use of eu.esdihumboldt.hale.io.jdbc.constraints.SQLArray in project hale by halestudio.
the class SQLArrayFactory method restore.
@Override
public SQLArray restore(Value value, Definition<?> definition, TypeResolver typeIndex, ClassResolver resolver) throws Exception {
ValueProperties props = value.as(ValueProperties.class);
if (props != null) {
// read element class
Class<?> elementType = null;
String className = props.getSafe(NAME_ELEMENT_CLASS).as(String.class);
if (className != null) {
elementType = resolver.loadClass(className);
}
// read element database type name
String elementTypeName = props.getSafe(NAME_ELEMENT_TYPE_NAME).as(String.class);
// read dimension
int dimension = props.getSafe(NAME_DIMENSION).as(Integer.class, 0);
// read array dimension sizes
int[] sizes = null;
ValueList sizeList = props.getSafe(NAME_SIZES).as(ValueList.class);
if (sizeList != null) {
sizes = new int[sizeList.size()];
int index = 0;
for (Value size : sizeList) {
sizes[index] = size.as(Integer.class, 0);
index++;
}
}
return new SQLArray(elementType, elementTypeName, dimension, sizes);
}
return SQLArray.NO_ARRAY;
}
Aggregations