diff --git a/src/org/atriasoft/exml/builder/BuilderIntrospection.java b/src/org/atriasoft/exml/builder/BuilderIntrospection.java index 6decf8f..62ac2a0 100644 --- a/src/org/atriasoft/exml/builder/BuilderIntrospection.java +++ b/src/org/atriasoft/exml/builder/BuilderIntrospection.java @@ -69,17 +69,25 @@ public class BuilderIntrospection implements Builder { String listTreeName = introspectionObject.getTreeNameOfSubNode(nodeName); if (typeClass != null) { // specific case for List ==> need to get the subType in introspection ... - if (!List.class.isAssignableFrom(typeClass)) { - Log.verbose("Create new class: '" + typeClass.getCanonicalName() + "' for node '" + nodeName + "'"); - final IntrospectionModel inferData = findOrCreate(typeClass); + if (typeClass.isArray()) { + Class subTypeClass = typeClass.getComponentType(); + Log.verbose("Create array new 'SUB' class: '" + typeClass.getCanonicalName() + "' for node '" + nodeName + "'"); + final IntrospectionModel inferData = findOrCreate(subTypeClass); // Create the data when object is ended created... - return new IntrospectionObject(inferData, listTreeName); + return new IntrospectionObject(inferData, listTreeName); } - Class subTypeClass = introspectionObject.getTypeOfSubNodeSubType(nodeName); - Log.verbose("Create new 'SUB' class: '" + typeClass.getCanonicalName() + "' for node '" + nodeName + "'"); - final IntrospectionModel inferData = findOrCreate(subTypeClass); + if (List.class.isAssignableFrom(typeClass)) { + Class subTypeClass = introspectionObject.getTypeOfSubNodeSubType(nodeName); + Log.verbose("Create List new 'SUB' class: '" + typeClass.getCanonicalName() + "' for node '" + nodeName + "'"); + final IntrospectionModel inferData = findOrCreate(subTypeClass); + // Create the data when object is ended created... + return new IntrospectionObject(inferData, listTreeName); + } + Log.verbose("Create new class: '" + typeClass.getCanonicalName() + "' for node '" + nodeName + "'"); + final IntrospectionModel inferData = findOrCreate(typeClass); // Create the data when object is ended created... return new IntrospectionObject(inferData, listTreeName); + } return null; } diff --git a/src/org/atriasoft/exml/builder/IntrospectionModelBaseType.java b/src/org/atriasoft/exml/builder/IntrospectionModelBaseType.java index c465208..034c6e1 100644 --- a/src/org/atriasoft/exml/builder/IntrospectionModelBaseType.java +++ b/src/org/atriasoft/exml/builder/IntrospectionModelBaseType.java @@ -25,6 +25,7 @@ public class IntrospectionModelBaseType extends IntrospectionModel { @Override public Object getValueFromText(final String text) throws ExmlBuilderException { + //il y a un bug ici ... return StringSerializer.valueOf(this.classType, text); } diff --git a/src/org/atriasoft/exml/builder/IntrospectionObject.java b/src/org/atriasoft/exml/builder/IntrospectionObject.java index e0cb63a..cb50b87 100644 --- a/src/org/atriasoft/exml/builder/IntrospectionObject.java +++ b/src/org/atriasoft/exml/builder/IntrospectionObject.java @@ -9,7 +9,7 @@ import org.atriasoft.exml.exception.ExmlBuilderException; import org.atriasoft.exml.internal.Log; public class IntrospectionObject { - private final IntrospectionModel dataInterface; + private final IntrospectionModel modelInterface; private Object data = null; private final String listNameModel; private final Map properties = new HashMap<>(); @@ -19,18 +19,18 @@ public class IntrospectionObject { * Create and empty element that have nothing. this is for the root node ==> not capable of knowing if only one element is created or many ... */ public IntrospectionObject() { - this.dataInterface = null; + this.modelInterface = null; this.data = new ArrayList<>(); this.listNameModel = null; } public IntrospectionObject(final IntrospectionModel dataInterface, final String listNameModel) { - this.dataInterface = dataInterface; + this.modelInterface = dataInterface; this.listNameModel = listNameModel; } public IntrospectionObject(final IntrospectionModel dataInterface) { - this.dataInterface = dataInterface; + this.modelInterface = dataInterface; this.listNameModel = null; } @@ -43,12 +43,12 @@ public class IntrospectionObject { } public IntrospectionModel getDataInterface() { - return this.dataInterface; + return this.modelInterface; } public void setProperty(final String propertyName, final String propertyValue) throws Exception { // Old way ... this.dataInterface.setProperty(this.data, propertyName, propertyValue); - Object value = this.dataInterface.getValue(propertyName, propertyValue); + Object value = this.modelInterface.getValue(propertyName, propertyValue); if (this.properties.containsKey(propertyName)) { throw new ExmlBuilderException("Property have multiple values ==> impossible case; A Node must contain only 1 attibutes"); } @@ -61,20 +61,20 @@ public class IntrospectionObject { * @return Class of the node to create */ public Class getTypeOfSubNode(final String nodeName) throws ExmlBuilderException { - return this.dataInterface.getTypeOfSubNode(this.data, nodeName); + return this.modelInterface.getTypeOfSubNode(this.data, nodeName); } public Class getTypeOfSubNodeSubType(final String nodeName) throws ExmlBuilderException { - return this.dataInterface.getTypeOfSubNodeList(this.data, nodeName); + return this.modelInterface.getTypeOfSubNodeList(this.data, nodeName); } public String getTreeNameOfSubNode(final String nodeName) throws ExmlBuilderException { - return this.dataInterface.getTreeNameOfSubNode(this.data, nodeName); + return this.modelInterface.getTreeNameOfSubNode(this.data, nodeName); } public void setText(final String text) throws ExmlBuilderException { if (this.data != null) { throw new ExmlBuilderException("Can not set multiple text value in a single NODE ..."); } - this.data = this.dataInterface.getValueFromText(text); + this.data = this.modelInterface.getValueFromText(text); } @SuppressWarnings("unchecked") @@ -102,10 +102,10 @@ public class IntrospectionObject { return; } if (this.listNameModel == null) { - Log.info("Create the element for the Specific node ... type = " + this.dataInterface.getClassType().getCanonicalName()); + Log.info("Create the element for the Specific node ... type = " + this.modelInterface.getClassType().getCanonicalName()); Log.info(" Properties : " + this.properties.keySet()); Log.info(" Nodes : " + this.nodes.keySet()); - this.data = this.dataInterface.createObject(this.properties, this.nodes); + this.data = this.modelInterface.createObject(this.properties, this.nodes); } else { if (this.properties.size() != 0) { throw new ExmlBuilderException("SubNode in tree can not have propoerties !!!!"); diff --git a/src/org/atriasoft/exml/generator/GeneratorIntrospection.java b/src/org/atriasoft/exml/generator/GeneratorIntrospection.java index f15fe12..4559334 100644 --- a/src/org/atriasoft/exml/generator/GeneratorIntrospection.java +++ b/src/org/atriasoft/exml/generator/GeneratorIntrospection.java @@ -8,6 +8,7 @@ import org.atriasoft.exml.builder.IntrospectionModel; import org.atriasoft.exml.builder.IntrospectionModelFactory; import org.atriasoft.exml.builder.IntrospectionProperty; import org.atriasoft.exml.exception.ExmlBuilderException; +import org.atriasoft.exml.internal.Log; import org.atriasoft.exml.parser.Tools; public class GeneratorIntrospection implements Generator { @@ -66,6 +67,8 @@ public class GeneratorIntrospection implements Generator { continue; } Class type = elem.getType(); + Class subType = elem.getSubType(); + generateNode(dataObj, name, tmpp, indent); /* if (List.class.isAssignableFrom(type)) { @@ -104,6 +107,8 @@ public class GeneratorIntrospection implements Generator { tmpp.append(nodeName); tmpp.append(">"); } + } else if (introspection.isList()) { + Log.error("lkjlk"); } else { Tools.addIndent(tmpp, indent); tmpp.append("<");