use of com.abubusoft.kripton.exception.KriptonRuntimeException in project kripton by xcesco.
the class CharBeanTable method parseValue2.
/**
* for attribute value2 parsing
*/
public static Character[] parseValue2(byte[] input) {
if (input == null) {
return null;
}
KriptonJsonContext context = KriptonBinder.jsonBind();
try (JacksonWrapperParser wrapper = context.createParser(input)) {
JsonParser jacksonParser = wrapper.jacksonParser;
// START_OBJECT
jacksonParser.nextToken();
// value of "element"
jacksonParser.nextValue();
Character[] result = null;
if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
ArrayList<Character> collection = new ArrayList<>();
Character item = null;
while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
if (jacksonParser.currentToken() == JsonToken.VALUE_NULL) {
item = null;
} else {
item = Character.valueOf((char) jacksonParser.getIntValue());
}
collection.add(item);
}
result = CollectionUtils.asCharacterArray(collection);
}
return result;
} catch (Exception e) {
throw (new KriptonRuntimeException(e.getMessage()));
}
}
use of com.abubusoft.kripton.exception.KriptonRuntimeException in project kripton by xcesco.
the class BindIntDataSource method build.
/**
* <p>Build instance. This method can be used only one time, on the application start.</p>
*/
public static BindIntDataSource build(DataSourceOptions options) {
BindIntDataSource result = instance;
if (result == null) {
synchronized (mutex) {
result = instance;
if (result == null) {
instance = result = new BindIntDataSource(options);
SQLiteDatabase database = instance.openWritableDatabase();
try {
} catch (Throwable e) {
Logger.error(e.getMessage());
e.printStackTrace();
} finally {
instance.close();
}
} else {
throw new KriptonRuntimeException("Datasource BindIntDataSource is already builded");
}
}
} else {
throw new KriptonRuntimeException("Datasource BindIntDataSource is already builded");
}
return result;
}
use of com.abubusoft.kripton.exception.KriptonRuntimeException in project kripton by xcesco.
the class BeanDaoImpl method parser5.
/**
* for param parser5 parsing
*/
private Set<String> parser5(byte[] input) {
if (input == null) {
return null;
}
KriptonJsonContext context = KriptonBinder.jsonBind();
try (JacksonWrapperParser wrapper = context.createParser(input)) {
JsonParser jacksonParser = wrapper.jacksonParser;
// START_OBJECT
jacksonParser.nextToken();
// value of "element"
jacksonParser.nextValue();
Set<String> result = null;
if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
HashSet<String> collection = new HashSet<>();
String item = null;
while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
if (jacksonParser.currentToken() == JsonToken.VALUE_NULL) {
item = null;
} else {
item = jacksonParser.getText();
}
collection.add(item);
}
result = collection;
}
return result;
} catch (Exception e) {
throw (new KriptonRuntimeException(e.getMessage()));
}
}
use of com.abubusoft.kripton.exception.KriptonRuntimeException in project kripton by xcesco.
the class BeanDaoImpl method serializer1.
/**
* for param serializer1 serialization
*/
private byte[] serializer1(Bean[] value) {
if (value == null) {
return null;
}
KriptonJsonContext context = KriptonBinder.jsonBind();
try (KriptonByteArrayOutputStream stream = new KriptonByteArrayOutputStream();
JacksonWrapperSerializer wrapper = context.createSerializer(stream)) {
JsonGenerator jacksonSerializer = wrapper.jacksonGenerator;
int fieldCount = 0;
jacksonSerializer.writeStartObject();
if (value != null) {
int n = value.length;
Bean item;
// write wrapper tag
jacksonSerializer.writeFieldName("element");
jacksonSerializer.writeStartArray();
for (int i = 0; i < n; i++) {
item = value[i];
if (item == null) {
jacksonSerializer.writeNull();
} else {
beanBindMap.serializeOnJackson(item, jacksonSerializer);
}
}
jacksonSerializer.writeEndArray();
}
jacksonSerializer.writeEndObject();
jacksonSerializer.flush();
return stream.toByteArray();
} catch (Exception e) {
throw (new KriptonRuntimeException(e.getMessage()));
}
}
use of com.abubusoft.kripton.exception.KriptonRuntimeException in project kripton by xcesco.
the class BeanDaoImpl method parser1.
/**
* for param parser1 parsing
*/
private Bean[] parser1(byte[] input) {
if (input == null) {
return null;
}
KriptonJsonContext context = KriptonBinder.jsonBind();
try (JacksonWrapperParser wrapper = context.createParser(input)) {
JsonParser jacksonParser = wrapper.jacksonParser;
// START_OBJECT
jacksonParser.nextToken();
// value of "element"
jacksonParser.nextValue();
Bean[] result = null;
if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
ArrayList<Bean> collection = new ArrayList<>();
Bean item = null;
while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
if (jacksonParser.currentToken() == JsonToken.VALUE_NULL) {
item = null;
} else {
item = beanBindMap.parseOnJackson(jacksonParser);
}
collection.add(item);
}
result = CollectionUtils.asArray(collection, new Bean[collection.size()]);
}
return result;
} catch (Exception e) {
throw (new KriptonRuntimeException(e.getMessage()));
}
}
Aggregations