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);
}
}
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;
}
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;
}
}
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);
}
}
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));
}
Aggregations