use of net.jangaroo.exml.json.JsonArray in project jangaroo-tools by CoreMedia.
the class ExmlToModelParser method parseValue.
private Object parseValue(ExmlModel model, boolean configTypeArray, List<Element> childElements) {
Object value;
List<Object> childObjects = parseChildObjects(model, childElements);
if (childObjects.size() > 1 || configTypeArray) {
// TODO: Check for type violation
// We must write an array.
value = new JsonArray(childObjects.toArray());
} else if (childObjects.size() == 1) {
// The property is either unspecified, untyped, or object-typed
// and it contains a single child element. Use that element as the
// property value.
value = childObjects.get(0);
} else {
value = null;
}
return value;
}
use of net.jangaroo.exml.json.JsonArray in project jangaroo-tools by CoreMedia.
the class ExmlToModelParserTest method testInheritProperties.
@Test
public void testInheritProperties() throws Exception {
setUp("testNamespace.config");
ExmlToModelParser exmlToModelParser = new ExmlToModelParser(getConfigClassRegistry());
ExmlModel model = exmlToModelParser.parse(getFile("/testPackage/TestComponent2.exml"));
Assert.assertEquals("testPackage.TestComponent", model.getSuperClassName());
JsonObject expectedJsonObject = new JsonObject("items", new JsonArray(new JsonObject("propertyThree", "3").settingWrapperClass("testNamespace.config.testComponent2")), "columns", new JsonObject("xtype", "agridcolumn"));
System.out.println(model.getJsonObject().toString(2));
Assert.assertEquals(expectedJsonObject.toString(2), model.getJsonObject().toString(2));
}
use of net.jangaroo.exml.json.JsonArray in project jangaroo-tools by CoreMedia.
the class ExmlToModelParserTest method testContainerDefaults.
@Test
public void testContainerDefaults() throws Exception {
setUp("testNamespace.config");
ExmlToModelParser exmlToModelParser = new ExmlToModelParser(getConfigClassRegistry());
ExmlModel model = exmlToModelParser.parse(getFile("/testPackage/TestContainerDefaults.exml"));
JsonObject expectedJsonObject = new JsonObject("defaults", new JsonObject("text", "it works!"), "defaultType", "button", "items", new JsonArray(new JsonObject("xtype", "container", "defaults", new JsonObject("propertyOne", true), "defaultType", "testNamespace.config.testComponent")));
System.out.println(model.getJsonObject().toString(2));
Assert.assertEquals(expectedJsonObject.toString(2), model.getJsonObject().toString(2));
}
use of net.jangaroo.exml.json.JsonArray in project jangaroo-tools by CoreMedia.
the class ExmlToModelParserTest method testParseTyped.
@Test
public void testParseTyped() throws Exception {
setUp("exmlparser.config");
ExmlToModelParser exmlToModelParser = new ExmlToModelParser(getConfigClassRegistry());
ExmlModel model = exmlToModelParser.parse(getFile("/exmlparser/TestTyped.exml"));
Assert.assertEquals("ext.Panel", model.getSuperClassName());
JsonObject expectedJsonObject = new JsonObject("items", new JsonArray(new JsonObject("xtype", "component", // not the number 5!
"margins", // not the number 5!
"5"), new JsonObject("xtype", "component", // not the boolean false!
"id", // not the boolean false!
"false")));
System.out.println(model.getJsonObject().toString(2));
Assert.assertEquals(expectedJsonObject.toString(2), model.getJsonObject().toString(2));
}
use of net.jangaroo.exml.json.JsonArray in project jangaroo-tools by CoreMedia.
the class ExmlToModelParserTest method testParseTestNumber.
@Test
public void testParseTestNumber() throws Exception {
setUp("exmlparser.config");
ExmlToModelParser exmlToModelParser = new ExmlToModelParser(getConfigClassRegistry());
ExmlModel model = exmlToModelParser.parse(getFile("/exmlparser/TestNumber.exml"));
Assert.assertEquals("ext.Panel", model.getSuperClassName());
JsonObject expectedJsonObject = new JsonObject("items", new JsonArray(new JsonObject("xtype", "panel", "id", "foo", "x", 100.0), new JsonObject("xtype", "panel", "id", "foo", "x", 1.5), new JsonObject("xtype", "panel", "id", "foo", "x", 1.0), new JsonObject("xtype", "panel", "id", "foo", "x", -1.5), new JsonObject("xtype", "panel", "id", "foo", "x", 3.0)));
System.out.println(model.getJsonObject().toString(2));
Assert.assertEquals(expectedJsonObject.toString(2), model.getJsonObject().toString(2));
}
Aggregations