use of org.whole.lang.properties.factories.PropertiesEntityFactory in project whole by wholeplatform.
the class DescriptorsTest method testDataEntityDescriptorIndexOf.
@Test
public void testDataEntityDescriptorIndexOf() {
PropertiesEntityFactory ef = PropertiesEntityFactory.instance;
PropertyName e1 = ef.createPropertyName("pn1");
EntityDescriptor<?> ed = e1.wGetEntityDescriptor();
int i1 = ed.indexOf(CommonsFeatureDescriptorEnum.data_value);
assertEquals(0, i1);
}
use of org.whole.lang.properties.factories.PropertiesEntityFactory 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.factories.PropertiesEntityFactory 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.factories.PropertiesEntityFactory in project whole by wholeplatform.
the class NormalizerOperationTest method testDefaultBehavior.
@Test
public void testDefaultBehavior() {
assertFalse(ReflectionFactory.getLanguageKit(PropertiesLanguageKit.URI).hasVisitor(NormalizerOperation.ID));
PropertiesEntityFactory ef = PropertiesEntityFactory.instance;
Entries entries = ef.createEntries(ef.createProperty(), ef.create(PropertiesEntityDescriptorEnum.Property, "p2", "v2"));
Entries entriesOrig = EntityUtils.clone(entries);
NormalizerOperation.normalize(entries);
assertTrue(Matcher.match(entriesOrig, entries));
}
use of org.whole.lang.properties.factories.PropertiesEntityFactory in project whole by wholeplatform.
the class DescriptorsTest method testCompositeEntityDescriptorIndexOf.
@Test
public void testCompositeEntityDescriptorIndexOf() {
PropertiesEntityFactory ef = PropertiesEntityFactory.instance;
Entries e1 = ef.createEntries();
EntityDescriptor<?> ed = e1.wGetEntityDescriptor();
int i1 = ed.indexOf(CommonsFeatureDescriptorEnum.composite_element);
assertEquals(0, i1);
int i2 = ed.indexOf(PropertiesFeatureDescriptorEnum.name);
assertEquals(-1, i2);
int i3 = e1.wIndexOf(CommonsFeatureDescriptorEnum.composite_element);
assertEquals(0, i3);
}
Aggregations