use of com.abubusoft.kripton.exception.KriptonRuntimeException in project kripton by xcesco.
the class DaoBean05Impl method serializer1.
/**
* for param serializer1 serialization
*/
private byte[] serializer1(Long 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) {
jacksonSerializer.writeNumberField("element", value);
}
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 BindApp1DataSource method build.
/**
* <p>Build instance. This method can be used only one time, on the application start.</p>
*/
public static BindApp1DataSource build(DataSourceOptions options) {
BindApp1DataSource result = instance;
if (result == null) {
synchronized (mutex) {
result = instance;
if (result == null) {
instance = result = new BindApp1DataSource(options);
SQLiteDatabase database = instance.openWritableDatabase();
try {
} catch (Throwable e) {
Logger.error(e.getMessage());
e.printStackTrace();
} finally {
instance.close();
}
} else {
throw new KriptonRuntimeException("Datasource BindApp1DataSource is already builded");
}
}
} else {
throw new KriptonRuntimeException("Datasource BindApp1DataSource is already builded");
}
return result;
}
use of com.abubusoft.kripton.exception.KriptonRuntimeException in project kripton by xcesco.
the class BindDummy01DataSource method build.
/**
* <p>Build instance. This method can be used only one time, on the application start.</p>
*/
public static BindDummy01DataSource build(DataSourceOptions options) {
BindDummy01DataSource result = instance;
if (result == null) {
synchronized (mutex) {
result = instance;
if (result == null) {
instance = result = new BindDummy01DataSource(options);
SQLiteDatabase database = instance.openWritableDatabase();
try {
} catch (Throwable e) {
Logger.error(e.getMessage());
e.printStackTrace();
} finally {
instance.close();
}
} else {
throw new KriptonRuntimeException("Datasource BindDummy01DataSource is already builded");
}
}
} else {
throw new KriptonRuntimeException("Datasource BindDummy01DataSource is already builded");
}
return result;
}
use of com.abubusoft.kripton.exception.KriptonRuntimeException in project kripton by xcesco.
the class BindDummy02DataSource method build.
/**
* <p>Build instance. This method can be used only one time, on the application start.</p>
*/
public static BindDummy02DataSource build(DataSourceOptions options) {
BindDummy02DataSource result = instance;
if (result == null) {
synchronized (mutex) {
result = instance;
if (result == null) {
instance = result = new BindDummy02DataSource(options);
SQLiteDatabase database = instance.openWritableDatabase();
try {
} catch (Throwable e) {
Logger.error(e.getMessage());
e.printStackTrace();
} finally {
instance.close();
}
} else {
throw new KriptonRuntimeException("Datasource BindDummy02DataSource is already builded");
}
}
} else {
throw new KriptonRuntimeException("Datasource BindDummy02DataSource is already builded");
}
return result;
}
use of com.abubusoft.kripton.exception.KriptonRuntimeException in project kripton by xcesco.
the class Bean01Table method parseTemp.
/**
* for attribute temp parsing
*/
public static List<String> parseTemp(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();
List<String> result = null;
if (jacksonParser.currentToken() == JsonToken.START_ARRAY) {
ArrayList<String> collection = new ArrayList<>();
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()));
}
}
Aggregations