use of org.whole.lang.properties.model.Properties in project whole by wholeplatform.
the class PropertiesTest method testLoadAsText.
@Test
public void testLoadAsText() throws IOException {
Properties props1 = PropertiesUtils.loadFromText(PropertiesTest.class.getResourceAsStream("plugin.properties"));
Properties props2 = PropertiesUtils.loadFromText(PropertiesTest.class.getResourceAsStream("build.properties"));
PropertiesUtils.saveToText(props2, System.out, "comment");
PropertiesUtils.saveToXml(props1, System.out, "comment");
}
use of org.whole.lang.properties.model.Properties 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;
}
use of org.whole.lang.properties.model.Properties in project whole by wholeplatform.
the class PropertiesUtils method translate.
@SuppressWarnings("unchecked")
public static Properties translate(java.util.Properties jProps) throws IOException {
PropertiesEntityFactory lf = PropertiesEntityFactory.instance;
Properties props = lf.create(PropertiesEntityDescriptorEnum.Properties);
Entries entries = props.getEntries();
if (entries.wSize() == 1)
// workaround for removing the resolver
entries.wRemove(0);
Enumeration<String> names = (Enumeration<String>) jProps.propertyNames();
while (names.hasMoreElements()) {
String name = names.nextElement();
String value = jProps.getProperty(name);
entries.wAdd(lf.createProperty(lf.createPropertyName(name), // FIXME workaround for null valued property returned from System.getProperties()
value != null ? lf.createPropertyValue(value) : CommonsEntityAdapterFactory.createResolver(PropertiesEntityDescriptorEnum.PropertyValue)));
}
return props;
}
use of org.whole.lang.properties.model.Properties in project whole by wholeplatform.
the class PropertiesPart method getModelSpecificChildren.
@Override
protected List<IEntity> getModelSpecificChildren() {
Properties entity = getModelEntity();
List<IEntity> list = new ArrayList<IEntity>(3);
list.add(entity.getComment());
list.add(entity.getDefaults());
list.add(entity.getEntries());
return list;
}
use of org.whole.lang.properties.model.Properties in project whole by wholeplatform.
the class PersistenceTest method testSingleBuilder2Java.
@Test
public void testSingleBuilder2Java() {
ModelBuilderOperation op = new ModelBuilderOperation();
JavaStoreProducerBuilderOperation javaOp = new JavaStoreProducerBuilderOperation(op);
((JavaStoreProducerBuilder) javaOp.wGetBuilder()).buildStartCompilationUnit("test", "Test");
try {
Properties props = PropertiesUtils.translate(System.getProperties());
props.getEntries().wAdd(0, createResolver(PropertiesEntityDescriptorEnum.Property));
new ModelTemplate(props).apply(javaOp);
} catch (IOException e) {
e.printStackTrace();
}
// new TopDownTraversal(new ModelsModel().create()).apply(javaOp);
((JavaStoreProducerBuilder) javaOp.wGetBuilder()).buildEndCompilationUnit();
// new ModelsModel().apply(new JavaStoreProducerBuilderOperation(op));
IEntity model = op.wGetResult();
PrettyPrinterOperation.prettyPrint(model);
}
Aggregations