[DEV] update list
This commit is contained in:
parent
d4b528eedf
commit
c7297bd106
@ -69,17 +69,25 @@ public class BuilderIntrospection implements Builder {
|
|||||||
String listTreeName = introspectionObject.getTreeNameOfSubNode(nodeName);
|
String listTreeName = introspectionObject.getTreeNameOfSubNode(nodeName);
|
||||||
if (typeClass != null) {
|
if (typeClass != null) {
|
||||||
// specific case for List ==> need to get the subType in introspection ...
|
// specific case for List ==> need to get the subType in introspection ...
|
||||||
if (!List.class.isAssignableFrom(typeClass)) {
|
if (typeClass.isArray()) {
|
||||||
Log.verbose("Create new class: '" + typeClass.getCanonicalName() + "' for node '" + nodeName + "'");
|
Class<?> subTypeClass = typeClass.getComponentType();
|
||||||
final IntrospectionModel inferData = findOrCreate(typeClass);
|
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...
|
// Create the data when object is ended created...
|
||||||
return new IntrospectionObject(inferData, listTreeName);
|
return new IntrospectionObject(inferData, listTreeName);
|
||||||
}
|
}
|
||||||
Class<?> subTypeClass = introspectionObject.getTypeOfSubNodeSubType(nodeName);
|
if (List.class.isAssignableFrom(typeClass)) {
|
||||||
Log.verbose("Create new 'SUB' class: '" + typeClass.getCanonicalName() + "' for node '" + nodeName + "'");
|
Class<?> subTypeClass = introspectionObject.getTypeOfSubNodeSubType(nodeName);
|
||||||
final IntrospectionModel inferData = findOrCreate(subTypeClass);
|
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...
|
// Create the data when object is ended created...
|
||||||
return new IntrospectionObject(inferData, listTreeName);
|
return new IntrospectionObject(inferData, listTreeName);
|
||||||
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ public class IntrospectionModelBaseType extends IntrospectionModel {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getValueFromText(final String text) throws ExmlBuilderException {
|
public Object getValueFromText(final String text) throws ExmlBuilderException {
|
||||||
|
//il y a un bug ici ...
|
||||||
return StringSerializer.valueOf(this.classType, text);
|
return StringSerializer.valueOf(this.classType, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import org.atriasoft.exml.exception.ExmlBuilderException;
|
|||||||
import org.atriasoft.exml.internal.Log;
|
import org.atriasoft.exml.internal.Log;
|
||||||
|
|
||||||
public class IntrospectionObject {
|
public class IntrospectionObject {
|
||||||
private final IntrospectionModel dataInterface;
|
private final IntrospectionModel modelInterface;
|
||||||
private Object data = null;
|
private Object data = null;
|
||||||
private final String listNameModel;
|
private final String listNameModel;
|
||||||
private final Map<String, Object> properties = new HashMap<>();
|
private final Map<String, Object> 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 ...
|
* 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() {
|
public IntrospectionObject() {
|
||||||
this.dataInterface = null;
|
this.modelInterface = null;
|
||||||
this.data = new ArrayList<>();
|
this.data = new ArrayList<>();
|
||||||
this.listNameModel = null;
|
this.listNameModel = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IntrospectionObject(final IntrospectionModel dataInterface, final String listNameModel) {
|
public IntrospectionObject(final IntrospectionModel dataInterface, final String listNameModel) {
|
||||||
this.dataInterface = dataInterface;
|
this.modelInterface = dataInterface;
|
||||||
this.listNameModel = listNameModel;
|
this.listNameModel = listNameModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IntrospectionObject(final IntrospectionModel dataInterface) {
|
public IntrospectionObject(final IntrospectionModel dataInterface) {
|
||||||
this.dataInterface = dataInterface;
|
this.modelInterface = dataInterface;
|
||||||
this.listNameModel = null;
|
this.listNameModel = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,12 +43,12 @@ public class IntrospectionObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public IntrospectionModel getDataInterface() {
|
public IntrospectionModel getDataInterface() {
|
||||||
return this.dataInterface;
|
return this.modelInterface;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProperty(final String propertyName, final String propertyValue) throws Exception {
|
public void setProperty(final String propertyName, final String propertyValue) throws Exception {
|
||||||
// Old way ... this.dataInterface.setProperty(this.data, propertyName, propertyValue);
|
// 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)) {
|
if (this.properties.containsKey(propertyName)) {
|
||||||
throw new ExmlBuilderException("Property have multiple values ==> impossible case; A Node must contain only 1 attibutes");
|
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
|
* @return Class of the node to create
|
||||||
*/
|
*/
|
||||||
public Class<?> getTypeOfSubNode(final String nodeName) throws ExmlBuilderException {
|
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 {
|
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 {
|
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 {
|
public void setText(final String text) throws ExmlBuilderException {
|
||||||
if (this.data != null) {
|
if (this.data != null) {
|
||||||
throw new ExmlBuilderException("Can not set multiple text value in a single NODE ...");
|
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")
|
@SuppressWarnings("unchecked")
|
||||||
@ -102,10 +102,10 @@ public class IntrospectionObject {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.listNameModel == null) {
|
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(" Properties : " + this.properties.keySet());
|
||||||
Log.info(" Nodes : " + this.nodes.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 {
|
} else {
|
||||||
if (this.properties.size() != 0) {
|
if (this.properties.size() != 0) {
|
||||||
throw new ExmlBuilderException("SubNode in tree can not have propoerties !!!!");
|
throw new ExmlBuilderException("SubNode in tree can not have propoerties !!!!");
|
||||||
|
@ -8,6 +8,7 @@ import org.atriasoft.exml.builder.IntrospectionModel;
|
|||||||
import org.atriasoft.exml.builder.IntrospectionModelFactory;
|
import org.atriasoft.exml.builder.IntrospectionModelFactory;
|
||||||
import org.atriasoft.exml.builder.IntrospectionProperty;
|
import org.atriasoft.exml.builder.IntrospectionProperty;
|
||||||
import org.atriasoft.exml.exception.ExmlBuilderException;
|
import org.atriasoft.exml.exception.ExmlBuilderException;
|
||||||
|
import org.atriasoft.exml.internal.Log;
|
||||||
import org.atriasoft.exml.parser.Tools;
|
import org.atriasoft.exml.parser.Tools;
|
||||||
|
|
||||||
public class GeneratorIntrospection implements Generator {
|
public class GeneratorIntrospection implements Generator {
|
||||||
@ -66,6 +67,8 @@ public class GeneratorIntrospection implements Generator {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Class<?> type = elem.getType();
|
Class<?> type = elem.getType();
|
||||||
|
Class<?> subType = elem.getSubType();
|
||||||
|
|
||||||
generateNode(dataObj, name, tmpp, indent);
|
generateNode(dataObj, name, tmpp, indent);
|
||||||
/*
|
/*
|
||||||
if (List.class.isAssignableFrom(type)) {
|
if (List.class.isAssignableFrom(type)) {
|
||||||
@ -104,6 +107,8 @@ public class GeneratorIntrospection implements Generator {
|
|||||||
tmpp.append(nodeName);
|
tmpp.append(nodeName);
|
||||||
tmpp.append(">");
|
tmpp.append(">");
|
||||||
}
|
}
|
||||||
|
} else if (introspection.isList()) {
|
||||||
|
Log.error("lkjlk");
|
||||||
} else {
|
} else {
|
||||||
Tools.addIndent(tmpp, indent);
|
Tools.addIndent(tmpp, indent);
|
||||||
tmpp.append("<");
|
tmpp.append("<");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user