Search in sources :

Example 1 with KriptonRuntimeException

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()));
    }
}
Also used : JsonGenerator(com.fasterxml.jackson.core.JsonGenerator) KriptonRuntimeException(com.abubusoft.kripton.exception.KriptonRuntimeException) KriptonByteArrayOutputStream(com.abubusoft.kripton.common.KriptonByteArrayOutputStream) KriptonJsonContext(com.abubusoft.kripton.KriptonJsonContext) JacksonWrapperSerializer(com.abubusoft.kripton.persistence.JacksonWrapperSerializer) KriptonRuntimeException(com.abubusoft.kripton.exception.KriptonRuntimeException)

Example 2 with KriptonRuntimeException

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;
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) KriptonRuntimeException(com.abubusoft.kripton.exception.KriptonRuntimeException)

Example 3 with KriptonRuntimeException

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;
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) KriptonRuntimeException(com.abubusoft.kripton.exception.KriptonRuntimeException)

Example 4 with KriptonRuntimeException

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;
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) KriptonRuntimeException(com.abubusoft.kripton.exception.KriptonRuntimeException)

Example 5 with KriptonRuntimeException

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()));
    }
}
Also used : ArrayList(java.util.ArrayList) KriptonRuntimeException(com.abubusoft.kripton.exception.KriptonRuntimeException) KriptonJsonContext(com.abubusoft.kripton.KriptonJsonContext) JacksonWrapperParser(com.abubusoft.kripton.persistence.JacksonWrapperParser) KriptonRuntimeException(com.abubusoft.kripton.exception.KriptonRuntimeException) JsonParser(com.fasterxml.jackson.core.JsonParser)

Aggregations

KriptonRuntimeException (com.abubusoft.kripton.exception.KriptonRuntimeException)721 KriptonJsonContext (com.abubusoft.kripton.KriptonJsonContext)514 JacksonWrapperParser (com.abubusoft.kripton.persistence.JacksonWrapperParser)258 JacksonWrapperSerializer (com.abubusoft.kripton.persistence.JacksonWrapperSerializer)258 JsonParser (com.fasterxml.jackson.core.JsonParser)258 KriptonByteArrayOutputStream (com.abubusoft.kripton.common.KriptonByteArrayOutputStream)257 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)257 ArrayList (java.util.ArrayList)143 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)120 KriptonContentValues (com.abubusoft.kripton.android.sqlite.KriptonContentValues)68 HashMap (java.util.HashMap)43 HashSet (java.util.HashSet)40 LinkedHashSet (java.util.LinkedHashSet)38 Cursor (android.database.Cursor)31 LinkedList (java.util.LinkedList)26 Map (java.util.Map)24 LinkedHashMap (java.util.LinkedHashMap)18 BeanInner (sqlite.kripton58.BeanInner)18 BigDecimal (java.math.BigDecimal)12 Time (java.sql.Time)10