use of org.whole.lang.properties.model.PropertyValue in project whole by wholeplatform.
the class PropertiesUtils method setProperty.
public static String setProperty(Properties props, String name, String value) {
PropertiesEntityFactory lf = PropertiesEntityFactory.instance;
Property pattern = lf.createProperty(lf.createPropertyName(name), createVariable(PropertiesEntityDescriptorEnum.PropertyValue, "value"));
Property property = Matcher.findChild(pattern, props.getEntries());
if (property != null) {
PropertyValue pv = property.getValue();
String oldValue = pv.wStringValue();
pv.wSetValue(value);
return oldValue;
} else {
pattern.setValue(lf.createPropertyValue(value));
props.getEntries().wAdd(pattern);
return null;
}
}
use of org.whole.lang.properties.model.PropertyValue in project whole by wholeplatform.
the class PropertiesUtils method translate.
public static java.util.Properties translate(Properties props) {
if (EntityUtils.isResolver(props))
return null;
java.util.Properties jProps = new java.util.Properties(translate(props.getDefaults()));
props.getEntries();
ScannerIterator<Property> i = IteratorFactory.<Property>childScannerIterator();
i.reset(props.getEntries());
for (Property p : i) try {
PropertyValue value = p.getValue();
if (// FIXME workaround for null valued property returned from System.getProperties()
!EntityUtils.isResolver(value))
jProps.setProperty(p.getName().wStringValue(), value.wStringValue());
} catch (IllegalArgumentException e) {
}
return jProps;
}
Aggregations