Search in sources :

Example 26 with FieldSetting

use of com.tvd12.dahlia.core.setting.FieldSetting in project dahlia by youngmonkeys.

the class RecordReader method read.

public EzyObject read(Record record, FieldSetting idSetting, Map<String, FieldSetting> settings) {
    try {
        file.seek(record.getPosition());
        // header
        file.readByte();
        EzyObject output = EzyEntityFactory.newObject();
        Object id = fieldReaders.read(file, idSetting);
        output.put(FIELD_ID, id);
        fieldReaders.read(file, settings, output);
        return output;
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
}
Also used : EzyObject(com.tvd12.ezyfox.entity.EzyObject) EzyObject(com.tvd12.ezyfox.entity.EzyObject) IOException(java.io.IOException)

Example 27 with FieldSetting

use of com.tvd12.dahlia.core.setting.FieldSetting in project dahlia by youngmonkeys.

the class FieldObjectReader method readValue.

@Override
protected EzyObject readValue(FieldReaders readers, FileProxy file, FieldSetting setting) throws IOException {
    FieldObjectSetting fs = (FieldObjectSetting) setting;
    Map<String, FieldSetting> fieldSettings = fs.getFields();
    EzyObject object = EzyEntityFactory.newObject();
    readers.read(file, fieldSettings, object);
    return object;
}
Also used : FieldSetting(com.tvd12.dahlia.core.setting.FieldSetting) FieldObjectSetting(com.tvd12.dahlia.core.setting.FieldObjectSetting) EzyObject(com.tvd12.ezyfox.entity.EzyObject)

Example 28 with FieldSetting

use of com.tvd12.dahlia.core.setting.FieldSetting in project dahlia by youngmonkeys.

the class FieldSimpleReaders method read.

@Override
public void read(FileProxy file, Map<String, FieldSetting> settings, EzyObject output) throws IOException {
    int readFields = 0;
    int totalFields = settings.size();
    while (readFields < totalFields) {
        String fieldName = readName(file);
        FieldSetting setting = settings.get(fieldName);
        Object value = readValue(file, setting);
        output.put(fieldName, value);
        ++readFields;
    }
}
Also used : FieldSetting(com.tvd12.dahlia.core.setting.FieldSetting) EzyObject(com.tvd12.ezyfox.entity.EzyObject)

Example 29 with FieldSetting

use of com.tvd12.dahlia.core.setting.FieldSetting in project dahlia by youngmonkeys.

the class FieldSimpleWriters method write.

@Override
public void write(FileProxy file, Map<String, FieldSetting> settings, EzyObject values) throws IOException {
    for (Entry<String, FieldSetting> e : settings.entrySet()) {
        Object value = values.get(e.getKey());
        write(file, e.getKey(), e.getValue(), value);
    }
}
Also used : FieldSetting(com.tvd12.dahlia.core.setting.FieldSetting) EzyObject(com.tvd12.ezyfox.entity.EzyObject)

Example 30 with FieldSetting

use of com.tvd12.dahlia.core.setting.FieldSetting in project dahlia by youngmonkeys.

the class FieldArrayWriter method writeValue.

@Override
protected void writeValue(FieldWriters writers, FileProxy file, FieldSetting setting, EzyArray value) throws IOException {
    int size = value.size();
    file.writeShort((short) size);
    FieldArraySetting fs = (FieldArraySetting) setting;
    FieldSetting itemSetting = fs.getItem();
    for (int i = 0; i < size; ++i) writers.write(file, itemSetting, value.get(i));
}
Also used : FieldSetting(com.tvd12.dahlia.core.setting.FieldSetting) FieldArraySetting(com.tvd12.dahlia.core.setting.FieldArraySetting)

Aggregations

FieldSetting (com.tvd12.dahlia.core.setting.FieldSetting)25 EzyObject (com.tvd12.ezyfox.entity.EzyObject)20 CollectionSetting (com.tvd12.dahlia.core.setting.CollectionSetting)11 EzyArray (com.tvd12.ezyfox.entity.EzyArray)10 Collection (com.tvd12.dahlia.core.entity.Collection)9 Record (com.tvd12.dahlia.core.entity.Record)9 CollectionStorage (com.tvd12.dahlia.core.storage.CollectionStorage)7 RecordConsumer (com.tvd12.dahlia.core.function.RecordConsumer)5 CollectionNotFoundException (com.tvd12.dahlia.exception.CollectionNotFoundException)5 FieldArraySetting (com.tvd12.dahlia.core.setting.FieldArraySetting)4 FieldObjectSetting (com.tvd12.dahlia.core.setting.FieldObjectSetting)4 HashMap (java.util.HashMap)4 DataType (com.tvd12.dahlia.core.data.DataType)3 ArrayList (java.util.ArrayList)3 JSONObject (org.json.JSONObject)3 DahliaCore (com.tvd12.dahlia.core.DahliaCore)2 DahliaCoreLoader (com.tvd12.dahlia.core.DahliaCoreLoader)2 CommandCount (com.tvd12.dahlia.core.command.CommandCount)2 CommandCreateCollection (com.tvd12.dahlia.core.command.CommandCreateCollection)2 CommandCreateDatabase (com.tvd12.dahlia.core.command.CommandCreateDatabase)2