use of eu.esdihumboldt.hale.common.core.io.ValueProperties in project hale by halestudio.
the class EnumerationFactory method store.
@Override
public Value store(Enumeration<?> constraint, TypeReferenceBuilder typeIndex) {
ValueProperties props = new ValueProperties(2);
// values
if (constraint.getValues() != null) {
ValueList list = new ValueList();
for (Object value : constraint.getValues()) {
list.add(Value.simple(value));
}
props.put(P_VALUES, Value.complex(list));
// XXX also store the value type for reconstruction?
}
// allow others?
props.put(P_ALLOW_OTHERS, Value.of(constraint.isAllowOthers()));
return Value.complex(props);
}
use of eu.esdihumboldt.hale.common.core.io.ValueProperties in project hale by halestudio.
the class EnumerationFactory method restore.
@Override
public Enumeration<?> restore(Value value, Definition<?> definition, TypeResolver typeIndex, ClassResolver resolver) throws Exception {
ValueProperties props = value.as(ValueProperties.class);
boolean allowOthers = props.get(P_ALLOW_OTHERS).as(Boolean.class, true);
Collection<Object> values = null;
if (props.containsKey(P_VALUES)) {
values = new ArrayList<>();
ValueList list = props.get(P_VALUES).as(ValueList.class);
for (Value val : list) {
// XXX determine value type?
// XXX for now just use string
String str = val.as(String.class);
if (str != null) {
values.add(str);
} else {
// TODO warn?
}
}
}
return new Enumeration<Object>(values, allowOthers);
}
use of eu.esdihumboldt.hale.common.core.io.ValueProperties in project hale by halestudio.
the class GeometryMetadataFactory method restore.
@Override
public GeometryMetadata restore(Value value, Definition<?> definition, TypeResolver typeIndex, ClassResolver resolver) throws Exception {
ValueProperties props = value.as(ValueProperties.class);
if (props != null) {
String srs = props.getSafe(NAME_SRS).as(String.class);
int dimension = props.getSafe(NAME_DIMENSION).as(Integer.class, 0);
String srsText = props.getSafe(NAME_SRS_TEXT).as(String.class);
String auth_name = props.getSafe(NAME_AUTH_NAME).as(String.class);
return new GeometryMetadata(srs, dimension, srsText, auth_name);
} else {
return new GeometryMetadata();
}
}
use of eu.esdihumboldt.hale.common.core.io.ValueProperties in project hale by halestudio.
the class DigitCountValidatorFactory method restore.
@Override
public Validator restore(Value value) throws Exception {
ValueProperties props = value.as(ValueProperties.class);
Type type = Type.valueOf(props.getSafe(P_TYPE).as(String.class));
int length = props.getSafe(P_LENGTH).as(Integer.class);
return new DigitCountValidator(type, length);
}
use of eu.esdihumboldt.hale.common.core.io.ValueProperties in project hale by halestudio.
the class DigitCountValidatorFactory method store.
@Override
public Value store(DigitCountValidator validator) throws Exception {
ValueProperties props = new ValueProperties();
props.put(P_TYPE, Value.of(validator.getType().name()));
props.put(P_LENGTH, Value.of(validator.getLength()));
return props.toValue();
}
Aggregations