use of org.whole.lang.properties.model.Property in project whole by wholeplatform.
the class PropertyRowPart method getModelSpecificChildren.
@Override
protected List<IEntity> getModelSpecificChildren() {
Property entity = getModelEntity();
List<IEntity> list = new ArrayList<IEntity>(2);
list.add(entity.getName());
list.add(entity.getValue());
return list;
}
use of org.whole.lang.properties.model.Property in project whole by wholeplatform.
the class PropertyPart method getModelSpecificChildren.
@Override
protected List<IEntity> getModelSpecificChildren() {
Property entity = getModelEntity();
List<IEntity> list = new ArrayList<IEntity>(2);
list.add(entity.getName());
list.add(entity.getValue());
return list;
}
use of org.whole.lang.properties.model.Property 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.Property in project whole by wholeplatform.
the class PropertiesTest method testGetSetProperty.
@Test
public void testGetSetProperty() {
PropertiesEntityFactory lf = PropertiesEntityFactory.instance;
Properties props = lf.createProperties(lf.createComment("Test properties"), createResolver(PropertiesEntityDescriptorEnum.Properties), lf.createEntries(new Property[] { lf.createProperty(lf.createPropertyName("prop1"), lf.createPropertyValue("value 1")), lf.createProperty(lf.createPropertyName("prop2"), lf.createPropertyValue("value 2")) }));
String prop1Value = PropertiesUtils.getProperty(props, "prop1");
Assert.assertEquals("value 1", prop1Value);
}
use of org.whole.lang.properties.model.Property 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