[DEV] work on introspection generation
This commit is contained in:
parent
e68802010b
commit
7ef59f2f7e
@ -7,7 +7,7 @@
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-14">
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
|
@ -186,248 +186,264 @@ public class IntrospectionData {
|
||||
public Class<?> getSubClassType() {
|
||||
return this.subClassType;
|
||||
}
|
||||
public IntrospectionData(final Class<?> classType) throws Exception {
|
||||
public IntrospectionData(final Class<?> classType) throws ExmlBuilderException {
|
||||
this(classType, null);
|
||||
}
|
||||
public IntrospectionData(final Class<?> classType, final Class<?> subClassType) throws Exception {
|
||||
this.classType = classType;
|
||||
this.subClassType = subClassType;
|
||||
final Boolean isDefaultManaged = getIsDefaultManaged(classType, IntrospectionData.DEFAULT_MANAGED);
|
||||
final Boolean isDefaultOptional = getIsDefaultOptional(classType, IntrospectionData.DEFAULT_OPTIONAL);
|
||||
final Boolean isDefaultCaseSensitive = getIsDefaultCaseSensitive(classType, IntrospectionData.DEFAULT_CASE_SENSITIVE);
|
||||
Log.verbose("Introspect class: '" + classType.getCanonicalName() + "'");
|
||||
final Constructor<?>[] constructors = this.classType.getConstructors();
|
||||
Log.verbose(" Constructors: (" + constructors.length + ")");
|
||||
for (final Constructor<?> elem : constructors) {
|
||||
Log.verbose(" - " + elem.toGenericString());
|
||||
}
|
||||
final Field[] fields = this.classType.getFields();
|
||||
Log.verbose(" Fields: (" + fields.length + ")");
|
||||
for (final Field elem : fields) {
|
||||
final Boolean isManaged = getIsManaged(elem, isDefaultManaged);
|
||||
final Boolean isOptionnal = getIsOptional(elem, isDefaultOptional);
|
||||
final String[] names = getNames(elem, Tools.decapitalizeFirst(elem.getName()));
|
||||
final Boolean caseSensitive = getIsCaseSensitive(elem, isDefaultCaseSensitive);
|
||||
final String listName = getListName(elem, null);
|
||||
// TODO check if property does not already exist ...
|
||||
if (isManaged) {
|
||||
this.properties.add(new IntrospectionPropertyField(elem, names, listName, caseSensitive, isOptionnal));
|
||||
public IntrospectionData(final Class<?> classType, final Class<?> subClassType) throws ExmlBuilderException {
|
||||
try {
|
||||
this.classType = classType;
|
||||
this.subClassType = subClassType;
|
||||
final Boolean isDefaultManaged = getIsDefaultManaged(classType, IntrospectionData.DEFAULT_MANAGED);
|
||||
final Boolean isDefaultOptional = getIsDefaultOptional(classType, IntrospectionData.DEFAULT_OPTIONAL);
|
||||
final Boolean isDefaultCaseSensitive = getIsDefaultCaseSensitive(classType, IntrospectionData.DEFAULT_CASE_SENSITIVE);
|
||||
Log.verbose("Introspect class: '" + classType.getCanonicalName() + "'");
|
||||
final Constructor<?>[] constructors = this.classType.getConstructors();
|
||||
Log.verbose(" Constructors: (" + constructors.length + ")");
|
||||
for (final Constructor<?> elem : constructors) {
|
||||
Log.verbose(" - " + elem.toGenericString());
|
||||
}
|
||||
Log.verbose(" - " + elem.toGenericString());
|
||||
}
|
||||
final Method[] methodsTmp = this.classType.getMethods();
|
||||
// filter getX setX isX
|
||||
final List<Method> methods = List.of(methodsTmp).stream().filter(o -> {
|
||||
if (o.getName().contentEquals("getClass")) {
|
||||
return false;
|
||||
final Field[] fields = this.classType.getFields();
|
||||
Log.verbose(" Fields: (" + fields.length + ")");
|
||||
for (final Field elem : fields) {
|
||||
// we does not manage static field
|
||||
if (Modifier.isStatic(elem.getModifiers())) {
|
||||
continue;
|
||||
}
|
||||
// we does not manage private field
|
||||
if (!Modifier.isPublic(elem.getModifiers())) {
|
||||
continue;
|
||||
}
|
||||
final Boolean isManaged = getIsManaged(elem, isDefaultManaged);
|
||||
final Boolean isOptionnal = getIsOptional(elem, isDefaultOptional);
|
||||
final String[] names = getNames(elem, Tools.decapitalizeFirst(elem.getName()));
|
||||
final Boolean caseSensitive = getIsCaseSensitive(elem, isDefaultCaseSensitive);
|
||||
final String listName = getListName(elem, null);
|
||||
// TODO check if property does not already exist ...
|
||||
if (isManaged) {
|
||||
this.properties.add(new IntrospectionPropertyField(elem, names, listName, caseSensitive, isOptionnal));
|
||||
}
|
||||
Log.verbose(" - " + elem.toGenericString());
|
||||
}
|
||||
if (Modifier.isStatic(o.getModifiers())) {
|
||||
if (o.getName().contentEquals("valueOf") && o.getParameterCount() == 1 && o.getParameters()[0].getType() == String.class) {
|
||||
return true;
|
||||
final Method[] methodsTmp = this.classType.getMethods();
|
||||
// filter getX setX isX
|
||||
final List<Method> methods = List.of(methodsTmp).stream().filter(o -> {
|
||||
if (o.getName().contentEquals("getClass")) {
|
||||
return false;
|
||||
}
|
||||
// we does not manage private function
|
||||
if (!Modifier.isPublic(o.getModifiers())) {
|
||||
return false;
|
||||
}
|
||||
if (Modifier.isStatic(o.getModifiers())) {
|
||||
if (o.getName().contentEquals("valueOf") && o.getParameterCount() == 1 && o.getParameters()[0].getType() == String.class) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (o.getName().startsWith("get")) {
|
||||
if (o.getParameterCount() != 0 || o.getReturnType() == void.class || o.getReturnType() == Boolean.class || o.getReturnType() == boolean.class) {
|
||||
return false;
|
||||
}
|
||||
// check name format
|
||||
if (o.getName().length() == 3) {
|
||||
return false;
|
||||
}
|
||||
if (o.getName().charAt(3) >= 'A' && o.getName().charAt(3) <= 'Z') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (o.getName().startsWith("set")) {
|
||||
if (o.getReturnType() != void.class || o.getParameterCount() != 1) {
|
||||
return false;
|
||||
}
|
||||
// check name format
|
||||
if (o.getName().length() == 3) {
|
||||
return false;
|
||||
}
|
||||
if (o.getName().charAt(3) >= 'A' && o.getName().charAt(3) <= 'Z') {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
if (o.getName().startsWith("is")) {
|
||||
if (!(o.getReturnType() == Boolean.class || o.getReturnType() == boolean.class) && o.getParameterCount() != 0) {
|
||||
return false;
|
||||
}
|
||||
// check name format
|
||||
if (o.getName().length() == 2) {
|
||||
return false;
|
||||
}
|
||||
if (o.getName().charAt(2) >= 'A' && o.getName().charAt(2) <= 'Z') {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}).collect(Collectors.toList());
|
||||
Log.verbose(" Methods: (" + methods.size() + ")");
|
||||
for (final Method elem : methods) {
|
||||
Log.verbose(" - " + elem.toGenericString());
|
||||
}
|
||||
if (o.getName().startsWith("get")) {
|
||||
if (o.getParameterCount() != 0 || o.getReturnType() == void.class || o.getReturnType() == Boolean.class || o.getReturnType() == boolean.class) {
|
||||
return false;
|
||||
}
|
||||
// check name format
|
||||
if (o.getName().length() == 3) {
|
||||
return false;
|
||||
}
|
||||
if (o.getName().charAt(3) >= 'A' && o.getName().charAt(3) <= 'Z') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (o.getName().startsWith("set")) {
|
||||
if (o.getReturnType() != void.class || o.getParameterCount() != 1) {
|
||||
return false;
|
||||
}
|
||||
// check name format
|
||||
if (o.getName().length() == 3) {
|
||||
return false;
|
||||
}
|
||||
if (o.getName().charAt(3) >= 'A' && o.getName().charAt(3) <= 'Z') {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
if (o.getName().startsWith("is")) {
|
||||
if (!(o.getReturnType() == Boolean.class || o.getReturnType() == boolean.class) && o.getParameterCount() != 0) {
|
||||
return false;
|
||||
}
|
||||
// check name format
|
||||
if (o.getName().length() == 2) {
|
||||
return false;
|
||||
}
|
||||
if (o.getName().charAt(2) >= 'A' && o.getName().charAt(2) <= 'Z') {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}).collect(Collectors.toList());
|
||||
Log.verbose(" Methods: (" + methods.size() + ")");
|
||||
for (final Method elem : methods) {
|
||||
Log.verbose(" - " + elem.toGenericString());
|
||||
}
|
||||
|
||||
|
||||
// Separate the methods and filer as:
|
||||
// XXX GetXxx(); & XXX != boolean
|
||||
// void setXxx(XXX elem);
|
||||
// [bB]oolean isXxx();
|
||||
|
||||
List<Method> methodsGet;
|
||||
List<Method> methodsSet;
|
||||
List<Method> methodsIs;
|
||||
if (!Enum.class.isAssignableFrom(classType)) {
|
||||
methodsGet = methods.stream().filter(o -> o.getName().startsWith("get")).collect(Collectors.toList());
|
||||
methodsSet = methods.stream().filter(o -> o.getName().startsWith("set")).collect(Collectors.toList());
|
||||
methodsIs = methods.stream().filter(o -> o.getName().startsWith("is")).collect(Collectors.toList());
|
||||
} else {
|
||||
methodsGet = new ArrayList<>();
|
||||
methodsSet = new ArrayList<>();
|
||||
methodsIs = new ArrayList<>();
|
||||
}
|
||||
final List<Method> valueOfString = methods.stream().filter(o -> o.getName().startsWith("valueOf")).collect(Collectors.toList());
|
||||
if (valueOfString.size() == 1) {
|
||||
this.valueof = valueOfString.get(0);
|
||||
} else {
|
||||
// some specific model:
|
||||
|
||||
this.valueof = null;
|
||||
}
|
||||
// associate methods by pair.
|
||||
final List<OrderData> elements = new ArrayList<>();
|
||||
for (final Method method : methodsGet) {
|
||||
final String name = method.getName().substring(3);
|
||||
final OrderData tmp = new OrderData(name);
|
||||
tmp.getter = method;
|
||||
elements.add(tmp);
|
||||
}
|
||||
for (final Method method : methodsIs) {
|
||||
final String name = method.getName().substring(2);
|
||||
for (final OrderData elem : elements) {
|
||||
if (elem.name.contentEquals(name)) {
|
||||
Log.error("Can not have a setXXX and isXXX with the same name ... " + method.getName());
|
||||
throw new Exception("lmkjlkjlk");
|
||||
}
|
||||
|
||||
// Separate the methods and filer as:
|
||||
// XXX GetXxx(); & XXX != boolean
|
||||
// void setXxx(XXX elem);
|
||||
// [bB]oolean isXxx();
|
||||
|
||||
List<Method> methodsGet;
|
||||
List<Method> methodsSet;
|
||||
List<Method> methodsIs;
|
||||
if (!Enum.class.isAssignableFrom(classType)) {
|
||||
methodsGet = methods.stream().filter(o -> o.getName().startsWith("get")).collect(Collectors.toList());
|
||||
methodsSet = methods.stream().filter(o -> o.getName().startsWith("set")).collect(Collectors.toList());
|
||||
methodsIs = methods.stream().filter(o -> o.getName().startsWith("is")).collect(Collectors.toList());
|
||||
} else {
|
||||
methodsGet = new ArrayList<>();
|
||||
methodsSet = new ArrayList<>();
|
||||
methodsIs = new ArrayList<>();
|
||||
}
|
||||
final OrderData tmp = new OrderData(name);
|
||||
tmp.getter = method;
|
||||
elements.add(tmp);
|
||||
}
|
||||
for (final Method method : methodsSet) {
|
||||
final String name = method.getName().substring(3);
|
||||
OrderData tmp = null;
|
||||
for (final OrderData elem : elements) {
|
||||
if (elem.name.contentEquals(name)) {
|
||||
tmp = elem;
|
||||
break;
|
||||
}
|
||||
final List<Method> valueOfString = methods.stream().filter(o -> o.getName().startsWith("valueOf")).collect(Collectors.toList());
|
||||
if (valueOfString.size() == 1) {
|
||||
this.valueof = valueOfString.get(0);
|
||||
} else {
|
||||
// some specific model:
|
||||
|
||||
this.valueof = null;
|
||||
}
|
||||
/*
|
||||
Class<?> internalModelClass = null;
|
||||
Class<?>[] tmppp = method.getParameterTypes();
|
||||
if (tmppp.length > 0 && (List.class.isAssignableFrom(tmppp[0]))) {
|
||||
Log.warning(" * " + method.getName());
|
||||
Type[] empppe = method.getGenericParameterTypes();
|
||||
if (empppe.length > 0) {
|
||||
if (empppe[0] instanceof ParameterizedType plopppppp) {
|
||||
Type[] realType = plopppppp.getActualTypeArguments();
|
||||
if (realType.length > 0) {
|
||||
Log.warning(" -->> " + realType[0]);
|
||||
internalModelClass = Class.forName(realType[0].getTypeName());
|
||||
}
|
||||
// associate methods by pair.
|
||||
final List<OrderData> elements = new ArrayList<>();
|
||||
for (final Method method : methodsGet) {
|
||||
final String name = method.getName().substring(3);
|
||||
final OrderData tmp = new OrderData(name);
|
||||
tmp.getter = method;
|
||||
elements.add(tmp);
|
||||
}
|
||||
for (final Method method : methodsIs) {
|
||||
final String name = method.getName().substring(2);
|
||||
for (final OrderData elem : elements) {
|
||||
if (elem.name.contentEquals(name)) {
|
||||
Log.error("Can not have a setXXX and isXXX with the same name ... " + method.getName());
|
||||
throw new Exception("lmkjlkjlk");
|
||||
}
|
||||
}
|
||||
for (int iii=0; iii<tmppp.length; iii++) {
|
||||
Log.warning(" -- " + tmppp[iii].getCanonicalName());
|
||||
}
|
||||
}
|
||||
*/
|
||||
if (tmp == null) {
|
||||
tmp = new OrderData(name);
|
||||
tmp.setter = method;
|
||||
final OrderData tmp = new OrderData(name);
|
||||
tmp.getter = method;
|
||||
elements.add(tmp);
|
||||
} else {
|
||||
tmp.setter = method;
|
||||
}
|
||||
}
|
||||
// Add it in the engine
|
||||
for (final OrderData elem : elements) {
|
||||
Log.info("find methode : '" + elem.name + "' :");
|
||||
if (elem.setter != null && elem.getter != null) {
|
||||
Log.info(" setter: " + elem.setter.toGenericString());
|
||||
Log.info(" getter: " + elem.getter.toGenericString());
|
||||
final Boolean isManagedSet = getIsManaged(elem.setter, null);
|
||||
final Boolean isManagedGet = getIsManaged(elem.getter, null);
|
||||
if (isManagedSet != null && isManagedGet != null && isManagedSet != isManagedGet) {
|
||||
throw new Exception("Can net set oposite information on getter and setter");
|
||||
for (final Method method : methodsSet) {
|
||||
final String name = method.getName().substring(3);
|
||||
OrderData tmp = null;
|
||||
for (final OrderData elem : elements) {
|
||||
if (elem.name.contentEquals(name)) {
|
||||
tmp = elem;
|
||||
break;
|
||||
}
|
||||
}
|
||||
final Boolean isManaged = isManagedSet != null ? isManagedSet : isManagedGet != null ? isManagedGet : isDefaultManaged;
|
||||
|
||||
final Boolean isOptionnalSet = getIsOptional(elem.setter, null);
|
||||
final Boolean isOptionnalGet = getIsOptional(elem.getter, null);
|
||||
if (isOptionnalSet != null && isOptionnalGet != null && isOptionnalSet != isOptionnalGet) {
|
||||
throw new Exception("Can net set oposite information on getter and setter");
|
||||
/*
|
||||
Class<?> internalModelClass = null;
|
||||
Class<?>[] tmppp = method.getParameterTypes();
|
||||
if (tmppp.length > 0 && (List.class.isAssignableFrom(tmppp[0]))) {
|
||||
Log.warning(" * " + method.getName());
|
||||
Type[] empppe = method.getGenericParameterTypes();
|
||||
if (empppe.length > 0) {
|
||||
if (empppe[0] instanceof ParameterizedType plopppppp) {
|
||||
Type[] realType = plopppppp.getActualTypeArguments();
|
||||
if (realType.length > 0) {
|
||||
Log.warning(" -->> " + realType[0]);
|
||||
internalModelClass = Class.forName(realType[0].getTypeName());
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int iii=0; iii<tmppp.length; iii++) {
|
||||
Log.warning(" -- " + tmppp[iii].getCanonicalName());
|
||||
}
|
||||
}
|
||||
final Boolean isOptional = isOptionnalSet != null ? isOptionnalSet : isOptionnalGet != null ? isOptionnalGet : isDefaultOptional;
|
||||
|
||||
final Boolean caseSensitiveSet = getIsCaseSensitive(elem.setter, null);
|
||||
final Boolean caseSensitiveGet = getIsCaseSensitive(elem.getter, null);
|
||||
if (caseSensitiveSet != null && caseSensitiveGet != null && caseSensitiveSet != caseSensitiveGet) {
|
||||
throw new Exception("Can net set oposite information on getter and setter");
|
||||
*/
|
||||
if (tmp == null) {
|
||||
tmp = new OrderData(name);
|
||||
tmp.setter = method;
|
||||
elements.add(tmp);
|
||||
} else {
|
||||
tmp.setter = method;
|
||||
}
|
||||
|
||||
final Boolean isCaseSensitive = caseSensitiveSet != null ? caseSensitiveSet : caseSensitiveGet != null ? caseSensitiveGet : isDefaultCaseSensitive;
|
||||
|
||||
final String[] namesSet = getNames(elem.setter, null);
|
||||
final String[] namesGet = getNames(elem.getter, null);
|
||||
if (namesSet != null && namesGet != null && namesSet.equals(namesGet)) {
|
||||
throw new Exception("Can net set oposite information on getter and setter");
|
||||
}
|
||||
final String[] names = namesSet != null ? namesSet : namesGet != null ? namesGet : new String[] { Tools.decapitalizeFirst(elem.name) };
|
||||
final String listNameSet = getListName(elem.setter, null);
|
||||
final String listNameGet = getListName(elem.getter, null);
|
||||
final String listName = listNameSet != null? listNameSet: listNameGet;
|
||||
this.methods.add(new IntrospectionPropertyMethod(elem.setter, elem.getter, names, listName, isCaseSensitive, isOptional));
|
||||
} else {
|
||||
Boolean isManaged = null;
|
||||
Boolean isOptionnal = null;
|
||||
String[] names = null;
|
||||
Boolean isCaseSensitive = null;
|
||||
String listName = null;
|
||||
if (elem.setter != null) {
|
||||
}
|
||||
// Add it in the engine
|
||||
for (final OrderData elem : elements) {
|
||||
Log.info("find methode : '" + elem.name + "' :");
|
||||
if (elem.setter != null && elem.getter != null) {
|
||||
Log.info(" setter: " + elem.setter.toGenericString());
|
||||
isManaged = getIsManaged(elem.setter, isDefaultManaged);
|
||||
isOptionnal = getIsOptional(elem.setter, isDefaultOptional);
|
||||
names = getNames(elem.setter, Tools.decapitalizeFirst(elem.name));
|
||||
isCaseSensitive = getIsCaseSensitive(elem.setter, isDefaultCaseSensitive);
|
||||
listName= getListName(elem.setter, null);
|
||||
} else {
|
||||
Log.info(" setter: null");
|
||||
}
|
||||
if (elem.getter != null) {
|
||||
Log.info(" getter: " + elem.getter.toGenericString());
|
||||
isManaged = getIsManaged(elem.getter, isDefaultManaged);
|
||||
isOptionnal = getIsOptional(elem.getter, isDefaultOptional);
|
||||
names = getNames(elem.getter, Tools.decapitalizeFirst(elem.name));
|
||||
isCaseSensitive = getIsCaseSensitive(elem.getter, isDefaultCaseSensitive);
|
||||
listName= getListName(elem.getter, null);
|
||||
final Boolean isManagedSet = getIsManaged(elem.setter, null);
|
||||
final Boolean isManagedGet = getIsManaged(elem.getter, null);
|
||||
if (isManagedSet != null && isManagedGet != null && isManagedSet != isManagedGet) {
|
||||
throw new Exception("Can net set oposite information on getter and setter");
|
||||
}
|
||||
final Boolean isManaged = isManagedSet != null ? isManagedSet : isManagedGet != null ? isManagedGet : isDefaultManaged;
|
||||
|
||||
final Boolean isOptionnalSet = getIsOptional(elem.setter, null);
|
||||
final Boolean isOptionnalGet = getIsOptional(elem.getter, null);
|
||||
if (isOptionnalSet != null && isOptionnalGet != null && isOptionnalSet != isOptionnalGet) {
|
||||
throw new Exception("Can net set oposite information on getter and setter");
|
||||
}
|
||||
final Boolean isOptional = isOptionnalSet != null ? isOptionnalSet : isOptionnalGet != null ? isOptionnalGet : isDefaultOptional;
|
||||
|
||||
final Boolean caseSensitiveSet = getIsCaseSensitive(elem.setter, null);
|
||||
final Boolean caseSensitiveGet = getIsCaseSensitive(elem.getter, null);
|
||||
if (caseSensitiveSet != null && caseSensitiveGet != null && caseSensitiveSet != caseSensitiveGet) {
|
||||
throw new Exception("Can net set oposite information on getter and setter");
|
||||
}
|
||||
|
||||
final Boolean isCaseSensitive = caseSensitiveSet != null ? caseSensitiveSet : caseSensitiveGet != null ? caseSensitiveGet : isDefaultCaseSensitive;
|
||||
|
||||
final String[] namesSet = getNames(elem.setter, null);
|
||||
final String[] namesGet = getNames(elem.getter, null);
|
||||
if (namesSet != null && namesGet != null && namesSet.equals(namesGet)) {
|
||||
throw new Exception("Can net set oposite information on getter and setter");
|
||||
}
|
||||
final String[] names = namesSet != null ? namesSet : namesGet != null ? namesGet : new String[] { Tools.decapitalizeFirst(elem.name) };
|
||||
final String listNameSet = getListName(elem.setter, null);
|
||||
final String listNameGet = getListName(elem.getter, null);
|
||||
final String listName = listNameSet != null? listNameSet: listNameGet;
|
||||
this.methods.add(new IntrospectionPropertyMethod(elem.setter, elem.getter, names, listName, isCaseSensitive, isOptional));
|
||||
} else {
|
||||
Log.info(" getter: null");
|
||||
}
|
||||
if (isManaged) {
|
||||
this.methods.add(new IntrospectionPropertyMethod(elem.setter, elem.getter, names, listName, isCaseSensitive, isOptionnal));
|
||||
Boolean isManaged = null;
|
||||
Boolean isOptionnal = null;
|
||||
String[] names = null;
|
||||
Boolean isCaseSensitive = null;
|
||||
String listName = null;
|
||||
if (elem.setter != null) {
|
||||
Log.info(" setter: " + elem.setter.toGenericString());
|
||||
isManaged = getIsManaged(elem.setter, isDefaultManaged);
|
||||
isOptionnal = getIsOptional(elem.setter, isDefaultOptional);
|
||||
names = getNames(elem.setter, Tools.decapitalizeFirst(elem.name));
|
||||
isCaseSensitive = getIsCaseSensitive(elem.setter, isDefaultCaseSensitive);
|
||||
listName= getListName(elem.setter, null);
|
||||
} else {
|
||||
Log.info(" setter: null");
|
||||
}
|
||||
if (elem.getter != null) {
|
||||
Log.info(" getter: " + elem.getter.toGenericString());
|
||||
isManaged = getIsManaged(elem.getter, isDefaultManaged);
|
||||
isOptionnal = getIsOptional(elem.getter, isDefaultOptional);
|
||||
names = getNames(elem.getter, Tools.decapitalizeFirst(elem.name));
|
||||
isCaseSensitive = getIsCaseSensitive(elem.getter, isDefaultCaseSensitive);
|
||||
listName= getListName(elem.getter, null);
|
||||
} else {
|
||||
Log.info(" getter: null");
|
||||
}
|
||||
if (isManaged) {
|
||||
this.methods.add(new IntrospectionPropertyMethod(elem.setter, elem.getter, names, listName, isCaseSensitive, isOptionnal));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
throw new ExmlBuilderException("Error in creating introspection data ... " + ex.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Object createObject(final Map<String, Object> properties, final Map<String, List<Object>> nodes) throws ExmlBuilderException {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.atriasoft.exml.builder;
|
||||
|
||||
import org.atriasoft.exml.exception.ExmlBuilderException;
|
||||
import org.atriasoft.exml.parser.Tools;
|
||||
|
||||
public abstract class IntrospectionProperty {
|
||||
protected final Boolean caseSensitive;
|
||||
@ -40,8 +41,68 @@ public abstract class IntrospectionProperty {
|
||||
public Class<?> getSubType() {
|
||||
return this.subType;
|
||||
}
|
||||
|
||||
public abstract String getValue(Object object) throws ExmlBuilderException;
|
||||
|
||||
public String getValueString(final Object object) throws ExmlBuilderException {
|
||||
Object value = getValue(object);
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
if (this.type == byte.class) {
|
||||
return Byte.toString((byte)value);
|
||||
}
|
||||
if (this.type == short.class) {
|
||||
return Short.toString((short)value);
|
||||
}
|
||||
if (this.type == int.class) {
|
||||
return Integer.toString((int)value);
|
||||
}
|
||||
if (this.type == long.class) {
|
||||
return Long.toString((long)value);
|
||||
}
|
||||
if (this.type == boolean.class) {
|
||||
return Boolean.toString((boolean)value);
|
||||
}
|
||||
if (this.type == String.class) {
|
||||
return (String)value;
|
||||
}
|
||||
if (this.type == Byte.class) {
|
||||
return Byte.toString((Byte)value);
|
||||
}
|
||||
if (this.type == Short.class) {
|
||||
return Short.toString((short)value);
|
||||
}
|
||||
if (this.type == Integer.class) {
|
||||
return Integer.toString((Integer)value);
|
||||
} else if (this.type == Long.class) {
|
||||
return Long.toString((Long)value);
|
||||
} else if (this.type == Boolean.class) {
|
||||
return Boolean.toString((Boolean)value);
|
||||
} else if (this.type == byte[].class) {
|
||||
return Tools.toString((byte[])value);
|
||||
} else if (this.type == Byte[].class) {
|
||||
return Tools.toString((Byte[])value);
|
||||
} else if (this.type == short[].class) {
|
||||
return Tools.toString((short[])value);
|
||||
} else if (this.type == Short[].class) {
|
||||
return Tools.toString((Short[])value);
|
||||
} else if (this.type == int[].class) {
|
||||
return Tools.toString((int[])value);
|
||||
} else if (this.type == Integer[].class) {
|
||||
return Tools.toString((Integer[])value);
|
||||
} else if (this.type == long[].class) {
|
||||
return Tools.toString((long[])value);
|
||||
} else if (this.type == Long[].class) {
|
||||
return Tools.toString((Long[])value);
|
||||
} else if (this.type == boolean[].class) {
|
||||
return Tools.toString((boolean[])value);
|
||||
} else if (this.type == Boolean[].class) {
|
||||
return Tools.toString((Boolean[])value);
|
||||
} else {
|
||||
//throw new ExmlBuilderException("Can not parse the specific element ... need to introspect and find the 'xxx valueOf(String data);'");
|
||||
}
|
||||
return value.toString();
|
||||
}
|
||||
public abstract Object getValue(Object object) throws ExmlBuilderException;
|
||||
|
||||
public boolean isCaseSensitive() {
|
||||
return this.caseSensitive;
|
||||
|
@ -43,66 +43,10 @@ public class IntrospectionPropertyField extends IntrospectionProperty {
|
||||
public boolean canSetValue() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue(final Object object) throws ExmlBuilderException {
|
||||
public Object getValue(final Object object) throws ExmlBuilderException {
|
||||
try {
|
||||
Object value = this.fieldDescription.get(object);
|
||||
|
||||
if (this.type == byte.class) {
|
||||
return Byte.toString((byte)value);
|
||||
}
|
||||
if (this.type == short.class) {
|
||||
return Short.toString((short)value);
|
||||
}
|
||||
if (this.type == int.class) {
|
||||
return Integer.toString((int)value);
|
||||
}
|
||||
if (this.type == long.class) {
|
||||
return Long.toString((long)value);
|
||||
}
|
||||
if (this.type == boolean.class) {
|
||||
return Boolean.toString((boolean)value);
|
||||
}
|
||||
if (this.type == String.class) {
|
||||
return (String)value;
|
||||
}
|
||||
if (this.type == Byte.class) {
|
||||
return Byte.toString((Byte)value);
|
||||
}
|
||||
if (this.type == Short.class) {
|
||||
return Short.toString((short)value);
|
||||
}
|
||||
if (this.type == Integer.class) {
|
||||
return Integer.toString((Integer)value);
|
||||
} else if (this.type == Long.class) {
|
||||
return Long.toString((Long)value);
|
||||
} else if (this.type == Boolean.class) {
|
||||
return Boolean.toString((Boolean)value);
|
||||
} /* else if (this.type == byte[].class) {
|
||||
return Tools.parseByteStringList(value);
|
||||
} else if (this.type == Byte[].class) {
|
||||
return Tools.parseByteClassStringList(value);
|
||||
} else if (this.type == short[].class) {
|
||||
return Tools.parseShortStringList(value);
|
||||
} else if (this.type == Short[].class) {
|
||||
return Tools.parseShortClassStringList(value);
|
||||
} else if (this.type == int[].class) {
|
||||
return Tools.parseIntegerStringList(value);
|
||||
} else if (this.type == Integer[].class) {
|
||||
return Tools.parseIntegerClassStringList(value);
|
||||
} else if (this.type == long[].class) {
|
||||
return Tools.parseLongStringList(value);
|
||||
} else if (this.type == Long[].class) {
|
||||
return Tools.parseLongClassStringList(value);
|
||||
} else if (this.type == boolean[].class) {
|
||||
return Tools.parseBooleanStringList(value);
|
||||
} else if (this.type == Boolean[].class) {
|
||||
return Tools.parseBooleanClassStringList(value);
|
||||
} */else {
|
||||
//throw new ExmlBuilderException("Can not parse the specific element ... need to introspect and find the 'xxx valueOf(String data);'");
|
||||
}
|
||||
return value.toString();
|
||||
return this.fieldDescription.get(object);
|
||||
} catch (IllegalArgumentException | IllegalAccessException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
|
@ -79,12 +79,16 @@ public class IntrospectionPropertyMethod extends IntrospectionProperty {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue(final Object object) throws ExmlBuilderException {
|
||||
public Object getValue(final Object object) throws ExmlBuilderException {
|
||||
if (this.getter == null) {
|
||||
throw new ExmlBuilderException("no getter availlable");
|
||||
}
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
try {
|
||||
return this.getter.invoke(object);
|
||||
} catch (InvocationTargetException | IllegalAccessException | IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
throw new ExmlBuilderException("Can not set value ... " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -6,6 +6,8 @@ import java.util.Map;
|
||||
|
||||
import org.atriasoft.exml.builder.IntrospectionData;
|
||||
import org.atriasoft.exml.builder.IntrospectionProperty;
|
||||
import org.atriasoft.exml.exception.ExmlBuilderException;
|
||||
import org.atriasoft.exml.parser.Tools;
|
||||
|
||||
public class GeneratorIntrospection implements Generator {
|
||||
// Keep in cach all the object alredy parsed ==> optimize CPU
|
||||
@ -20,7 +22,7 @@ public class GeneratorIntrospection implements Generator {
|
||||
this.elements.put(classType, new IntrospectionData(classType, null));
|
||||
}
|
||||
|
||||
IntrospectionData findOrCreate(final Class<?> classType) throws Exception {
|
||||
IntrospectionData findOrCreate(final Class<?> classType) throws ExmlBuilderException {
|
||||
IntrospectionData out = this.elements.get(classType);
|
||||
if (out != null) {
|
||||
return out;
|
||||
@ -30,40 +32,54 @@ public class GeneratorIntrospection implements Generator {
|
||||
return out;
|
||||
}
|
||||
|
||||
public void generateProperties(final Object node, final IntrospectionData introspection, final StringBuilder tmpp) throws Exception {
|
||||
public void generateProperties(final Object data, final IntrospectionData introspection, final StringBuilder tmpp) throws ExmlBuilderException {
|
||||
List<IntrospectionProperty> elements = introspection.getProperties();
|
||||
for (IntrospectionProperty elem : elements) {
|
||||
if (!elem.canGetValue()) {
|
||||
continue;
|
||||
}
|
||||
String name = elem.getNames()[0];
|
||||
String data=elem.getValue(node);
|
||||
String dataString=elem.getValueString(data);
|
||||
tmpp.append(" ");
|
||||
tmpp.append(name);
|
||||
tmpp.append("=\"");
|
||||
tmpp.append(data);
|
||||
tmpp.append(dataString);
|
||||
tmpp.append("\"");
|
||||
}
|
||||
}
|
||||
public void generateSubNodes(final Object node, final IntrospectionData introspection, final StringBuilder tmpp) {
|
||||
public void generateSubNodes(final Object data, final IntrospectionData introspection, final StringBuilder tmpp, int indent) throws ExmlBuilderException {
|
||||
List<IntrospectionProperty> elements = introspection.getMethods();
|
||||
for (IntrospectionProperty elem : elements) {
|
||||
if (!elem.canGetValue()) {
|
||||
continue;
|
||||
}
|
||||
String name = elem.getNames()[0];
|
||||
|
||||
Object dataObj =elem.getValue(data);
|
||||
|
||||
if (dataObj != null) {
|
||||
generateNode(dataObj, name, tmpp, indent);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void generateNode(final Object node, final String nodeName, final StringBuilder tmpp) throws Exception {
|
||||
IntrospectionData introspection = findOrCreate(node.getClass());
|
||||
public void generateNode(final Object data, final String nodeName, final StringBuilder tmpp, int indent) throws ExmlBuilderException {
|
||||
IntrospectionData introspection = findOrCreate(data.getClass());
|
||||
Tools.addIndent(tmpp, indent);
|
||||
tmpp.append("<");
|
||||
tmpp.append(nodeName);
|
||||
generateProperties(node, introspection, tmpp);
|
||||
tmpp.append(">\n");
|
||||
generateSubNodes(node, introspection, tmpp);
|
||||
tmpp.append("</");
|
||||
tmpp.append(nodeName);
|
||||
tmpp.append(">\n");
|
||||
|
||||
generateProperties(data, introspection, tmpp);
|
||||
if (introspection.getMethods().size() != 0) {
|
||||
tmpp.append(">\n");
|
||||
generateSubNodes(data, introspection, tmpp, indent + 1);
|
||||
Tools.addIndent(tmpp, indent);
|
||||
tmpp.append("</");
|
||||
tmpp.append(nodeName);
|
||||
tmpp.append(">\n");
|
||||
} else {
|
||||
tmpp.append("/>\n");
|
||||
}
|
||||
}
|
||||
public void generate(final Object root, final StringBuilder tmpp) throws Exception {
|
||||
generateNode(root, this.rootNodeName, tmpp);
|
||||
public void generate(final Object root, final StringBuilder tmpp) throws ExmlBuilderException {
|
||||
generateNode(root, this.rootNodeName, tmpp, 0);
|
||||
}
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ public class Tools {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Boolean[] parseBooleanClassStringList(String data) { // throws NumberFormatException
|
||||
public static Boolean[] parseBooleanClassStringList(String data) {
|
||||
data = Tools.cleanNumberList(data);
|
||||
final String[] dataArray = data.split(";");
|
||||
final Boolean[] out = new Boolean[dataArray.length];
|
||||
@ -159,8 +159,18 @@ public class Tools {
|
||||
}
|
||||
return out;
|
||||
}
|
||||
public static String toString(Boolean[] data) {
|
||||
StringBuilder out = new StringBuilder();
|
||||
for (int iii=0; iii<data.length; iii++) {
|
||||
if (iii != 0) {
|
||||
out.append(";");
|
||||
}
|
||||
out.append(data[iii]);
|
||||
}
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
public static boolean[] parseBooleanStringList(String data) { // throws NumberFormatException
|
||||
public static boolean[] parseBooleanStringList(String data) {
|
||||
data = Tools.cleanNumberList(data);
|
||||
final String[] dataArray = data.split(";");
|
||||
final boolean[] out = new boolean[dataArray.length];
|
||||
@ -170,8 +180,18 @@ public class Tools {
|
||||
}
|
||||
return out;
|
||||
}
|
||||
public static String toString(boolean[] data) {
|
||||
StringBuilder out = new StringBuilder();
|
||||
for (int iii=0; iii<data.length; iii++) {
|
||||
if (iii != 0) {
|
||||
out.append(";");
|
||||
}
|
||||
out.append(data[iii]);
|
||||
}
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
public static Byte[] parseByteClassStringList(String data) { // throws NumberFormatException
|
||||
public static Byte[] parseByteClassStringList(String data) {
|
||||
data = Tools.cleanNumberList(data);
|
||||
final String[] dataArray = data.split(";");
|
||||
final Byte[] out = new Byte[dataArray.length];
|
||||
@ -181,8 +201,19 @@ public class Tools {
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
public static String toString(Byte[] data) {
|
||||
StringBuilder out = new StringBuilder();
|
||||
for (int iii=0; iii<data.length; iii++) {
|
||||
if (iii != 0) {
|
||||
out.append(";");
|
||||
}
|
||||
out.append(data[iii]);
|
||||
}
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
public static byte[] parseByteStringList(String data) { // throws NumberFormatException
|
||||
public static byte[] parseByteStringList(String data) {
|
||||
data = Tools.cleanNumberList(data);
|
||||
final String[] dataArray = data.split(";");
|
||||
final byte[] out = new byte[dataArray.length];
|
||||
@ -192,8 +223,18 @@ public class Tools {
|
||||
}
|
||||
return out;
|
||||
}
|
||||
public static String toString(byte[] data) {
|
||||
StringBuilder out = new StringBuilder();
|
||||
for (int iii=0; iii<data.length; iii++) {
|
||||
if (iii != 0) {
|
||||
out.append(";");
|
||||
}
|
||||
out.append(data[iii]);
|
||||
}
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
public static Integer[] parseIntegerClassStringList(String data) { // throws NumberFormatException
|
||||
public static Integer[] parseIntegerClassStringList(String data) {
|
||||
data = Tools.cleanNumberList(data);
|
||||
final String[] dataArray = data.split(";");
|
||||
final Integer[] out = new Integer[dataArray.length];
|
||||
@ -203,8 +244,18 @@ public class Tools {
|
||||
}
|
||||
return out;
|
||||
}
|
||||
public static String toString(Integer[] data) {
|
||||
StringBuilder out = new StringBuilder();
|
||||
for (int iii=0; iii<data.length; iii++) {
|
||||
if (iii != 0) {
|
||||
out.append(";");
|
||||
}
|
||||
out.append(data[iii]);
|
||||
}
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
public static int[] parseIntegerStringList(String data) { // throws NumberFormatException
|
||||
public static int[] parseIntegerStringList(String data) {
|
||||
data = Tools.cleanNumberList(data);
|
||||
final String[] dataArray = data.split(";");
|
||||
final int[] out = new int[dataArray.length];
|
||||
@ -214,8 +265,18 @@ public class Tools {
|
||||
}
|
||||
return out;
|
||||
}
|
||||
public static String toString(int[] data) {
|
||||
StringBuilder out = new StringBuilder();
|
||||
for (int iii=0; iii<data.length; iii++) {
|
||||
if (iii != 0) {
|
||||
out.append(";");
|
||||
}
|
||||
out.append(data[iii]);
|
||||
}
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
public static Long[] parseLongClassStringList(String data) { // throws NumberFormatException
|
||||
public static Long[] parseLongClassStringList(String data) {
|
||||
data = Tools.cleanNumberList(data);
|
||||
final String[] dataArray = data.split(";");
|
||||
final Long[] out = new Long[dataArray.length];
|
||||
@ -225,8 +286,18 @@ public class Tools {
|
||||
}
|
||||
return out;
|
||||
}
|
||||
public static String toString(Long[] data) {
|
||||
StringBuilder out = new StringBuilder();
|
||||
for (int iii=0; iii<data.length; iii++) {
|
||||
if (iii != 0) {
|
||||
out.append(";");
|
||||
}
|
||||
out.append(data[iii]);
|
||||
}
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
public static long[] parseLongStringList(String data) { // throws NumberFormatException
|
||||
public static long[] parseLongStringList(String data) {
|
||||
data = Tools.cleanNumberList(data);
|
||||
final String[] dataArray = data.split(";");
|
||||
final long[] out = new long[dataArray.length];
|
||||
@ -236,8 +307,18 @@ public class Tools {
|
||||
}
|
||||
return out;
|
||||
}
|
||||
public static String toString(long[] data) {
|
||||
StringBuilder out = new StringBuilder();
|
||||
for (int iii=0; iii<data.length; iii++) {
|
||||
if (iii != 0) {
|
||||
out.append(";");
|
||||
}
|
||||
out.append(data[iii]);
|
||||
}
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
public static Short[] parseShortClassStringList(String data) { // throws NumberFormatException
|
||||
public static Short[] parseShortClassStringList(String data) {
|
||||
data = Tools.cleanNumberList(data);
|
||||
final String[] dataArray = data.split(";");
|
||||
final Short[] out = new Short[dataArray.length];
|
||||
@ -247,8 +328,19 @@ public class Tools {
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
public static String toString(Short[] data) {
|
||||
StringBuilder out = new StringBuilder();
|
||||
for (int iii=0; iii<data.length; iii++) {
|
||||
if (iii != 0) {
|
||||
out.append(";");
|
||||
}
|
||||
out.append(data[iii]);
|
||||
}
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
public static short[] parseShortStringList(String data) { // throws NumberFormatException
|
||||
public static short[] parseShortStringList(String data) {
|
||||
data = Tools.cleanNumberList(data);
|
||||
final String[] dataArray = data.split(";");
|
||||
final short[] out = new short[dataArray.length];
|
||||
@ -258,6 +350,16 @@ public class Tools {
|
||||
}
|
||||
return out;
|
||||
}
|
||||
public static String toString(short[] data) {
|
||||
StringBuilder out = new StringBuilder();
|
||||
for (int iii=0; iii<data.length; iii++) {
|
||||
if (iii != 0) {
|
||||
out.append(";");
|
||||
}
|
||||
out.append(data[iii]);
|
||||
}
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
// transform the Text with :
|
||||
// "<" == "<"
|
||||
|
@ -13,13 +13,15 @@ import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import test.atriasoft.exml.introspection.ClassPublicMemberOnly;
|
||||
import test.atriasoft.exml.introspection.ClassPublicMethodOnly;
|
||||
import test.atriasoft.exml.introspection.ClassPublicMethodeNode;
|
||||
|
||||
public class ExmlTestIntrospectionGenerate {
|
||||
@BeforeAll
|
||||
public static void beforeClass() {
|
||||
Log.verbose("----------------------------------------------------------------");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void test1() throws ExmlParserErrorMulti, ExmlBuilderException {
|
||||
ClassPublicMemberOnly elem = new ClassPublicMemberOnly();
|
||||
@ -50,5 +52,66 @@ public class ExmlTestIntrospectionGenerate {
|
||||
Log.warning("data generated: " + builder.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test2() throws ExmlParserErrorMulti, ExmlBuilderException {
|
||||
ClassPublicMethodOnly elem = new ClassPublicMethodOnly();
|
||||
elem.setMemberArrayBoolean ( new boolean[] {false, true});
|
||||
elem.setMemberArrayBooleanClass ( new Boolean[] {false, true, true});
|
||||
elem.setMemberArrayByte ( new byte[] {21,21,58});
|
||||
elem.setMemberArrayByteClass ( new Byte[] {54,21,65,32});
|
||||
elem.setMemberArrayInteger ( new int[] { 1521,2151,2156,216354});
|
||||
elem.setMemberArrayIntegerClass ( new Integer[] {5564,6546321,654564,231321,54654});
|
||||
elem.setMemberArrayLong ( new long[] {6546544L,654654651L,5646546541L,5465465163L} );
|
||||
elem.setMemberArrayLongClass ( new Long[] {561651L, 6541321L, 651351L});
|
||||
elem.setMemberArrayShort ( new short[] {4564, -54,-564});
|
||||
elem.setMemberArrayShortClass ( new Short[] {-54, 5646, -8465, 852});
|
||||
elem.setMemberBoolean ( false);
|
||||
elem.setMemberBooleanClass ( true);
|
||||
elem.setMemberByte ( (byte)12);
|
||||
elem.setMemberByteClass ( (byte)54);
|
||||
elem.setMemberInteger ( 6543524);
|
||||
elem.setMemberIntegerClass ( 545666);
|
||||
elem.setMemberLong ( 400000055L);
|
||||
elem.setMemberLongClass ( 54654546L);
|
||||
elem.setMemberShort ( (short)31252);
|
||||
elem.setMemberShortClass ((short)-25212);
|
||||
elem.setMemberStringClass ("lkjhlkjlkjlkj");
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
Exml.generate(elem, "elem", builder);
|
||||
Log.warning("data generated: " + builder.toString());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void test3() throws ExmlParserErrorMulti, ExmlBuilderException {
|
||||
ClassPublicMethodeNode elem = new ClassPublicMethodeNode();
|
||||
elem.setMemberArrayBoolean ( new boolean[] {false, true});
|
||||
elem.setMemberArrayBooleanClass ( new Boolean[] {false, true, true});
|
||||
elem.setMemberArrayByte ( new byte[] {21,21,58});
|
||||
elem.setMemberArrayByteClass ( new Byte[] {54,21,65,32});
|
||||
elem.setMemberArrayInteger ( new int[] { 1521,2151,2156,216354});
|
||||
elem.setMemberArrayIntegerClass ( new Integer[] {5564,6546321,654564,231321,54654});
|
||||
elem.setMemberArrayLong ( new long[] {6546544L,654654651L,5646546541L,5465465163L} );
|
||||
elem.setMemberArrayLongClass ( new Long[] {561651L, 6541321L, 651351L});
|
||||
elem.setMemberArrayShort ( new short[] {4564, -54,-564});
|
||||
elem.setMemberArrayShortClass ( new Short[] {-54, 5646, -8465, 852});
|
||||
elem.setMemberBoolean ( false);
|
||||
elem.setMemberBooleanClass ( true);
|
||||
elem.setMemberByte ( (byte)12);
|
||||
elem.setMemberByteClass ( (byte)54);
|
||||
elem.setMemberInteger ( 6543524);
|
||||
elem.setMemberIntegerClass ( 545666);
|
||||
elem.setMemberLong ( 400000055L);
|
||||
elem.setMemberLongClass ( 54654546L);
|
||||
elem.setMemberShort ( (short)31252);
|
||||
elem.setMemberShortClass ((short)-25212);
|
||||
elem.setMemberStringClass ("lkjhlkjlkjlkj");
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
Exml.generate(elem, "elem", builder);
|
||||
Log.warning("data generated: " + builder.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user