[DEV] start full test of decorators...
This commit is contained in:
parent
a2d37bb241
commit
1b69ba649a
@ -19,6 +19,7 @@ import org.atriasoft.exml.builder.BuilderIntrospection;
|
|||||||
import org.atriasoft.exml.builder.IntrospectionObject;
|
import org.atriasoft.exml.builder.IntrospectionObject;
|
||||||
import org.atriasoft.exml.builder.ModelType;
|
import org.atriasoft.exml.builder.ModelType;
|
||||||
import org.atriasoft.exml.exception.ExmlBuilderException;
|
import org.atriasoft.exml.exception.ExmlBuilderException;
|
||||||
|
import org.atriasoft.exml.exception.ExmlException;
|
||||||
import org.atriasoft.exml.exception.ExmlParserErrorMulti;
|
import org.atriasoft.exml.exception.ExmlParserErrorMulti;
|
||||||
import org.atriasoft.exml.generator.GeneratorIntrospection;
|
import org.atriasoft.exml.generator.GeneratorIntrospection;
|
||||||
import org.atriasoft.exml.internal.Log;
|
import org.atriasoft.exml.internal.Log;
|
||||||
@ -38,7 +39,7 @@ public class Exml {
|
|||||||
Log.info("Generated XML : \n" + tmpp.toString());
|
Log.info("Generated XML : \n" + tmpp.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void generate(final Object root, final String rootNodeName, final StringBuilder data) throws ExmlBuilderException {
|
public static void generate(final Object root, final String rootNodeName, final StringBuilder data) throws ExmlException {
|
||||||
GeneratorIntrospection generator;
|
GeneratorIntrospection generator;
|
||||||
try {
|
try {
|
||||||
generator = new GeneratorIntrospection(ModelType.NORMAL, root.getClass(), rootNodeName);
|
generator = new GeneratorIntrospection(ModelType.NORMAL, root.getClass(), rootNodeName);
|
||||||
@ -72,7 +73,7 @@ public class Exml {
|
|||||||
// return iGenerate(_data, 0);
|
// return iGenerate(_data, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static XmlElement parse(final String data) throws ExmlBuilderException, ExmlParserErrorMulti {
|
public static XmlElement parse(final String data) throws ExmlException, ExmlParserErrorMulti {
|
||||||
final Builder builder = new BuilderGeneric();
|
final Builder builder = new BuilderGeneric();
|
||||||
final ParseXml parser = new ParseXml(builder);
|
final ParseXml parser = new ParseXml(builder);
|
||||||
final ParsingProperty property = new ParsingProperty();
|
final ParsingProperty property = new ParsingProperty();
|
||||||
@ -82,7 +83,7 @@ public class Exml {
|
|||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T> T[] parse(final String data, final Class<T> classType, final String rootNodeName) throws ExmlBuilderException, ExmlParserErrorMulti {
|
public static <T> T[] parse(final String data, final Class<T> classType, final String rootNodeName) throws ExmlException, ExmlParserErrorMulti {
|
||||||
Builder builder;
|
Builder builder;
|
||||||
try {
|
try {
|
||||||
builder = new BuilderIntrospection(ModelType.ARRAY, classType, rootNodeName);
|
builder = new BuilderIntrospection(ModelType.ARRAY, classType, rootNodeName);
|
||||||
@ -97,17 +98,13 @@ public class Exml {
|
|||||||
return (T[]) listRet;
|
return (T[]) listRet;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
} catch (final ExmlBuilderException ex) {
|
} catch (final ExmlException ex) {
|
||||||
ex.printStackTrace();
|
//ex.printStackTrace();
|
||||||
throw ex;
|
throw ex;
|
||||||
} catch (final Exception ex) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
ex.printStackTrace();
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T parseOne(final String data, final Class<T> classType, final String rootNodeName) throws ExmlBuilderException, ExmlParserErrorMulti {
|
public static <T> T parseOne(final String data, final Class<T> classType, final String rootNodeName) throws ExmlException, ExmlParserErrorMulti {
|
||||||
T[] elements = Exml.parse(data, classType, rootNodeName);
|
T[] elements = Exml.parse(data, classType, rootNodeName);
|
||||||
if (elements == null || elements.length == 0 ) {
|
if (elements == null || elements.length == 0 ) {
|
||||||
throw new ExmlBuilderException("Error in parsing the file, no node find ...");
|
throw new ExmlBuilderException("Error in parsing the file, no node find ...");
|
||||||
@ -124,7 +121,7 @@ public class Exml {
|
|||||||
return new String(encoded, encoding);
|
return new String(encoded, encoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T[] parse(final Path path, final Class<T> classType, final String rootNodeName) throws ExmlBuilderException, ExmlParserErrorMulti {
|
public static <T> T[] parse(final Path path, final Class<T> classType, final String rootNodeName) throws ExmlException, ExmlParserErrorMulti {
|
||||||
String content = null;
|
String content = null;
|
||||||
try {
|
try {
|
||||||
content = Exml.readFile(path, StandardCharsets.UTF_8);
|
content = Exml.readFile(path, StandardCharsets.UTF_8);
|
||||||
@ -133,7 +130,7 @@ public class Exml {
|
|||||||
}
|
}
|
||||||
return Exml.parse(content, classType, rootNodeName);
|
return Exml.parse(content, classType, rootNodeName);
|
||||||
}
|
}
|
||||||
public static <T> T parseOne(final Path path, final Class<T> classType, final String rootNodeName) throws ExmlBuilderException, ExmlParserErrorMulti {
|
public static <T> T parseOne(final Path path, final Class<T> classType, final String rootNodeName) throws ExmlException, ExmlParserErrorMulti {
|
||||||
T[] elements = Exml.parse(path, classType, rootNodeName);
|
T[] elements = Exml.parse(path, classType, rootNodeName);
|
||||||
if (elements == null || elements.length == 0 ) {
|
if (elements == null || elements.length == 0 ) {
|
||||||
throw new ExmlBuilderException("Error in parsing the file, no node find ...");
|
throw new ExmlBuilderException("Error in parsing the file, no node find ...");
|
||||||
@ -151,6 +148,7 @@ public class Exml {
|
|||||||
* @param _uri URI of the xml
|
* @param _uri URI of the xml
|
||||||
* @return false : An error occured
|
* @return false : An error occured
|
||||||
* @return true : Parsing is OK
|
* @return true : Parsing is OK
|
||||||
|
* @throws ExmlException
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* public boolean load( Uri _uri){ // Start loading the XML :
|
* public boolean load( Uri _uri){ // Start loading the XML :
|
||||||
@ -163,7 +161,7 @@ public class Exml {
|
|||||||
* parse(tmpDataUnicode); //Display(); return ret; }
|
* parse(tmpDataUnicode); //Display(); return ret; }
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static XmlElement parse(final Uri data) throws ExmlBuilderException, ExmlParserErrorMulti {
|
public static XmlElement parse(final Uri data) throws ExmlException {
|
||||||
final Builder builder = new BuilderGeneric();
|
final Builder builder = new BuilderGeneric();
|
||||||
final ParseXml parser = new ParseXml(builder);
|
final ParseXml parser = new ParseXml(builder);
|
||||||
final ParsingProperty property = new ParsingProperty();
|
final ParsingProperty property = new ParsingProperty();
|
||||||
@ -177,7 +175,7 @@ public class Exml {
|
|||||||
final String dataToParse = new String(elemData);
|
final String dataToParse = new String(elemData);
|
||||||
return (XmlElement) parser.parse(dataToParse, property);
|
return (XmlElement) parser.parse(dataToParse, property);
|
||||||
}
|
}
|
||||||
public static XmlElement parse(final Path data) throws ExmlBuilderException, ExmlParserErrorMulti {
|
public static XmlElement parse(final Path data) throws ExmlException, ExmlParserErrorMulti {
|
||||||
final Builder builder = new BuilderGeneric();
|
final Builder builder = new BuilderGeneric();
|
||||||
final ParseXml parser = new ParseXml(builder);
|
final ParseXml parser = new ParseXml(builder);
|
||||||
final ParsingProperty property = new ParsingProperty();
|
final ParsingProperty property = new ParsingProperty();
|
||||||
|
@ -9,7 +9,7 @@ import java.lang.annotation.Target;
|
|||||||
* Marker annotation that force the xml Parser to manage this element (used when the class is mark as @XmldefaultNotManaged).
|
* Marker annotation that force the xml Parser to manage this element (used when the class is mark as @XmldefaultNotManaged).
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Target({ ElementType.FIELD, ElementType.METHOD })
|
@Target({ ElementType.FIELD, ElementType.METHOD})
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@ExmlAnnotation
|
@ExmlAnnotation
|
||||||
public @interface XmlManaged {
|
public @interface XmlManaged {
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
package org.atriasoft.exml.builder;
|
package org.atriasoft.exml.builder;
|
||||||
|
|
||||||
import org.atriasoft.exml.exception.ExmlBuilderException;
|
import org.atriasoft.exml.exception.ExmlBuilderException;
|
||||||
|
import org.atriasoft.exml.exception.ExmlException;
|
||||||
|
|
||||||
public interface Builder {
|
public interface Builder {
|
||||||
|
|
||||||
@ -15,7 +16,7 @@ public interface Builder {
|
|||||||
* @param comment Comment value
|
* @param comment Comment value
|
||||||
* @throws ExmlBuilderException Error with this node or element.
|
* @throws ExmlBuilderException Error with this node or element.
|
||||||
*/
|
*/
|
||||||
void newComment(Object element, String comment) throws ExmlBuilderException;
|
void newComment(Object element, String comment) throws ExmlException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* New comment added on this Element
|
* New comment added on this Element
|
||||||
@ -24,7 +25,7 @@ public interface Builder {
|
|||||||
* @return Declaration object value
|
* @return Declaration object value
|
||||||
* @throws ExmlBuilderException Error with this node or element.
|
* @throws ExmlBuilderException Error with this node or element.
|
||||||
*/
|
*/
|
||||||
Object newDeclaration(Object parent, String text) throws ExmlBuilderException;
|
Object newDeclaration(Object parent, String text) throws ExmlException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new sub-element on the current parent element: {@code<ELEMENT>}
|
* Add a new sub-element on the current parent element: {@code<ELEMENT>}
|
||||||
@ -33,7 +34,7 @@ public interface Builder {
|
|||||||
* @return the object representing the Element.
|
* @return the object representing the Element.
|
||||||
* @throws ExmlBuilderException Error with this node or element.
|
* @throws ExmlBuilderException Error with this node or element.
|
||||||
*/
|
*/
|
||||||
Object newElement(Object parent, String nodeName) throws ExmlBuilderException, Exception;
|
Object newElement(Object parent, String nodeName) throws ExmlException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a property on the Element.
|
* Add a property on the Element.
|
||||||
@ -42,7 +43,7 @@ public interface Builder {
|
|||||||
* @param propertyValue Value of the property
|
* @param propertyValue Value of the property
|
||||||
* @throws ExmlBuilderException Error with this node or element.
|
* @throws ExmlBuilderException Error with this node or element.
|
||||||
*/
|
*/
|
||||||
void newProperty(Object element, String propertyName, String propertyValue) throws ExmlBuilderException, Exception;
|
void newProperty(Object element, String propertyName, String propertyValue) throws ExmlException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create or get the root element of the document
|
* Create or get the root element of the document
|
||||||
@ -57,14 +58,14 @@ public interface Builder {
|
|||||||
* @param text Test to add.
|
* @param text Test to add.
|
||||||
* @throws ExmlBuilderException Error with this node or element.
|
* @throws ExmlBuilderException Error with this node or element.
|
||||||
*/
|
*/
|
||||||
void newText(Object parent, String text) throws ExmlBuilderException;
|
void newText(Object parent, String text) throws ExmlException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detect the end of the element : {@code<ELEMENT>}
|
* Detect the end of the element : {@code<ELEMENT>}
|
||||||
* @param element Element that is finished
|
* @param element Element that is finished
|
||||||
* @throws ExmlBuilderException
|
* @throws ExmlBuilderException
|
||||||
*/
|
*/
|
||||||
void endElement(Object element) throws ExmlBuilderException;
|
void endElement(Object element) throws ExmlException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The sub-element is finish (creation done)
|
* The sub-element is finish (creation done)
|
||||||
@ -72,6 +73,6 @@ public interface Builder {
|
|||||||
* @param tmpname Name of the node
|
* @param tmpname Name of the node
|
||||||
* @param element Element builder that has been created
|
* @param element Element builder that has been created
|
||||||
*/
|
*/
|
||||||
void newElementFinished(Object parent, String tmpname, Object element);
|
void newElementFinished(Object parent, String tmpname, Object element) throws ExmlException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,10 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.atriasoft.eStringSerialize.StringSerializer;
|
import org.atriasoft.eStringSerialize.StringSerializer;
|
||||||
|
import org.atriasoft.exml.exception.ExmlAttributeDoesNotExist;
|
||||||
import org.atriasoft.exml.exception.ExmlBuilderException;
|
import org.atriasoft.exml.exception.ExmlBuilderException;
|
||||||
|
import org.atriasoft.exml.exception.ExmlException;
|
||||||
|
import org.atriasoft.exml.exception.ExmlNodeDoesNotExist;
|
||||||
import org.atriasoft.exml.internal.Log;
|
import org.atriasoft.exml.internal.Log;
|
||||||
|
|
||||||
public class BuilderIntrospection implements Builder {
|
public class BuilderIntrospection implements Builder {
|
||||||
@ -14,7 +17,7 @@ public class BuilderIntrospection implements Builder {
|
|||||||
final Class<?> rootClassType;
|
final Class<?> rootClassType;
|
||||||
final String rootNodeName;
|
final String rootNodeName;
|
||||||
|
|
||||||
public BuilderIntrospection(final ModelType model, final Class<?> classType, final String rootNodeName) throws Exception {
|
public BuilderIntrospection(final ModelType model, final Class<?> classType, final String rootNodeName) throws ExmlException {
|
||||||
this.rootNodeName = rootNodeName;
|
this.rootNodeName = rootNodeName;
|
||||||
this.rootClassType = classType;
|
this.rootClassType = classType;
|
||||||
this.cacheModel.findOrCreate(model, null, classType);
|
this.cacheModel.findOrCreate(model, null, classType);
|
||||||
@ -22,17 +25,20 @@ public class BuilderIntrospection implements Builder {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void newComment(final Object element, final String comment) throws ExmlBuilderException {
|
public void newComment(final Object element, final String comment) throws ExmlException {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object newDeclaration(final Object parent, final String text) throws ExmlBuilderException {
|
public Object newDeclaration(final Object parent, final String text) throws ExmlException {
|
||||||
// we drop all declaration, no need of it too.
|
// we drop all declaration, no need of it too.
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object newElement(final Object parent, final String nodeName) throws ExmlBuilderException, Exception {
|
public Object newElement(final Object parent, final String nodeName) throws ExmlException {
|
||||||
|
if (parent == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
Log.warning("new element on NodeName=" + nodeName);
|
Log.warning("new element on NodeName=" + nodeName);
|
||||||
final IntrospectionObject introspectionObject = (IntrospectionObject) parent;
|
final IntrospectionObject introspectionObject = (IntrospectionObject) parent;
|
||||||
IntrospectionModel model = introspectionObject.getModelIntrospection();
|
IntrospectionModel model = introspectionObject.getModelIntrospection();
|
||||||
@ -89,12 +95,19 @@ public class BuilderIntrospection implements Builder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void newProperty(final Object element, final String propertyName, final String propertyValue) throws ExmlBuilderException, Exception {
|
public void newProperty(final Object element, final String propertyName, final String propertyValue) throws ExmlException {
|
||||||
|
if (element == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
final IntrospectionObject introspectionObject = (IntrospectionObject) element;
|
final IntrospectionObject introspectionObject = (IntrospectionObject) element;
|
||||||
IntrospectionModel model = introspectionObject.getModelIntrospection();
|
IntrospectionModel model = introspectionObject.getModelIntrospection();
|
||||||
if (model.isArray() || model.isList()) {
|
if (model.isArray() || model.isList()) {
|
||||||
throw new ExmlBuilderException("Model (List/Array) can not have property with name '" + propertyName + "'");
|
throw new ExmlBuilderException("Model (List/Array) can not have property with name '" + propertyName + "'");
|
||||||
}
|
}
|
||||||
|
String beanName = model.getBeanName(propertyName);
|
||||||
|
if (beanName == null) {
|
||||||
|
throw new ExmlAttributeDoesNotExist("The node '" + propertyName + "' Does not exist...");
|
||||||
|
}
|
||||||
Class<?> typeClass = model.getTypeOfProperty(propertyName);
|
Class<?> typeClass = model.getTypeOfProperty(propertyName);
|
||||||
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 ...
|
||||||
@ -137,7 +150,10 @@ public class BuilderIntrospection implements Builder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void newText(final Object parent, final String text) throws ExmlBuilderException {
|
public void newText(final Object parent, final String text) throws ExmlException {
|
||||||
|
if (parent == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
final IntrospectionObject introspectionObject = (IntrospectionObject) parent;
|
final IntrospectionObject introspectionObject = (IntrospectionObject) parent;
|
||||||
IntrospectionModel model = introspectionObject.getModelIntrospection();
|
IntrospectionModel model = introspectionObject.getModelIntrospection();
|
||||||
if (model.isArray() || model.isList()) {
|
if (model.isArray() || model.isList()) {
|
||||||
@ -159,6 +175,9 @@ public class BuilderIntrospection implements Builder {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void endElement(final Object element) throws ExmlBuilderException {
|
public void endElement(final Object element) throws ExmlBuilderException {
|
||||||
|
if (element == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
final IntrospectionObject introspectionObject = (IntrospectionObject) element;
|
final IntrospectionObject introspectionObject = (IntrospectionObject) element;
|
||||||
if (introspectionObject.getModelIntrospection() == null) {
|
if (introspectionObject.getModelIntrospection() == null) {
|
||||||
// property on nothing ???
|
// property on nothing ???
|
||||||
@ -169,7 +188,10 @@ public class BuilderIntrospection implements Builder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void newElementFinished(final Object parent, final String tmpName, final Object element) {
|
public void newElementFinished(final Object parent, final String tmpName, final Object element) throws ExmlException {
|
||||||
|
if (parent == null || element == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
final IntrospectionObject introspectionElementObject = (IntrospectionObject) element;
|
final IntrospectionObject introspectionElementObject = (IntrospectionObject) element;
|
||||||
if (introspectionElementObject.getModelIntrospection() == null) {
|
if (introspectionElementObject.getModelIntrospection() == null) {
|
||||||
// property on nothing ???
|
// property on nothing ???
|
||||||
|
@ -78,5 +78,8 @@ public abstract class IntrospectionModel {
|
|||||||
public boolean isEnum() {
|
public boolean isEnum() {
|
||||||
return this.classType.isEnum();
|
return this.classType.isEnum();
|
||||||
}
|
}
|
||||||
|
public String getBeanName(String nodeName) {
|
||||||
|
return nodeName;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,14 @@ public class IntrospectionModelComplex extends IntrospectionModel {
|
|||||||
private final List<ConstructorModel> constructors = new ArrayList<>();
|
private final List<ConstructorModel> constructors = new ArrayList<>();
|
||||||
private final List<IntrospectionProperty> elements = new ArrayList<>();
|
private final List<IntrospectionProperty> elements = new ArrayList<>();
|
||||||
|
|
||||||
|
public String getBeanName(String nodeName) {
|
||||||
|
for (IntrospectionProperty elem : this.elements) {
|
||||||
|
if (elem.isCompatible(nodeName)) {
|
||||||
|
return elem.getBeanName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public List<IntrospectionProperty> getNodes() {
|
public List<IntrospectionProperty> getNodes() {
|
||||||
List<IntrospectionProperty> out = new ArrayList<>();
|
List<IntrospectionProperty> out = new ArrayList<>();
|
||||||
@ -136,6 +144,9 @@ public class IntrospectionModelComplex extends IntrospectionModel {
|
|||||||
throw new ExmlBuilderException("Wrong number of parameter in constructor with ne number declared in the @XmlName (for bean name)");
|
throw new ExmlBuilderException("Wrong number of parameter in constructor with ne number declared in the @XmlName (for bean name)");
|
||||||
}
|
}
|
||||||
Boolean[] isAttributes = new Boolean[elem.getParameterCount()-offsetSubClass];
|
Boolean[] isAttributes = new Boolean[elem.getParameterCount()-offsetSubClass];
|
||||||
|
Boolean[] isCaseSensitives = new Boolean[elem.getParameterCount()-offsetSubClass];
|
||||||
|
Boolean[] isOptionals = new Boolean[elem.getParameterCount()-offsetSubClass];
|
||||||
|
Boolean[] isManageds = new Boolean[elem.getParameterCount()-offsetSubClass];
|
||||||
|
|
||||||
Class<?>[][] clazz = new Class<?>[elem.getParameterCount()-offsetSubClass][];
|
Class<?>[][] clazz = new Class<?>[elem.getParameterCount()-offsetSubClass][];
|
||||||
String[][] names = new String[elem.getParameterCount()-offsetSubClass][];
|
String[][] names = new String[elem.getParameterCount()-offsetSubClass][];
|
||||||
@ -144,6 +155,9 @@ public class IntrospectionModelComplex extends IntrospectionModel {
|
|||||||
for (int iii=offsetSubClass; iii<params.length; iii++) {
|
for (int iii=offsetSubClass; iii<params.length; iii++) {
|
||||||
Parameter paramElem = params[iii];
|
Parameter paramElem = params[iii];
|
||||||
isAttributes[iii-offsetSubClass] = ReflectTools.getIsAttribute(elem, paramElem, null);
|
isAttributes[iii-offsetSubClass] = ReflectTools.getIsAttribute(elem, paramElem, null);
|
||||||
|
isCaseSensitives[iii-offsetSubClass] = ReflectTools.getIsCaseSensitive(elem, paramElem, null);
|
||||||
|
isOptionals[iii-offsetSubClass] = ReflectTools.getIsOptional(elem, paramElem, null);
|
||||||
|
isManageds[iii-offsetSubClass] = ReflectTools.getIsManaged(elem, paramElem, null);
|
||||||
String[] namesParam = ReflectTools.getNames(elem, paramElem, null);
|
String[] namesParam = ReflectTools.getNames(elem, paramElem, null);
|
||||||
Class<?>[] types = ReflectTools.getTypeParameterfunction(elem, iii);
|
Class<?>[] types = ReflectTools.getTypeParameterfunction(elem, iii);
|
||||||
clazz[iii-offsetSubClass] = types;
|
clazz[iii-offsetSubClass] = types;
|
||||||
@ -189,6 +203,30 @@ public class IntrospectionModelComplex extends IntrospectionModel {
|
|||||||
}
|
}
|
||||||
prop.setAttribute(isAttribute);
|
prop.setAttribute(isAttribute);
|
||||||
}
|
}
|
||||||
|
final Boolean isCaseSensitive = isCaseSensitives[iii];
|
||||||
|
if (isCaseSensitive != null) {
|
||||||
|
Boolean curentValue = prop.isCaseSensitive();
|
||||||
|
if (curentValue != null && curentValue != isCaseSensitive) {
|
||||||
|
throw new ExmlBuilderException("Set 'caseSensitive' with a different value previous=" + curentValue + " ==> new=" + isCaseSensitive + " in " + elem.toGenericString());
|
||||||
|
}
|
||||||
|
prop.setCaseSensitive(isCaseSensitive);
|
||||||
|
}
|
||||||
|
final Boolean isOptional = isOptionals[iii];
|
||||||
|
if (isOptional != null) {
|
||||||
|
Boolean curentValue = prop.isOptionnal();
|
||||||
|
if (curentValue != null && curentValue != isOptional) {
|
||||||
|
throw new ExmlBuilderException("Set 'optionnal' with a different value previous=" + curentValue + " ==> new=" + isOptional + " in " + elem.toGenericString());
|
||||||
|
}
|
||||||
|
prop.setOptionnal(isOptional);
|
||||||
|
}
|
||||||
|
final Boolean isManaged = isManageds[iii];
|
||||||
|
if (isManaged != null) {
|
||||||
|
Boolean curentValue = prop.isManaged();
|
||||||
|
if (curentValue != null && curentValue != isManaged) {
|
||||||
|
throw new ExmlBuilderException("Set 'managed' with a different value previous=" + curentValue + " ==> new=" + isManaged + " in " + elem.toGenericString());
|
||||||
|
}
|
||||||
|
prop.setManaged(isManaged);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.constructors.add(new ConstructorModel(namesBeans, isAttributes, elem));
|
this.constructors.add(new ConstructorModel(namesBeans, isAttributes, elem));
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,8 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.atriasoft.exml.exception.ExmlBuilderException;
|
import org.atriasoft.exml.exception.ExmlBuilderException;
|
||||||
|
import org.atriasoft.exml.exception.ExmlException;
|
||||||
|
import org.atriasoft.exml.exception.ExmlNodeDoesNotExist;
|
||||||
import org.atriasoft.exml.internal.Log;
|
import org.atriasoft.exml.internal.Log;
|
||||||
|
|
||||||
public class IntrospectionObject {
|
public class IntrospectionObject {
|
||||||
@ -27,11 +29,12 @@ public class IntrospectionObject {
|
|||||||
return this.modelInterface;
|
return this.modelInterface;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void putProperty(final String propertyName, final Object propertyValue) throws Exception {
|
public void putProperty(final String propertyName, final Object propertyValue) throws ExmlException {
|
||||||
if (this.properties.containsKey(propertyName)) {
|
final String beanName = modelInterface.getBeanName(propertyName);
|
||||||
|
if (this.properties.containsKey(beanName)) {
|
||||||
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");
|
||||||
}
|
}
|
||||||
this.properties.put(propertyName, propertyValue);
|
this.properties.put(beanName, propertyValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -39,20 +42,40 @@ public class IntrospectionObject {
|
|||||||
* @param nodeName Name of the node
|
* @param nodeName Name of the node
|
||||||
* @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 ExmlException {
|
||||||
return this.modelInterface.getTypeOfSubNode(nodeName);
|
final String beanName = modelInterface.getBeanName(nodeName);
|
||||||
|
if (beanName == null) {
|
||||||
|
throw new ExmlNodeDoesNotExist("The node '" + nodeName + "' Does not exist...");
|
||||||
|
}
|
||||||
|
return this.modelInterface.getTypeOfSubNode(beanName);
|
||||||
}
|
}
|
||||||
public Class<?> getTypeOfSubNodeSubType(final String nodeName) throws ExmlBuilderException {
|
public Class<?> getTypeOfSubNodeSubType(final String nodeName) throws ExmlException {
|
||||||
return this.modelInterface.getTypeOfSubNodeList(nodeName);
|
final String beanName = modelInterface.getBeanName(nodeName);
|
||||||
|
if (beanName == null) {
|
||||||
|
throw new ExmlNodeDoesNotExist("The node '" + nodeName + "' Does not exist...");
|
||||||
|
}
|
||||||
|
return this.modelInterface.getTypeOfSubNodeList(beanName);
|
||||||
}
|
}
|
||||||
public String getTreeNameOfSubNode(final String nodeName) throws ExmlBuilderException {
|
public String getTreeNameOfSubNode(final String nodeName) throws ExmlException {
|
||||||
return this.modelInterface.getTreeNameOfSubNode(nodeName);
|
final String beanName = modelInterface.getBeanName(nodeName);
|
||||||
|
if (beanName == null) {
|
||||||
|
throw new ExmlNodeDoesNotExist("The node '" + nodeName + "' Does not exist...");
|
||||||
|
}
|
||||||
|
return this.modelInterface.getTreeNameOfSubNode(beanName);
|
||||||
}
|
}
|
||||||
public Class<?> getTypeOfProperty(final String nodeName) throws ExmlBuilderException {
|
public Class<?> getTypeOfProperty(final String nodeName) throws ExmlException {
|
||||||
return this.modelInterface.getTypeOfProperty(nodeName);
|
final String beanName = modelInterface.getBeanName(nodeName);
|
||||||
|
if (beanName == null) {
|
||||||
|
throw new ExmlNodeDoesNotExist("The node '" + nodeName + "' Does not exist...");
|
||||||
|
}
|
||||||
|
return this.modelInterface.getTypeOfProperty(beanName);
|
||||||
}
|
}
|
||||||
public Class<?> getTypeOfSubProperty(final String nodeName) throws ExmlBuilderException {
|
public Class<?> getTypeOfSubProperty(final String nodeName) throws ExmlException {
|
||||||
return this.modelInterface.getTypeOfSubProperty(nodeName);
|
final String beanName = modelInterface.getBeanName(nodeName);
|
||||||
|
if (beanName == null) {
|
||||||
|
throw new ExmlNodeDoesNotExist("The node '" + nodeName + "' Does not exist...");
|
||||||
|
}
|
||||||
|
return this.modelInterface.getTypeOfSubProperty(beanName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setText(final String text) throws ExmlBuilderException {
|
public void setText(final String text) throws ExmlBuilderException {
|
||||||
@ -63,8 +86,12 @@ public class IntrospectionObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void addObject(final String nodeName, final Object value) {
|
public void addObject(final String nodeName, final Object value) throws ExmlException {
|
||||||
List<Object> node = this.nodes.get(nodeName);
|
final String beanName = modelInterface.getBeanName(nodeName);
|
||||||
|
if (beanName == null) {
|
||||||
|
throw new ExmlNodeDoesNotExist("The node '" + nodeName + "' Does not exist...");
|
||||||
|
}
|
||||||
|
List<Object> node = this.nodes.get(beanName);
|
||||||
if (node == null) {
|
if (node == null) {
|
||||||
if (List.class.isAssignableFrom(value.getClass())) {
|
if (List.class.isAssignableFrom(value.getClass())) {
|
||||||
node = (List<Object>) value;
|
node = (List<Object>) value;
|
||||||
@ -83,7 +110,7 @@ public class IntrospectionObject {
|
|||||||
node = new ArrayList<>();
|
node = new ArrayList<>();
|
||||||
node.add(value);
|
node.add(value);
|
||||||
}
|
}
|
||||||
this.nodes.put(nodeName, node);
|
this.nodes.put(beanName, node);
|
||||||
} else if (value.getClass().isArray()) {
|
} else if (value.getClass().isArray()) {
|
||||||
Log.error("this is a big problem ...");
|
Log.error("this is a big problem ...");
|
||||||
Log.error("this is a big problem ...");
|
Log.error("this is a big problem ...");
|
||||||
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.atriasoft.eStringSerialize.StringSerializer;
|
import org.atriasoft.eStringSerialize.StringSerializer;
|
||||||
import org.atriasoft.exml.exception.ExmlBuilderException;
|
import org.atriasoft.exml.exception.ExmlBuilderException;
|
||||||
|
import org.atriasoft.exml.internal.Log;
|
||||||
|
|
||||||
public final class IntrospectionProperty {
|
public final class IntrospectionProperty {
|
||||||
// if the element is not managed by us (set at null while not define by a function attribute, parameter ...)
|
// if the element is not managed by us (set at null while not define by a function attribute, parameter ...)
|
||||||
@ -109,7 +110,7 @@ public final class IntrospectionProperty {
|
|||||||
* @param name Name to check
|
* @param name Name to check
|
||||||
* @return true if the element is compatible, false otherwise
|
* @return true if the element is compatible, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean isCompatible(String name) {
|
public boolean isCompatible(final String name) {
|
||||||
if (this.caseSensitive) {
|
if (this.caseSensitive) {
|
||||||
for (final String elem : this.names) {
|
for (final String elem : this.names) {
|
||||||
if (elem.contentEquals(name)) {
|
if (elem.contentEquals(name)) {
|
||||||
@ -117,7 +118,6 @@ public final class IntrospectionProperty {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
name = name.toLowerCase();
|
|
||||||
for (final String elem : this.names) {
|
for (final String elem : this.names) {
|
||||||
if (elem.equalsIgnoreCase(name)) {
|
if (elem.equalsIgnoreCase(name)) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -2,6 +2,7 @@ package org.atriasoft.exml.parser;
|
|||||||
|
|
||||||
import org.atriasoft.exml.builder.Builder;
|
import org.atriasoft.exml.builder.Builder;
|
||||||
import org.atriasoft.exml.exception.ExmlBuilderException;
|
import org.atriasoft.exml.exception.ExmlBuilderException;
|
||||||
|
import org.atriasoft.exml.exception.ExmlException;
|
||||||
import org.atriasoft.exml.exception.ExmlParserError;
|
import org.atriasoft.exml.exception.ExmlParserError;
|
||||||
import org.atriasoft.exml.exception.ExmlParserErrorMulti;
|
import org.atriasoft.exml.exception.ExmlParserErrorMulti;
|
||||||
import org.atriasoft.exml.internal.Log;
|
import org.atriasoft.exml.internal.Log;
|
||||||
@ -14,7 +15,7 @@ public class ParseXml {
|
|||||||
this.builder = builder;
|
this.builder = builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean iParseAttribute(final Object parent, final String data, final PositionParsing pos, final FilePos filePos, final ParsingProperty parsingProperty) throws ExmlBuilderException {
|
protected boolean iParseAttribute(final Object parent, final String data, final PositionParsing pos, final FilePos filePos, final ParsingProperty parsingProperty) throws ExmlException {
|
||||||
Log.verbose("start parse : 'attribute'");
|
Log.verbose("start parse : 'attribute'");
|
||||||
// search end of the comment :
|
// search end of the comment :
|
||||||
int lastElementName = pos.value;
|
int lastElementName = pos.value;
|
||||||
@ -101,16 +102,11 @@ public class ParseXml {
|
|||||||
//EXMLPARSEATTRIBUTE(pos << " attribute : " << name << "=\"" << value << "\"");
|
//EXMLPARSEATTRIBUTE(pos << " attribute : " << name << "=\"" << value << "\"");
|
||||||
|
|
||||||
pos.value = lastAttributePos;
|
pos.value = lastAttributePos;
|
||||||
try {
|
this.builder.newProperty(parent, name, value);
|
||||||
this.builder.newProperty(parent, name, value);
|
|
||||||
} catch (final Exception e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean iParseCDATA(final Object parent, final String data, final PositionParsing pos, final FilePos filePos, final ParsingProperty parsingProperty) throws ExmlBuilderException {
|
protected boolean iParseCDATA(final Object parent, final String data, final PositionParsing pos, final FilePos filePos, final ParsingProperty parsingProperty) throws ExmlException {
|
||||||
Log.verbose("start parse : 'text::CDATA'");
|
Log.verbose("start parse : 'text::CDATA'");
|
||||||
// search end of the comment :
|
// search end of the comment :
|
||||||
for (int iii = pos.value; iii + 2 < data.length(); iii++) {
|
for (int iii = pos.value; iii + 2 < data.length(); iii++) {
|
||||||
@ -133,7 +129,7 @@ public class ParseXml {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean iParseComment(final Object parent, final String data, final PositionParsing pos, final FilePos filePos, final ParsingProperty parsingProperty) throws ExmlBuilderException {
|
protected boolean iParseComment(final Object parent, final String data, final PositionParsing pos, final FilePos filePos, final ParsingProperty parsingProperty) throws ExmlException {
|
||||||
Log.verbose("start parse : 'comment'");
|
Log.verbose("start parse : 'comment'");
|
||||||
final FilePos tmpPos = new FilePos();
|
final FilePos tmpPos = new FilePos();
|
||||||
final int white = Tools.countWhiteChar(data, pos.value, tmpPos);
|
final int white = Tools.countWhiteChar(data, pos.value, tmpPos);
|
||||||
@ -167,7 +163,7 @@ public class ParseXml {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean iParseDeclaration(final Object parent, final String data, final PositionParsing pos, final FilePos filePos, final ParsingProperty parsingProperty) throws ExmlBuilderException {
|
protected boolean iParseDeclaration(final Object parent, final String data, final PositionParsing pos, final FilePos filePos, final ParsingProperty parsingProperty) throws ExmlException {
|
||||||
// search end of the comment :
|
// search end of the comment :
|
||||||
for (int iii = pos.value; iii + 1 < data.length(); iii++) {
|
for (int iii = pos.value; iii + 1 < data.length(); iii++) {
|
||||||
Tools.drawElementParsed(data.charAt(iii), filePos);
|
Tools.drawElementParsed(data.charAt(iii), filePos);
|
||||||
@ -200,7 +196,7 @@ public class ParseXml {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean iParseDOCTYPE(final Object parent, final String data, final PositionParsing pos, final FilePos filePos, final ParsingProperty parsingProperty) throws ExmlBuilderException {
|
protected boolean iParseDOCTYPE(final Object parent, final String data, final PositionParsing pos, final FilePos filePos, final ParsingProperty parsingProperty) throws ExmlException {
|
||||||
Log.verbose("start parse : 'DOCTYPE'");
|
Log.verbose("start parse : 'DOCTYPE'");
|
||||||
final FilePos tmpPos = new FilePos();
|
final FilePos tmpPos = new FilePos();
|
||||||
final int white = Tools.countWhiteChar(data, pos.value, tmpPos);
|
final int white = Tools.countWhiteChar(data, pos.value, tmpPos);
|
||||||
@ -222,7 +218,7 @@ public class ParseXml {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected boolean iParseElement(final Object parent, final String nameElement, final String data, final PositionParsing pos, final FilePos filePos, final ParsingProperty parsingProperty)
|
protected boolean iParseElement(final Object parent, final String nameElement, final String data, final PositionParsing pos, final FilePos filePos, final ParsingProperty parsingProperty)
|
||||||
throws ExmlBuilderException {
|
throws ExmlException {
|
||||||
// note : When start parsing the upper element must have set the value of the element and set the position after this one
|
// note : When start parsing the upper element must have set the value of the element and set the position after this one
|
||||||
// find a normal node ...
|
// find a normal node ...
|
||||||
for (int iii = pos.value; iii < data.length(); iii++) {
|
for (int iii = pos.value; iii < data.length(); iii++) {
|
||||||
@ -269,7 +265,7 @@ public class ParseXml {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean iParseText(final Object parent, final String data, final PositionParsing pos, final FilePos filePos, final ParsingProperty parsingProperty) throws ExmlBuilderException {
|
protected boolean iParseText(final Object parent, final String data, final PositionParsing pos, final FilePos filePos, final ParsingProperty parsingProperty) throws ExmlException {
|
||||||
Log.verbose("start parse : 'text'");
|
Log.verbose("start parse : 'text'");
|
||||||
// search end of the comment :
|
// search end of the comment :
|
||||||
for (int iii = pos.value; iii < data.length(); iii++) {
|
for (int iii = pos.value; iii < data.length(); iii++) {
|
||||||
@ -300,7 +296,7 @@ public class ParseXml {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object parse(final String data, final ParsingProperty property) throws ExmlBuilderException, ExmlParserErrorMulti {
|
public Object parse(final String data, final ParsingProperty property) throws ExmlException {
|
||||||
Log.verbose("Start parsing document (type: string) size=" + data.length());
|
Log.verbose("Start parsing document (type: string) size=" + data.length());
|
||||||
// came from char == > force in utf8 ...
|
// came from char == > force in utf8 ...
|
||||||
final FilePos pos = new FilePos(1, 0);
|
final FilePos pos = new FilePos(1, 0);
|
||||||
@ -327,9 +323,9 @@ public class ParseXml {
|
|||||||
* @param mainNode if true, this is the first root node
|
* @param mainNode if true, this is the first root node
|
||||||
* @return true parsing is done OK
|
* @return true parsing is done OK
|
||||||
* @return false An error appear in the parsing
|
* @return false An error appear in the parsing
|
||||||
|
* @throws ExmlException
|
||||||
*/
|
*/
|
||||||
protected boolean subParseElement(final Object parent, final String nameElement, final String data, final PositionParsing pos, final FilePos filePos, final ParsingProperty parsingProperty)
|
protected boolean subParseElement(final Object parent, final String nameElement, final String data, final PositionParsing pos, final FilePos filePos, final ParsingProperty parsingProperty) throws ExmlException {
|
||||||
throws ExmlBuilderException {
|
|
||||||
//EXMLPARSEELEMENT(" start subParse ... " << pos << " " << filePos);
|
//EXMLPARSEELEMENT(" start subParse ... " << pos << " " << filePos);
|
||||||
for (int iii = pos.value; iii < data.length(); iii++) {
|
for (int iii = pos.value; iii < data.length(); iii++) {
|
||||||
filePos.check(data.charAt(iii));
|
filePos.check(data.charAt(iii));
|
||||||
@ -534,12 +530,12 @@ public class ParseXml {
|
|||||||
Log.debug("find node named : '" + tmpname + "'");
|
Log.debug("find node named : '" + tmpname + "'");
|
||||||
// find text:
|
// find text:
|
||||||
Object element = null;
|
Object element = null;
|
||||||
try {
|
//try {
|
||||||
element = this.builder.newElement(parent, tmpname);
|
element = this.builder.newElement(parent, tmpname);
|
||||||
} catch (final Exception e) {
|
//} catch (final Exception e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
}
|
//}
|
||||||
pos.value = endPosName + 1;
|
pos.value = endPosName + 1;
|
||||||
filePos.add(tmpPos);
|
filePos.add(tmpPos);
|
||||||
Log.verbose("start parse : 'element' named='" + tmpname + "'");
|
Log.verbose("start parse : 'element' named='" + tmpname + "'");
|
||||||
|
@ -125,6 +125,16 @@ public class ReflectTools {
|
|||||||
}
|
}
|
||||||
return ((XmlCaseSensitive) annotation[0]).value();
|
return ((XmlCaseSensitive) annotation[0]).value();
|
||||||
}
|
}
|
||||||
|
public static Boolean getIsCaseSensitive(final Constructor<?> constructor, final Parameter element, final Boolean parentValue) throws ExmlBuilderException {
|
||||||
|
final Annotation[] annotation = element.getDeclaredAnnotationsByType(XmlCaseSensitive.class);
|
||||||
|
if (annotation.length == 0) {
|
||||||
|
return parentValue;
|
||||||
|
}
|
||||||
|
if (annotation.length > 1) {
|
||||||
|
throw new ExmlBuilderException("Must not have more than 1 element @XmlCaseSensitive on " + constructor.getClass().getCanonicalName());
|
||||||
|
}
|
||||||
|
return ((XmlCaseSensitive) annotation[0]).value();
|
||||||
|
}
|
||||||
|
|
||||||
public static Boolean getIsDefaultCaseSensitive(final Class<?> classType, final Boolean defaultValue) throws ExmlBuilderException {
|
public static Boolean getIsDefaultCaseSensitive(final Class<?> classType, final Boolean defaultValue) throws ExmlBuilderException {
|
||||||
final Annotation[] annotation = classType.getDeclaredAnnotationsByType(XmlDefaultCaseSensitive.class);
|
final Annotation[] annotation = classType.getDeclaredAnnotationsByType(XmlDefaultCaseSensitive.class);
|
||||||
@ -224,6 +234,17 @@ public class ReflectTools {
|
|||||||
}
|
}
|
||||||
return ((XmlManaged) annotation[0]).value();
|
return ((XmlManaged) annotation[0]).value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Boolean getIsManaged(final Constructor<?> constructor, final Parameter element, final Boolean parentValue) throws ExmlBuilderException {
|
||||||
|
final Annotation[] annotation = element.getDeclaredAnnotationsByType(XmlManaged.class);
|
||||||
|
if (annotation.length == 0) {
|
||||||
|
return parentValue;
|
||||||
|
}
|
||||||
|
if (annotation.length > 1) {
|
||||||
|
throw new ExmlBuilderException("Must not have more than 1 element @XmlManaged on " + constructor.getClass().getCanonicalName());
|
||||||
|
}
|
||||||
|
return ((XmlManaged) annotation[0]).value();
|
||||||
|
}
|
||||||
|
|
||||||
public static Boolean getIsOptional(final Field element, final Boolean parentValue) throws Exception {
|
public static Boolean getIsOptional(final Field element, final Boolean parentValue) throws Exception {
|
||||||
final Annotation[] annotation = element.getDeclaredAnnotationsByType(XmlOptional.class);
|
final Annotation[] annotation = element.getDeclaredAnnotationsByType(XmlOptional.class);
|
||||||
@ -246,6 +267,17 @@ public class ReflectTools {
|
|||||||
}
|
}
|
||||||
return ((XmlOptional) annotation[0]).value();
|
return ((XmlOptional) annotation[0]).value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Boolean getIsOptional(final Constructor<?> constructor, final Parameter element, final Boolean parentValue) throws ExmlBuilderException {
|
||||||
|
final Annotation[] annotation = element.getDeclaredAnnotationsByType(XmlOptional.class);
|
||||||
|
if (annotation.length == 0) {
|
||||||
|
return parentValue;
|
||||||
|
}
|
||||||
|
if (annotation.length > 1) {
|
||||||
|
throw new ExmlBuilderException("Must not have more than 1 element @XmlOptional on " + constructor.getClass().getCanonicalName());
|
||||||
|
}
|
||||||
|
return ((XmlOptional) annotation[0]).value();
|
||||||
|
}
|
||||||
|
|
||||||
public static String[] getNames(final Field element, final String defaultValue) throws Exception {
|
public static String[] getNames(final Field element, final String defaultValue) throws Exception {
|
||||||
final Annotation[] annotation = element.getDeclaredAnnotationsByType(XmlName.class);
|
final Annotation[] annotation = element.getDeclaredAnnotationsByType(XmlName.class);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,594 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2021, Edouard DUPIN, all right reserved
|
||||||
|
* @license MPL v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
package test.atriasoft.exml;
|
||||||
|
|
||||||
|
|
||||||
|
import org.atriasoft.exml.Exml;
|
||||||
|
import org.atriasoft.exml.annotation.XmlManaged;
|
||||||
|
import org.atriasoft.exml.annotation.XmlCaseSensitive;
|
||||||
|
import org.atriasoft.exml.annotation.XmlDefaultAttibute;
|
||||||
|
import org.atriasoft.exml.annotation.XmlDefaultCaseSensitive;
|
||||||
|
import org.atriasoft.exml.annotation.XmlDefaultManaged;
|
||||||
|
import org.atriasoft.exml.annotation.XmlManaged;
|
||||||
|
import org.atriasoft.exml.annotation.XmlName;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
public class ExmlTestIntrospectionDecoratorManaged {
|
||||||
|
static final String NODE_NAME = "elem";
|
||||||
|
@BeforeAll
|
||||||
|
public static void beforeClass() {
|
||||||
|
Log.warning("================================================================");
|
||||||
|
}
|
||||||
|
// ************************************************************
|
||||||
|
// ** Managed
|
||||||
|
// ************************************************************
|
||||||
|
|
||||||
|
@XmlDefaultManaged
|
||||||
|
public class TestNodeObject {
|
||||||
|
|
||||||
|
public int valueA;
|
||||||
|
@XmlManaged
|
||||||
|
public int valueB;
|
||||||
|
@XmlManaged(true)
|
||||||
|
public int valueC;
|
||||||
|
@XmlManaged(false)
|
||||||
|
public int valueD;
|
||||||
|
|
||||||
|
private int valueE;
|
||||||
|
private int valueF;
|
||||||
|
private int valueG;
|
||||||
|
private int valueH;
|
||||||
|
private int valueI;
|
||||||
|
private int valueJ;
|
||||||
|
private int valueK;
|
||||||
|
|
||||||
|
|
||||||
|
public final int finalValueM;
|
||||||
|
@XmlManaged
|
||||||
|
public final int finalValueN;
|
||||||
|
@XmlManaged(true)
|
||||||
|
public final int finalValueO;
|
||||||
|
@XmlManaged(false)
|
||||||
|
public final int finalValueP;
|
||||||
|
|
||||||
|
private final int pFinalValueQ;
|
||||||
|
private final int pFinalValueR;
|
||||||
|
private final int pFinalValueS;
|
||||||
|
private final int pFinalValueT;
|
||||||
|
|
||||||
|
// note: this constructor is not managed by the system ==> some field can not be instantiate (unmanaged ...)
|
||||||
|
@XmlName({"finalValueM", "finalValueN", "finalValueO", "finalValueP",
|
||||||
|
"pFinalValueQ", "pFinalValueR", "pFinalValueS", "pFinalValueT"})
|
||||||
|
public TestNodeObject(
|
||||||
|
final int finalValueM, final int finalValueN, final int finalValueO, final int finalValueP,
|
||||||
|
final int pFinalValueQ, final int pFinalValueR, final int pFinalValueS, final int pFinalValueT) {
|
||||||
|
this.finalValueM = finalValueM;
|
||||||
|
this.finalValueN = finalValueN;
|
||||||
|
this.finalValueO = finalValueO;
|
||||||
|
this.finalValueP = finalValueP;
|
||||||
|
this.pFinalValueQ = pFinalValueQ;
|
||||||
|
this.pFinalValueR = pFinalValueR;
|
||||||
|
this.pFinalValueS = pFinalValueS;
|
||||||
|
this.pFinalValueT = pFinalValueT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlName({"finalValueM", "finalValueN", "finalValueO",
|
||||||
|
"pFinalValueQ", "pFinalValueR", "pFinalValueS"})
|
||||||
|
public TestNodeObject(
|
||||||
|
final int finalValueM, final int finalValueN, final int finalValueO,
|
||||||
|
final int pFinalValueQ, final int pFinalValueR, final int pFinalValueS) {
|
||||||
|
this.finalValueM = finalValueM;
|
||||||
|
this.finalValueN = finalValueN;
|
||||||
|
this.finalValueO = finalValueO;
|
||||||
|
this.finalValueP = -555556;
|
||||||
|
this.pFinalValueQ = pFinalValueQ;
|
||||||
|
this.pFinalValueR = pFinalValueR;
|
||||||
|
this.pFinalValueS = pFinalValueS;
|
||||||
|
this.pFinalValueT = -555557;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getValueE() {
|
||||||
|
return this.valueE;
|
||||||
|
}
|
||||||
|
public void setValueE(final int valueE) {
|
||||||
|
this.valueE = valueE;
|
||||||
|
}
|
||||||
|
@XmlManaged
|
||||||
|
public int getValueF() {
|
||||||
|
return this.valueF;
|
||||||
|
}
|
||||||
|
public void setValueF(final int valueF) {
|
||||||
|
this.valueF = valueF;
|
||||||
|
}
|
||||||
|
public int getValueG() {
|
||||||
|
return this.valueG;
|
||||||
|
}
|
||||||
|
@XmlManaged
|
||||||
|
public void setValueG(final int valueG) {
|
||||||
|
this.valueG = valueG;
|
||||||
|
}
|
||||||
|
@XmlManaged(true)
|
||||||
|
public int getValueH() {
|
||||||
|
return this.valueH;
|
||||||
|
}
|
||||||
|
public void setValueH(final int valueH) {
|
||||||
|
this.valueH = valueH;
|
||||||
|
}
|
||||||
|
public int getValueI() {
|
||||||
|
return this.valueI;
|
||||||
|
}
|
||||||
|
@XmlManaged(true)
|
||||||
|
public void setValueI(final int valueI) {
|
||||||
|
this.valueI = valueI;
|
||||||
|
}
|
||||||
|
@XmlManaged(false)
|
||||||
|
public int getValueJ() {
|
||||||
|
return this.valueJ;
|
||||||
|
}
|
||||||
|
public void setValueJ(final int valueJ) {
|
||||||
|
this.valueJ = valueJ;
|
||||||
|
}
|
||||||
|
public int getValueK() {
|
||||||
|
return this.valueK;
|
||||||
|
}
|
||||||
|
@XmlManaged(false)
|
||||||
|
public void setValueK(final int valueK) {
|
||||||
|
this.valueK = valueK;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPFinalValueQ() {
|
||||||
|
return this.pFinalValueQ;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlManaged
|
||||||
|
public int getPFinalValueR() {
|
||||||
|
return this.pFinalValueR;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlManaged(true)
|
||||||
|
public int getPFinalValueS() {
|
||||||
|
return this.pFinalValueS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlManaged(false)
|
||||||
|
public int getPFinalValueT() {
|
||||||
|
return this.pFinalValueT;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void testDefaultManaged() {
|
||||||
|
TestNodeObject elem = new TestNodeObject(321,654,987,159, -552, -965, -98885, -8754);
|
||||||
|
elem.valueA = 55;
|
||||||
|
elem.valueB = 78;
|
||||||
|
elem.valueC = 51;
|
||||||
|
elem.valueD = 24;
|
||||||
|
elem.setValueE(651);
|
||||||
|
elem.setValueF(654);
|
||||||
|
elem.setValueG(8552);
|
||||||
|
elem.setValueH(9531);
|
||||||
|
elem.setValueI(87465);
|
||||||
|
elem.setValueJ(8247);
|
||||||
|
elem.setValueK(885522);
|
||||||
|
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionObject.NODE_NAME, builder));
|
||||||
|
String dataTest = builder.toString();
|
||||||
|
Log.warning("data generated: " + dataTest);
|
||||||
|
Assertions.assertEquals("<elem>\n"
|
||||||
|
+ " <finalValueM>321</finalValueM>\n"
|
||||||
|
+ " <finalValueN>654</finalValueN>\n"
|
||||||
|
+ " <finalValueO>987</finalValueO>\n"
|
||||||
|
+ " <pFinalValueQ>-552</pFinalValueQ>\n"
|
||||||
|
+ " <pFinalValueR>-965</pFinalValueR>\n"
|
||||||
|
+ " <pFinalValueS>-98885</pFinalValueS>\n"
|
||||||
|
+ " <valueA>55</valueA>\n"
|
||||||
|
+ " <valueB>78</valueB>\n"
|
||||||
|
+ " <valueC>51</valueC>\n"
|
||||||
|
+ " <valueE>651</valueE>\n"
|
||||||
|
+ " <valueF>654</valueF>\n"
|
||||||
|
+ " <valueG>8552</valueG>\n"
|
||||||
|
+ " <valueH>9531</valueH>\n"
|
||||||
|
+ " <valueI>87465</valueI>\n"
|
||||||
|
+ "</elem>", dataTest);
|
||||||
|
|
||||||
|
final TestNodeObject root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeObject.class, ExmlTestIntrospectionObject.NODE_NAME));
|
||||||
|
Assertions.assertEquals(55, root.valueA);
|
||||||
|
Assertions.assertEquals(78, root.valueB);
|
||||||
|
Assertions.assertEquals(51, root.valueC);
|
||||||
|
Assertions.assertEquals(24, root.valueD);
|
||||||
|
Assertions.assertEquals(651, root.getValueE());
|
||||||
|
Assertions.assertEquals(654, root.getValueF());
|
||||||
|
Assertions.assertEquals(8552, root.getValueG());
|
||||||
|
Assertions.assertEquals(9531, root.getValueH());
|
||||||
|
Assertions.assertEquals(87465, root.getValueI());
|
||||||
|
Assertions.assertEquals(8247, root.getValueJ());
|
||||||
|
Assertions.assertEquals(885522, root.getValueK());
|
||||||
|
Assertions.assertEquals(321, root.finalValueM);
|
||||||
|
Assertions.assertEquals(654, root.finalValueN);
|
||||||
|
Assertions.assertEquals(987, root.finalValueO);
|
||||||
|
Assertions.assertEquals(-555556, root.finalValueP);
|
||||||
|
Assertions.assertEquals(-552, root.getPFinalValueQ());
|
||||||
|
Assertions.assertEquals(-965, root.getPFinalValueR());
|
||||||
|
Assertions.assertEquals(-98885, root.getPFinalValueS());
|
||||||
|
Assertions.assertEquals(-555557, root.getPFinalValueT());
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlDefaultManaged(true)
|
||||||
|
public class TestNodeObjectTrue {
|
||||||
|
public int valueA;
|
||||||
|
@XmlManaged
|
||||||
|
public int valueB;
|
||||||
|
@XmlManaged(true)
|
||||||
|
public int valueC;
|
||||||
|
@XmlManaged(false)
|
||||||
|
public int valueD;
|
||||||
|
|
||||||
|
private int valueE;
|
||||||
|
private int valueF;
|
||||||
|
private int valueG;
|
||||||
|
private int valueH;
|
||||||
|
private int valueI;
|
||||||
|
private int valueJ;
|
||||||
|
private int valueK;
|
||||||
|
|
||||||
|
|
||||||
|
public final int finalValueM;
|
||||||
|
@XmlManaged
|
||||||
|
public final int finalValueN;
|
||||||
|
@XmlManaged(true)
|
||||||
|
public final int finalValueO;
|
||||||
|
@XmlManaged(false)
|
||||||
|
public final int finalValueP;
|
||||||
|
|
||||||
|
// special case for bijectivity with records
|
||||||
|
public final int finalValueQ;
|
||||||
|
public final int finalValueR;
|
||||||
|
public final int finalValueS;
|
||||||
|
public final int finalValueT;
|
||||||
|
|
||||||
|
private final int pFinalValueQ;
|
||||||
|
private final int pFinalValueR;
|
||||||
|
private final int pFinalValueS;
|
||||||
|
private final int pFinalValueT;
|
||||||
|
|
||||||
|
@XmlName({"finalValueM", "finalValueN", "finalValueO", "finalValueP",
|
||||||
|
"finalValueQ", "finalValueR", "finalValueS", "finalValueT",
|
||||||
|
"pFinalValueQ", "pFinalValueR", "pFinalValueS", "pFinalValueT"})
|
||||||
|
public TestNodeObjectTrue(
|
||||||
|
final int finalValueM, final int finalValueN, final int finalValueO, final int finalValueP,
|
||||||
|
final int finalValueQ, @XmlManaged final int finalValueR, @XmlManaged(true) final int finalValueS, @XmlManaged(false) final int finalValueT,
|
||||||
|
final int pFinalValueQ, final int pFinalValueR, final int pFinalValueS, final int pFinalValueT) {
|
||||||
|
this.finalValueM = finalValueM;
|
||||||
|
this.finalValueN = finalValueN;
|
||||||
|
this.finalValueO = finalValueO;
|
||||||
|
this.finalValueP = finalValueP;
|
||||||
|
this.finalValueQ = finalValueQ;
|
||||||
|
this.finalValueR = finalValueR;
|
||||||
|
this.finalValueS = finalValueS;
|
||||||
|
this.finalValueT = finalValueT;
|
||||||
|
this.pFinalValueQ = pFinalValueQ;
|
||||||
|
this.pFinalValueR = pFinalValueR;
|
||||||
|
this.pFinalValueS = pFinalValueS;
|
||||||
|
this.pFinalValueT = pFinalValueT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getValueE() {
|
||||||
|
return this.valueE;
|
||||||
|
}
|
||||||
|
public void setValueE(final int valueE) {
|
||||||
|
this.valueE = valueE;
|
||||||
|
}
|
||||||
|
@XmlManaged
|
||||||
|
public int getValueF() {
|
||||||
|
return this.valueF;
|
||||||
|
}
|
||||||
|
public void setValueF(final int valueF) {
|
||||||
|
this.valueF = valueF;
|
||||||
|
}
|
||||||
|
public int getValueG() {
|
||||||
|
return this.valueG;
|
||||||
|
}
|
||||||
|
@XmlManaged
|
||||||
|
public void setValueG(final int valueG) {
|
||||||
|
this.valueG = valueG;
|
||||||
|
}
|
||||||
|
@XmlManaged(true)
|
||||||
|
public int getValueH() {
|
||||||
|
return this.valueH;
|
||||||
|
}
|
||||||
|
public void setValueH(final int valueH) {
|
||||||
|
this.valueH = valueH;
|
||||||
|
}
|
||||||
|
public int getValueI() {
|
||||||
|
return this.valueI;
|
||||||
|
}
|
||||||
|
@XmlManaged(true)
|
||||||
|
public void setValueI(final int valueI) {
|
||||||
|
this.valueI = valueI;
|
||||||
|
}
|
||||||
|
@XmlManaged(false)
|
||||||
|
public int getValueJ() {
|
||||||
|
return this.valueJ;
|
||||||
|
}
|
||||||
|
public void setValueJ(final int valueJ) {
|
||||||
|
this.valueJ = valueJ;
|
||||||
|
}
|
||||||
|
public int getValueK() {
|
||||||
|
return this.valueK;
|
||||||
|
}
|
||||||
|
@XmlManaged(false)
|
||||||
|
public void setValueK(final int valueK) {
|
||||||
|
this.valueK = valueK;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPFinalValueQ() {
|
||||||
|
return this.pFinalValueQ;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlManaged
|
||||||
|
public int getPFinalValueR() {
|
||||||
|
return this.pFinalValueR;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlManaged(true)
|
||||||
|
public int getPFinalValueS() {
|
||||||
|
return this.pFinalValueS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlManaged(false)
|
||||||
|
public int getPFinalValueT() {
|
||||||
|
return this.pFinalValueT;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void testDefaultManagedTrue() {
|
||||||
|
TestNodeObjectTrue elem = new TestNodeObjectTrue(321,654,987,159,267,264,1524,182445, -552, -965, -98885, -8754);
|
||||||
|
elem.valueA = 55;
|
||||||
|
elem.valueB = 78;
|
||||||
|
elem.valueC = 51;
|
||||||
|
elem.valueD = 24;
|
||||||
|
elem.setValueE(651);
|
||||||
|
elem.setValueF(654);
|
||||||
|
elem.setValueG(8552);
|
||||||
|
elem.setValueH(9531);
|
||||||
|
elem.setValueI(87465);
|
||||||
|
elem.setValueJ(8247);
|
||||||
|
elem.setValueK(885522);
|
||||||
|
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionObject.NODE_NAME, builder));
|
||||||
|
String dataTest = builder.toString();
|
||||||
|
Log.warning("data generated: " + builder.toString());
|
||||||
|
Assertions.assertEquals("<elem finalValueM=\"321\" finalValueN=\"654\" finalValueO=\"987\" finalValueQ=\"267\" finalValueR=\"264\" finalValueS=\"1524\" pFinalValueQ=\"-552\" pFinalValueR=\"-965\" pFinalValueS=\"-98885\" valueA=\"55\" valueB=\"78\" valueC=\"51\" valueE=\"651\" valueF=\"654\" valueG=\"8552\" valueH=\"9531\" valueI=\"87465\">\n"
|
||||||
|
+ " <finalValueP>159</finalValueP>\n"
|
||||||
|
+ " <finalValueT>182445</finalValueT>\n"
|
||||||
|
+ " <pFinalValueT>-8754</pFinalValueT>\n"
|
||||||
|
+ " <valueD>24</valueD>\n"
|
||||||
|
+ " <valueJ>8247</valueJ>\n"
|
||||||
|
+ " <valueK>885522</valueK>\n"
|
||||||
|
+ "</elem>", dataTest);
|
||||||
|
|
||||||
|
final TestNodeObjectTrue root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeObjectTrue.class, ExmlTestIntrospectionObject.NODE_NAME));
|
||||||
|
Assertions.assertEquals(55, root.valueA);
|
||||||
|
Assertions.assertEquals(78, root.valueB);
|
||||||
|
Assertions.assertEquals(51, root.valueC);
|
||||||
|
Assertions.assertEquals(24, root.valueD);
|
||||||
|
Assertions.assertEquals(651, root.getValueE());
|
||||||
|
Assertions.assertEquals(654, root.getValueF());
|
||||||
|
Assertions.assertEquals(8552, root.getValueG());
|
||||||
|
Assertions.assertEquals(9531, root.getValueH());
|
||||||
|
Assertions.assertEquals(87465, root.getValueI());
|
||||||
|
Assertions.assertEquals(8247, root.getValueJ());
|
||||||
|
Assertions.assertEquals(885522, root.getValueK());
|
||||||
|
Assertions.assertEquals(321, root.finalValueM);
|
||||||
|
Assertions.assertEquals(654, root.finalValueN);
|
||||||
|
Assertions.assertEquals(987, root.finalValueO);
|
||||||
|
Assertions.assertEquals(159, root.finalValueP);
|
||||||
|
Assertions.assertEquals(267, root.finalValueQ);
|
||||||
|
Assertions.assertEquals(264, root.finalValueR);
|
||||||
|
Assertions.assertEquals(1524, root.finalValueS);
|
||||||
|
Assertions.assertEquals(182445, root.finalValueT);
|
||||||
|
Assertions.assertEquals(-552, root.getPFinalValueQ());
|
||||||
|
Assertions.assertEquals(-965, root.getPFinalValueR());
|
||||||
|
Assertions.assertEquals(-98885, root.getPFinalValueS());
|
||||||
|
Assertions.assertEquals(-8754, root.getPFinalValueT());
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlDefaultManaged(false)
|
||||||
|
public class TestNodeObjectFalse {
|
||||||
|
public int valueA;
|
||||||
|
@XmlManaged
|
||||||
|
public int valueB;
|
||||||
|
@XmlManaged(true)
|
||||||
|
public int valueC;
|
||||||
|
@XmlManaged(false)
|
||||||
|
public int valueD;
|
||||||
|
|
||||||
|
private int valueE;
|
||||||
|
private int valueF;
|
||||||
|
private int valueG;
|
||||||
|
private int valueH;
|
||||||
|
private int valueI;
|
||||||
|
private int valueJ;
|
||||||
|
private int valueK;
|
||||||
|
|
||||||
|
public final int finalValueM;
|
||||||
|
@XmlManaged
|
||||||
|
public final int finalValueN;
|
||||||
|
@XmlManaged(true)
|
||||||
|
public final int finalValueO;
|
||||||
|
@XmlManaged(false)
|
||||||
|
public final int finalValueP;
|
||||||
|
|
||||||
|
// special case for bijectivity with records
|
||||||
|
public final int finalValueQ;
|
||||||
|
public final int finalValueR;
|
||||||
|
public final int finalValueS;
|
||||||
|
public final int finalValueT;
|
||||||
|
|
||||||
|
private final int pFinalValueQ;
|
||||||
|
private final int pFinalValueR;
|
||||||
|
private final int pFinalValueS;
|
||||||
|
private final int pFinalValueT;
|
||||||
|
|
||||||
|
@XmlName({"finalValueM", "finalValueN", "finalValueO", "finalValueP",
|
||||||
|
"finalValueQ", "finalValueR", "finalValueS", "finalValueT",
|
||||||
|
"pFinalValueQ", "pFinalValueR", "pFinalValueS", "pFinalValueT"})
|
||||||
|
public TestNodeObjectFalse(
|
||||||
|
final int finalValueM, final int finalValueN, final int finalValueO, final int finalValueP,
|
||||||
|
final int finalValueQ, @XmlManaged final int finalValueR, @XmlManaged(true) final int finalValueS, @XmlManaged(false) final int finalValueT,
|
||||||
|
final int pFinalValueQ, final int pFinalValueR, final int pFinalValueS, final int pFinalValueT) {
|
||||||
|
this.finalValueM = finalValueM;
|
||||||
|
this.finalValueN = finalValueN;
|
||||||
|
this.finalValueO = finalValueO;
|
||||||
|
this.finalValueP = finalValueP;
|
||||||
|
this.finalValueQ = finalValueQ;
|
||||||
|
this.finalValueR = finalValueR;
|
||||||
|
this.finalValueS = finalValueS;
|
||||||
|
this.finalValueT = finalValueT;
|
||||||
|
this.pFinalValueQ = pFinalValueQ;
|
||||||
|
this.pFinalValueR = pFinalValueR;
|
||||||
|
this.pFinalValueS = pFinalValueS;
|
||||||
|
this.pFinalValueT = pFinalValueT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getValueE() {
|
||||||
|
return this.valueE;
|
||||||
|
}
|
||||||
|
public void setValueE(final int valueE) {
|
||||||
|
this.valueE = valueE;
|
||||||
|
}
|
||||||
|
@XmlManaged
|
||||||
|
public int getValueF() {
|
||||||
|
return this.valueF;
|
||||||
|
}
|
||||||
|
public void setValueF(final int valueF) {
|
||||||
|
this.valueF = valueF;
|
||||||
|
}
|
||||||
|
public int getValueG() {
|
||||||
|
return this.valueG;
|
||||||
|
}
|
||||||
|
@XmlManaged
|
||||||
|
public void setValueG(final int valueG) {
|
||||||
|
this.valueG = valueG;
|
||||||
|
}
|
||||||
|
@XmlManaged(true)
|
||||||
|
public int getValueH() {
|
||||||
|
return this.valueH;
|
||||||
|
}
|
||||||
|
public void setValueH(final int valueH) {
|
||||||
|
this.valueH = valueH;
|
||||||
|
}
|
||||||
|
public int getValueI() {
|
||||||
|
return this.valueI;
|
||||||
|
}
|
||||||
|
@XmlManaged(true)
|
||||||
|
public void setValueI(final int valueI) {
|
||||||
|
this.valueI = valueI;
|
||||||
|
}
|
||||||
|
@XmlManaged(false)
|
||||||
|
public int getValueJ() {
|
||||||
|
return this.valueJ;
|
||||||
|
}
|
||||||
|
public void setValueJ(final int valueJ) {
|
||||||
|
this.valueJ = valueJ;
|
||||||
|
}
|
||||||
|
public int getValueK() {
|
||||||
|
return this.valueK;
|
||||||
|
}
|
||||||
|
@XmlManaged(false)
|
||||||
|
public void setValueK(final int valueK) {
|
||||||
|
this.valueK = valueK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int getPFinalValueQ() {
|
||||||
|
return this.pFinalValueQ;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlManaged
|
||||||
|
public int getPFinalValueR() {
|
||||||
|
return this.pFinalValueR;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlManaged(true)
|
||||||
|
public int getPFinalValueS() {
|
||||||
|
return this.pFinalValueS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlManaged(false)
|
||||||
|
public int getPFinalValueT() {
|
||||||
|
return this.pFinalValueT;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void testDefaultManagedFalse() {
|
||||||
|
TestNodeObjectFalse elem = new TestNodeObjectFalse(321,654,987,159,267,264,1524,182445, -552, -965, -98885, -8754);
|
||||||
|
elem.valueA = 55;
|
||||||
|
elem.valueB = 78;
|
||||||
|
elem.valueC = 51;
|
||||||
|
elem.valueD = 24;
|
||||||
|
elem.setValueE(651);
|
||||||
|
elem.setValueF(654);
|
||||||
|
elem.setValueG(8552);
|
||||||
|
elem.setValueH(9531);
|
||||||
|
elem.setValueI(87465);
|
||||||
|
elem.setValueJ(8247);
|
||||||
|
elem.setValueK(885522);
|
||||||
|
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionObject.NODE_NAME, builder));
|
||||||
|
String dataTest = builder.toString();
|
||||||
|
Log.warning("data generated: " + builder.toString());
|
||||||
|
Assertions.assertEquals("<elem finalValueN=\"654\" finalValueO=\"987\" finalValueR=\"264\" finalValueS=\"1524\" pFinalValueR=\"-965\" pFinalValueS=\"-98885\" valueB=\"78\" valueC=\"51\" valueF=\"654\" valueG=\"8552\" valueH=\"9531\" valueI=\"87465\">\n"
|
||||||
|
+ " <finalValueM>321</finalValueM>\n"
|
||||||
|
+ " <finalValueP>159</finalValueP>\n"
|
||||||
|
+ " <finalValueQ>267</finalValueQ>\n"
|
||||||
|
+ " <finalValueT>182445</finalValueT>\n"
|
||||||
|
+ " <pFinalValueQ>-552</pFinalValueQ>\n"
|
||||||
|
+ " <pFinalValueT>-8754</pFinalValueT>\n"
|
||||||
|
+ " <valueA>55</valueA>\n"
|
||||||
|
+ " <valueD>24</valueD>\n"
|
||||||
|
+ " <valueE>651</valueE>\n"
|
||||||
|
+ " <valueJ>8247</valueJ>\n"
|
||||||
|
+ " <valueK>885522</valueK>\n"
|
||||||
|
+ "</elem>", dataTest);
|
||||||
|
|
||||||
|
final TestNodeObjectFalse root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeObjectFalse.class, ExmlTestIntrospectionObject.NODE_NAME));
|
||||||
|
Assertions.assertEquals(55, root.valueA);
|
||||||
|
Assertions.assertEquals(78, root.valueB);
|
||||||
|
Assertions.assertEquals(51, root.valueC);
|
||||||
|
Assertions.assertEquals(24, root.valueD);
|
||||||
|
Assertions.assertEquals(651, root.getValueE());
|
||||||
|
Assertions.assertEquals(654, root.getValueF());
|
||||||
|
Assertions.assertEquals(8552, root.getValueG());
|
||||||
|
Assertions.assertEquals(9531, root.getValueH());
|
||||||
|
Assertions.assertEquals(87465, root.getValueI());
|
||||||
|
Assertions.assertEquals(8247, root.getValueJ());
|
||||||
|
Assertions.assertEquals(885522, root.getValueK());
|
||||||
|
Assertions.assertEquals(321, root.finalValueM);
|
||||||
|
Assertions.assertEquals(654, root.finalValueN);
|
||||||
|
Assertions.assertEquals(987, root.finalValueO);
|
||||||
|
Assertions.assertEquals(159, root.finalValueP);
|
||||||
|
Assertions.assertEquals(267, root.finalValueQ);
|
||||||
|
Assertions.assertEquals(264, root.finalValueR);
|
||||||
|
Assertions.assertEquals(1524, root.finalValueS);
|
||||||
|
Assertions.assertEquals(182445, root.finalValueT);
|
||||||
|
Assertions.assertEquals(-552, root.getPFinalValueQ());
|
||||||
|
Assertions.assertEquals(-965, root.getPFinalValueR());
|
||||||
|
Assertions.assertEquals(-98885, root.getPFinalValueS());
|
||||||
|
Assertions.assertEquals(-8754, root.getPFinalValueT());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,584 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2021, Edouard DUPIN, all right reserved
|
||||||
|
* @license MPL v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
package test.atriasoft.exml;
|
||||||
|
|
||||||
|
|
||||||
|
import org.atriasoft.exml.Exml;
|
||||||
|
import org.atriasoft.exml.annotation.XmlAttribute;
|
||||||
|
import org.atriasoft.exml.annotation.XmlCaseSensitive;
|
||||||
|
import org.atriasoft.exml.annotation.XmlDefaultAttibute;
|
||||||
|
import org.atriasoft.exml.annotation.XmlDefaultCaseSensitive;
|
||||||
|
import org.atriasoft.exml.annotation.XmlName;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
public class ExmlTestIntrospectionDecoratorNames {
|
||||||
|
static final String NODE_NAME = "elem";
|
||||||
|
@BeforeAll
|
||||||
|
public static void beforeClass() {
|
||||||
|
Log.warning("================================================================");
|
||||||
|
}
|
||||||
|
// ************************************************************
|
||||||
|
// ** Attribute
|
||||||
|
// ************************************************************
|
||||||
|
|
||||||
|
@XmlDefaultCaseSensitive
|
||||||
|
public class TestNodeObject {
|
||||||
|
|
||||||
|
public int valueA;
|
||||||
|
@XmlCaseSensitive
|
||||||
|
public int valueB;
|
||||||
|
@XmlCaseSensitive(true)
|
||||||
|
public int valueC;
|
||||||
|
@XmlCaseSensitive(false)
|
||||||
|
public int valueD;
|
||||||
|
|
||||||
|
private int valueE;
|
||||||
|
private int valueF;
|
||||||
|
private int valueG;
|
||||||
|
private int valueH;
|
||||||
|
private int valueI;
|
||||||
|
private int valueJ;
|
||||||
|
private int valueK;
|
||||||
|
|
||||||
|
|
||||||
|
public final int finalValueM;
|
||||||
|
@XmlCaseSensitive
|
||||||
|
public final int finalValueN;
|
||||||
|
@XmlCaseSensitive(true)
|
||||||
|
public final int finalValueO;
|
||||||
|
@XmlCaseSensitive(false)
|
||||||
|
public final int finalValueP;
|
||||||
|
|
||||||
|
// special case for bijectivity with records
|
||||||
|
public final int finalValueQ;
|
||||||
|
public final int finalValueR;
|
||||||
|
public final int finalValueS;
|
||||||
|
public final int finalValueT;
|
||||||
|
|
||||||
|
private final int pFinalValueQ;
|
||||||
|
private final int pFinalValueR;
|
||||||
|
private final int pFinalValueS;
|
||||||
|
private final int pFinalValueT;
|
||||||
|
|
||||||
|
@XmlName({"finalValueM", "finalValueN", "finalValueO", "finalValueP",
|
||||||
|
"finalValueQ", "finalValueR", "finalValueS", "finalValueT",
|
||||||
|
"pFinalValueQ", "pFinalValueR", "pFinalValueS", "pFinalValueT"})
|
||||||
|
public TestNodeObject(
|
||||||
|
final int finalValueM, final int finalValueN, final int finalValueO, final int finalValueP,
|
||||||
|
final int finalValueQ, @XmlCaseSensitive final int finalValueR, @XmlCaseSensitive(true) final int finalValueS, @XmlCaseSensitive(false) final int finalValueT,
|
||||||
|
final int pFinalValueQ, final int pFinalValueR, final int pFinalValueS, final int pFinalValueT) {
|
||||||
|
this.finalValueM = finalValueM;
|
||||||
|
this.finalValueN = finalValueN;
|
||||||
|
this.finalValueO = finalValueO;
|
||||||
|
this.finalValueP = finalValueP;
|
||||||
|
this.finalValueQ = finalValueQ;
|
||||||
|
this.finalValueR = finalValueR;
|
||||||
|
this.finalValueS = finalValueS;
|
||||||
|
this.finalValueT = finalValueT;
|
||||||
|
this.pFinalValueQ = pFinalValueQ;
|
||||||
|
this.pFinalValueR = pFinalValueR;
|
||||||
|
this.pFinalValueS = pFinalValueS;
|
||||||
|
this.pFinalValueT = pFinalValueT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getValueE() {
|
||||||
|
return this.valueE;
|
||||||
|
}
|
||||||
|
public void setValueE(final int valueE) {
|
||||||
|
this.valueE = valueE;
|
||||||
|
}
|
||||||
|
@XmlCaseSensitive
|
||||||
|
public int getValueF() {
|
||||||
|
return this.valueF;
|
||||||
|
}
|
||||||
|
public void setValueF(final int valueF) {
|
||||||
|
this.valueF = valueF;
|
||||||
|
}
|
||||||
|
public int getValueG() {
|
||||||
|
return this.valueG;
|
||||||
|
}
|
||||||
|
@XmlCaseSensitive
|
||||||
|
public void setValueG(final int valueG) {
|
||||||
|
this.valueG = valueG;
|
||||||
|
}
|
||||||
|
@XmlCaseSensitive(true)
|
||||||
|
public int getValueH() {
|
||||||
|
return this.valueH;
|
||||||
|
}
|
||||||
|
public void setValueH(final int valueH) {
|
||||||
|
this.valueH = valueH;
|
||||||
|
}
|
||||||
|
public int getValueI() {
|
||||||
|
return this.valueI;
|
||||||
|
}
|
||||||
|
@XmlCaseSensitive(true)
|
||||||
|
public void setValueI(final int valueI) {
|
||||||
|
this.valueI = valueI;
|
||||||
|
}
|
||||||
|
@XmlCaseSensitive(false)
|
||||||
|
public int getValueJ() {
|
||||||
|
return this.valueJ;
|
||||||
|
}
|
||||||
|
public void setValueJ(final int valueJ) {
|
||||||
|
this.valueJ = valueJ;
|
||||||
|
}
|
||||||
|
public int getValueK() {
|
||||||
|
return this.valueK;
|
||||||
|
}
|
||||||
|
@XmlCaseSensitive(false)
|
||||||
|
public void setValueK(final int valueK) {
|
||||||
|
this.valueK = valueK;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPFinalValueQ() {
|
||||||
|
return this.pFinalValueQ;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlCaseSensitive
|
||||||
|
public int getPFinalValueR() {
|
||||||
|
return this.pFinalValueR;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlCaseSensitive(true)
|
||||||
|
public int getPFinalValueS() {
|
||||||
|
return this.pFinalValueS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlCaseSensitive(false)
|
||||||
|
public int getPFinalValueT() {
|
||||||
|
return this.pFinalValueT;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void testDefaultAttribute() {
|
||||||
|
TestNodeObject elem = new TestNodeObject(321,654,987,159,267,264,1524,182445, -552, -965, -98885, -8754);
|
||||||
|
elem.valueA = 55;
|
||||||
|
elem.valueB = 78;
|
||||||
|
elem.valueC = 51;
|
||||||
|
elem.valueD = 24;
|
||||||
|
elem.setValueE(651);
|
||||||
|
elem.setValueF(654);
|
||||||
|
elem.setValueG(8552);
|
||||||
|
elem.setValueH(9531);
|
||||||
|
elem.setValueI(87465);
|
||||||
|
elem.setValueJ(8247);
|
||||||
|
elem.setValueK(885522);
|
||||||
|
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionObject.NODE_NAME, builder));
|
||||||
|
String dataTest = builder.toString();
|
||||||
|
Log.warning("data generated: " + dataTest);
|
||||||
|
Assertions.assertEquals("<elem finalValueM=\"321\" finalValueN=\"654\" finalValueO=\"987\" finalValueQ=\"267\" finalValueR=\"264\" finalValueS=\"1524\" pFinalValueQ=\"-552\" pFinalValueR=\"-965\" pFinalValueS=\"-98885\" valueA=\"55\" valueB=\"78\" valueC=\"51\" valueE=\"651\" valueF=\"654\" valueG=\"8552\" valueH=\"9531\" valueI=\"87465\">\n"
|
||||||
|
+ " <finalValueP>159</finalValueP>\n"
|
||||||
|
+ " <finalValueT>182445</finalValueT>\n"
|
||||||
|
+ " <pFinalValueT>-8754</pFinalValueT>\n"
|
||||||
|
+ " <valueD>24</valueD>\n"
|
||||||
|
+ " <valueJ>8247</valueJ>\n"
|
||||||
|
+ " <valueK>885522</valueK>\n"
|
||||||
|
+ "</elem>", dataTest);
|
||||||
|
|
||||||
|
final TestNodeObject root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeObject.class, ExmlTestIntrospectionObject.NODE_NAME));
|
||||||
|
Assertions.assertEquals(55, root.valueA);
|
||||||
|
Assertions.assertEquals(78, root.valueB);
|
||||||
|
Assertions.assertEquals(51, root.valueC);
|
||||||
|
Assertions.assertEquals(24, root.valueD);
|
||||||
|
Assertions.assertEquals(651, root.getValueE());
|
||||||
|
Assertions.assertEquals(654, root.getValueF());
|
||||||
|
Assertions.assertEquals(8552, root.getValueG());
|
||||||
|
Assertions.assertEquals(9531, root.getValueH());
|
||||||
|
Assertions.assertEquals(87465, root.getValueI());
|
||||||
|
Assertions.assertEquals(8247, root.getValueJ());
|
||||||
|
Assertions.assertEquals(885522, root.getValueK());
|
||||||
|
Assertions.assertEquals(321, root.finalValueM);
|
||||||
|
Assertions.assertEquals(654, root.finalValueN);
|
||||||
|
Assertions.assertEquals(987, root.finalValueO);
|
||||||
|
Assertions.assertEquals(159, root.finalValueP);
|
||||||
|
Assertions.assertEquals(267, root.finalValueQ);
|
||||||
|
Assertions.assertEquals(264, root.finalValueR);
|
||||||
|
Assertions.assertEquals(1524, root.finalValueS);
|
||||||
|
Assertions.assertEquals(182445, root.finalValueT);
|
||||||
|
Assertions.assertEquals(-552, root.getPFinalValueQ());
|
||||||
|
Assertions.assertEquals(-965, root.getPFinalValueR());
|
||||||
|
Assertions.assertEquals(-98885, root.getPFinalValueS());
|
||||||
|
Assertions.assertEquals(-8754, root.getPFinalValueT());
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlDefaultCaseSensitive(true)
|
||||||
|
public class TestNodeObjectTrue {
|
||||||
|
public int valueA;
|
||||||
|
@XmlCaseSensitive
|
||||||
|
public int valueB;
|
||||||
|
@XmlCaseSensitive(true)
|
||||||
|
public int valueC;
|
||||||
|
@XmlCaseSensitive(false)
|
||||||
|
public int valueD;
|
||||||
|
|
||||||
|
private int valueE;
|
||||||
|
private int valueF;
|
||||||
|
private int valueG;
|
||||||
|
private int valueH;
|
||||||
|
private int valueI;
|
||||||
|
private int valueJ;
|
||||||
|
private int valueK;
|
||||||
|
|
||||||
|
|
||||||
|
public final int finalValueM;
|
||||||
|
@XmlCaseSensitive
|
||||||
|
public final int finalValueN;
|
||||||
|
@XmlCaseSensitive(true)
|
||||||
|
public final int finalValueO;
|
||||||
|
@XmlCaseSensitive(false)
|
||||||
|
public final int finalValueP;
|
||||||
|
|
||||||
|
// special case for bijectivity with records
|
||||||
|
public final int finalValueQ;
|
||||||
|
public final int finalValueR;
|
||||||
|
public final int finalValueS;
|
||||||
|
public final int finalValueT;
|
||||||
|
|
||||||
|
private final int pFinalValueQ;
|
||||||
|
private final int pFinalValueR;
|
||||||
|
private final int pFinalValueS;
|
||||||
|
private final int pFinalValueT;
|
||||||
|
|
||||||
|
@XmlName({"finalValueM", "finalValueN", "finalValueO", "finalValueP",
|
||||||
|
"finalValueQ", "finalValueR", "finalValueS", "finalValueT",
|
||||||
|
"pFinalValueQ", "pFinalValueR", "pFinalValueS", "pFinalValueT"})
|
||||||
|
public TestNodeObjectTrue(
|
||||||
|
final int finalValueM, final int finalValueN, final int finalValueO, final int finalValueP,
|
||||||
|
final int finalValueQ, @XmlCaseSensitive final int finalValueR, @XmlCaseSensitive(true) final int finalValueS, @XmlCaseSensitive(false) final int finalValueT,
|
||||||
|
final int pFinalValueQ, final int pFinalValueR, final int pFinalValueS, final int pFinalValueT) {
|
||||||
|
this.finalValueM = finalValueM;
|
||||||
|
this.finalValueN = finalValueN;
|
||||||
|
this.finalValueO = finalValueO;
|
||||||
|
this.finalValueP = finalValueP;
|
||||||
|
this.finalValueQ = finalValueQ;
|
||||||
|
this.finalValueR = finalValueR;
|
||||||
|
this.finalValueS = finalValueS;
|
||||||
|
this.finalValueT = finalValueT;
|
||||||
|
this.pFinalValueQ = pFinalValueQ;
|
||||||
|
this.pFinalValueR = pFinalValueR;
|
||||||
|
this.pFinalValueS = pFinalValueS;
|
||||||
|
this.pFinalValueT = pFinalValueT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getValueE() {
|
||||||
|
return this.valueE;
|
||||||
|
}
|
||||||
|
public void setValueE(final int valueE) {
|
||||||
|
this.valueE = valueE;
|
||||||
|
}
|
||||||
|
@XmlCaseSensitive
|
||||||
|
public int getValueF() {
|
||||||
|
return this.valueF;
|
||||||
|
}
|
||||||
|
public void setValueF(final int valueF) {
|
||||||
|
this.valueF = valueF;
|
||||||
|
}
|
||||||
|
public int getValueG() {
|
||||||
|
return this.valueG;
|
||||||
|
}
|
||||||
|
@XmlCaseSensitive
|
||||||
|
public void setValueG(final int valueG) {
|
||||||
|
this.valueG = valueG;
|
||||||
|
}
|
||||||
|
@XmlCaseSensitive(true)
|
||||||
|
public int getValueH() {
|
||||||
|
return this.valueH;
|
||||||
|
}
|
||||||
|
public void setValueH(final int valueH) {
|
||||||
|
this.valueH = valueH;
|
||||||
|
}
|
||||||
|
public int getValueI() {
|
||||||
|
return this.valueI;
|
||||||
|
}
|
||||||
|
@XmlCaseSensitive(true)
|
||||||
|
public void setValueI(final int valueI) {
|
||||||
|
this.valueI = valueI;
|
||||||
|
}
|
||||||
|
@XmlCaseSensitive(false)
|
||||||
|
public int getValueJ() {
|
||||||
|
return this.valueJ;
|
||||||
|
}
|
||||||
|
public void setValueJ(final int valueJ) {
|
||||||
|
this.valueJ = valueJ;
|
||||||
|
}
|
||||||
|
public int getValueK() {
|
||||||
|
return this.valueK;
|
||||||
|
}
|
||||||
|
@XmlCaseSensitive(false)
|
||||||
|
public void setValueK(final int valueK) {
|
||||||
|
this.valueK = valueK;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPFinalValueQ() {
|
||||||
|
return this.pFinalValueQ;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlCaseSensitive
|
||||||
|
public int getPFinalValueR() {
|
||||||
|
return this.pFinalValueR;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlCaseSensitive(true)
|
||||||
|
public int getPFinalValueS() {
|
||||||
|
return this.pFinalValueS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlCaseSensitive(false)
|
||||||
|
public int getPFinalValueT() {
|
||||||
|
return this.pFinalValueT;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void testDefaultAttributeTrue() {
|
||||||
|
TestNodeObjectTrue elem = new TestNodeObjectTrue(321,654,987,159,267,264,1524,182445, -552, -965, -98885, -8754);
|
||||||
|
elem.valueA = 55;
|
||||||
|
elem.valueB = 78;
|
||||||
|
elem.valueC = 51;
|
||||||
|
elem.valueD = 24;
|
||||||
|
elem.setValueE(651);
|
||||||
|
elem.setValueF(654);
|
||||||
|
elem.setValueG(8552);
|
||||||
|
elem.setValueH(9531);
|
||||||
|
elem.setValueI(87465);
|
||||||
|
elem.setValueJ(8247);
|
||||||
|
elem.setValueK(885522);
|
||||||
|
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionObject.NODE_NAME, builder));
|
||||||
|
String dataTest = builder.toString();
|
||||||
|
Log.warning("data generated: " + builder.toString());
|
||||||
|
Assertions.assertEquals("<elem finalValueM=\"321\" finalValueN=\"654\" finalValueO=\"987\" finalValueQ=\"267\" finalValueR=\"264\" finalValueS=\"1524\" pFinalValueQ=\"-552\" pFinalValueR=\"-965\" pFinalValueS=\"-98885\" valueA=\"55\" valueB=\"78\" valueC=\"51\" valueE=\"651\" valueF=\"654\" valueG=\"8552\" valueH=\"9531\" valueI=\"87465\">\n"
|
||||||
|
+ " <finalValueP>159</finalValueP>\n"
|
||||||
|
+ " <finalValueT>182445</finalValueT>\n"
|
||||||
|
+ " <pFinalValueT>-8754</pFinalValueT>\n"
|
||||||
|
+ " <valueD>24</valueD>\n"
|
||||||
|
+ " <valueJ>8247</valueJ>\n"
|
||||||
|
+ " <valueK>885522</valueK>\n"
|
||||||
|
+ "</elem>", dataTest);
|
||||||
|
|
||||||
|
final TestNodeObjectTrue root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeObjectTrue.class, ExmlTestIntrospectionObject.NODE_NAME));
|
||||||
|
Assertions.assertEquals(55, root.valueA);
|
||||||
|
Assertions.assertEquals(78, root.valueB);
|
||||||
|
Assertions.assertEquals(51, root.valueC);
|
||||||
|
Assertions.assertEquals(24, root.valueD);
|
||||||
|
Assertions.assertEquals(651, root.getValueE());
|
||||||
|
Assertions.assertEquals(654, root.getValueF());
|
||||||
|
Assertions.assertEquals(8552, root.getValueG());
|
||||||
|
Assertions.assertEquals(9531, root.getValueH());
|
||||||
|
Assertions.assertEquals(87465, root.getValueI());
|
||||||
|
Assertions.assertEquals(8247, root.getValueJ());
|
||||||
|
Assertions.assertEquals(885522, root.getValueK());
|
||||||
|
Assertions.assertEquals(321, root.finalValueM);
|
||||||
|
Assertions.assertEquals(654, root.finalValueN);
|
||||||
|
Assertions.assertEquals(987, root.finalValueO);
|
||||||
|
Assertions.assertEquals(159, root.finalValueP);
|
||||||
|
Assertions.assertEquals(267, root.finalValueQ);
|
||||||
|
Assertions.assertEquals(264, root.finalValueR);
|
||||||
|
Assertions.assertEquals(1524, root.finalValueS);
|
||||||
|
Assertions.assertEquals(182445, root.finalValueT);
|
||||||
|
Assertions.assertEquals(-552, root.getPFinalValueQ());
|
||||||
|
Assertions.assertEquals(-965, root.getPFinalValueR());
|
||||||
|
Assertions.assertEquals(-98885, root.getPFinalValueS());
|
||||||
|
Assertions.assertEquals(-8754, root.getPFinalValueT());
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlDefaultCaseSensitive(false)
|
||||||
|
public class TestNodeObjectFalse {
|
||||||
|
public int valueA;
|
||||||
|
@XmlCaseSensitive
|
||||||
|
public int valueB;
|
||||||
|
@XmlCaseSensitive(true)
|
||||||
|
public int valueC;
|
||||||
|
@XmlCaseSensitive(false)
|
||||||
|
public int valueD;
|
||||||
|
|
||||||
|
private int valueE;
|
||||||
|
private int valueF;
|
||||||
|
private int valueG;
|
||||||
|
private int valueH;
|
||||||
|
private int valueI;
|
||||||
|
private int valueJ;
|
||||||
|
private int valueK;
|
||||||
|
|
||||||
|
public final int finalValueM;
|
||||||
|
@XmlCaseSensitive
|
||||||
|
public final int finalValueN;
|
||||||
|
@XmlCaseSensitive(true)
|
||||||
|
public final int finalValueO;
|
||||||
|
@XmlCaseSensitive(false)
|
||||||
|
public final int finalValueP;
|
||||||
|
|
||||||
|
// special case for bijectivity with records
|
||||||
|
public final int finalValueQ;
|
||||||
|
public final int finalValueR;
|
||||||
|
public final int finalValueS;
|
||||||
|
public final int finalValueT;
|
||||||
|
|
||||||
|
private final int pFinalValueQ;
|
||||||
|
private final int pFinalValueR;
|
||||||
|
private final int pFinalValueS;
|
||||||
|
private final int pFinalValueT;
|
||||||
|
|
||||||
|
@XmlName({"finalValueM", "finalValueN", "finalValueO", "finalValueP",
|
||||||
|
"finalValueQ", "finalValueR", "finalValueS", "finalValueT",
|
||||||
|
"pFinalValueQ", "pFinalValueR", "pFinalValueS", "pFinalValueT"})
|
||||||
|
public TestNodeObjectFalse(
|
||||||
|
final int finalValueM, final int finalValueN, final int finalValueO, final int finalValueP,
|
||||||
|
final int finalValueQ, @XmlCaseSensitive final int finalValueR, @XmlCaseSensitive(true) final int finalValueS, @XmlCaseSensitive(false) final int finalValueT,
|
||||||
|
final int pFinalValueQ, final int pFinalValueR, final int pFinalValueS, final int pFinalValueT) {
|
||||||
|
this.finalValueM = finalValueM;
|
||||||
|
this.finalValueN = finalValueN;
|
||||||
|
this.finalValueO = finalValueO;
|
||||||
|
this.finalValueP = finalValueP;
|
||||||
|
this.finalValueQ = finalValueQ;
|
||||||
|
this.finalValueR = finalValueR;
|
||||||
|
this.finalValueS = finalValueS;
|
||||||
|
this.finalValueT = finalValueT;
|
||||||
|
this.pFinalValueQ = pFinalValueQ;
|
||||||
|
this.pFinalValueR = pFinalValueR;
|
||||||
|
this.pFinalValueS = pFinalValueS;
|
||||||
|
this.pFinalValueT = pFinalValueT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getValueE() {
|
||||||
|
return this.valueE;
|
||||||
|
}
|
||||||
|
public void setValueE(final int valueE) {
|
||||||
|
this.valueE = valueE;
|
||||||
|
}
|
||||||
|
@XmlCaseSensitive
|
||||||
|
public int getValueF() {
|
||||||
|
return this.valueF;
|
||||||
|
}
|
||||||
|
public void setValueF(final int valueF) {
|
||||||
|
this.valueF = valueF;
|
||||||
|
}
|
||||||
|
public int getValueG() {
|
||||||
|
return this.valueG;
|
||||||
|
}
|
||||||
|
@XmlCaseSensitive
|
||||||
|
public void setValueG(final int valueG) {
|
||||||
|
this.valueG = valueG;
|
||||||
|
}
|
||||||
|
@XmlCaseSensitive(true)
|
||||||
|
public int getValueH() {
|
||||||
|
return this.valueH;
|
||||||
|
}
|
||||||
|
public void setValueH(final int valueH) {
|
||||||
|
this.valueH = valueH;
|
||||||
|
}
|
||||||
|
public int getValueI() {
|
||||||
|
return this.valueI;
|
||||||
|
}
|
||||||
|
@XmlCaseSensitive(true)
|
||||||
|
public void setValueI(final int valueI) {
|
||||||
|
this.valueI = valueI;
|
||||||
|
}
|
||||||
|
@XmlCaseSensitive(false)
|
||||||
|
public int getValueJ() {
|
||||||
|
return this.valueJ;
|
||||||
|
}
|
||||||
|
public void setValueJ(final int valueJ) {
|
||||||
|
this.valueJ = valueJ;
|
||||||
|
}
|
||||||
|
public int getValueK() {
|
||||||
|
return this.valueK;
|
||||||
|
}
|
||||||
|
@XmlCaseSensitive(false)
|
||||||
|
public void setValueK(final int valueK) {
|
||||||
|
this.valueK = valueK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int getPFinalValueQ() {
|
||||||
|
return this.pFinalValueQ;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlCaseSensitive
|
||||||
|
public int getPFinalValueR() {
|
||||||
|
return this.pFinalValueR;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlCaseSensitive(true)
|
||||||
|
public int getPFinalValueS() {
|
||||||
|
return this.pFinalValueS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlCaseSensitive(false)
|
||||||
|
public int getPFinalValueT() {
|
||||||
|
return this.pFinalValueT;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void testDefaultAttributeFalse() {
|
||||||
|
TestNodeObjectFalse elem = new TestNodeObjectFalse(321,654,987,159,267,264,1524,182445, -552, -965, -98885, -8754);
|
||||||
|
elem.valueA = 55;
|
||||||
|
elem.valueB = 78;
|
||||||
|
elem.valueC = 51;
|
||||||
|
elem.valueD = 24;
|
||||||
|
elem.setValueE(651);
|
||||||
|
elem.setValueF(654);
|
||||||
|
elem.setValueG(8552);
|
||||||
|
elem.setValueH(9531);
|
||||||
|
elem.setValueI(87465);
|
||||||
|
elem.setValueJ(8247);
|
||||||
|
elem.setValueK(885522);
|
||||||
|
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionObject.NODE_NAME, builder));
|
||||||
|
String dataTest = builder.toString();
|
||||||
|
Log.warning("data generated: " + builder.toString());
|
||||||
|
Assertions.assertEquals("<elem finalValueN=\"654\" finalValueO=\"987\" finalValueR=\"264\" finalValueS=\"1524\" pFinalValueR=\"-965\" pFinalValueS=\"-98885\" valueB=\"78\" valueC=\"51\" valueF=\"654\" valueG=\"8552\" valueH=\"9531\" valueI=\"87465\">\n"
|
||||||
|
+ " <finalValueM>321</finalValueM>\n"
|
||||||
|
+ " <finalValueP>159</finalValueP>\n"
|
||||||
|
+ " <finalValueQ>267</finalValueQ>\n"
|
||||||
|
+ " <finalValueT>182445</finalValueT>\n"
|
||||||
|
+ " <pFinalValueQ>-552</pFinalValueQ>\n"
|
||||||
|
+ " <pFinalValueT>-8754</pFinalValueT>\n"
|
||||||
|
+ " <valueA>55</valueA>\n"
|
||||||
|
+ " <valueD>24</valueD>\n"
|
||||||
|
+ " <valueE>651</valueE>\n"
|
||||||
|
+ " <valueJ>8247</valueJ>\n"
|
||||||
|
+ " <valueK>885522</valueK>\n"
|
||||||
|
+ "</elem>", dataTest);
|
||||||
|
|
||||||
|
final TestNodeObjectFalse root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeObjectFalse.class, ExmlTestIntrospectionObject.NODE_NAME));
|
||||||
|
Assertions.assertEquals(55, root.valueA);
|
||||||
|
Assertions.assertEquals(78, root.valueB);
|
||||||
|
Assertions.assertEquals(51, root.valueC);
|
||||||
|
Assertions.assertEquals(24, root.valueD);
|
||||||
|
Assertions.assertEquals(651, root.getValueE());
|
||||||
|
Assertions.assertEquals(654, root.getValueF());
|
||||||
|
Assertions.assertEquals(8552, root.getValueG());
|
||||||
|
Assertions.assertEquals(9531, root.getValueH());
|
||||||
|
Assertions.assertEquals(87465, root.getValueI());
|
||||||
|
Assertions.assertEquals(8247, root.getValueJ());
|
||||||
|
Assertions.assertEquals(885522, root.getValueK());
|
||||||
|
Assertions.assertEquals(321, root.finalValueM);
|
||||||
|
Assertions.assertEquals(654, root.finalValueN);
|
||||||
|
Assertions.assertEquals(987, root.finalValueO);
|
||||||
|
Assertions.assertEquals(159, root.finalValueP);
|
||||||
|
Assertions.assertEquals(267, root.finalValueQ);
|
||||||
|
Assertions.assertEquals(264, root.finalValueR);
|
||||||
|
Assertions.assertEquals(1524, root.finalValueS);
|
||||||
|
Assertions.assertEquals(182445, root.finalValueT);
|
||||||
|
Assertions.assertEquals(-552, root.getPFinalValueQ());
|
||||||
|
Assertions.assertEquals(-965, root.getPFinalValueR());
|
||||||
|
Assertions.assertEquals(-98885, root.getPFinalValueS());
|
||||||
|
Assertions.assertEquals(-8754, root.getPFinalValueT());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,585 @@
|
|||||||
|
/** @file
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2021, Edouard DUPIN, all right reserved
|
||||||
|
* @license MPL v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
package test.atriasoft.exml;
|
||||||
|
|
||||||
|
|
||||||
|
import org.atriasoft.exml.Exml;
|
||||||
|
import org.atriasoft.exml.annotation.XmlAttribute;
|
||||||
|
import org.atriasoft.exml.annotation.XmlCaseSensitive;
|
||||||
|
import org.atriasoft.exml.annotation.XmlDefaultAttibute;
|
||||||
|
import org.atriasoft.exml.annotation.XmlDefaultCaseSensitive;
|
||||||
|
import org.atriasoft.exml.annotation.XmlDefaultOptional;
|
||||||
|
import org.atriasoft.exml.annotation.XmlName;
|
||||||
|
import org.atriasoft.exml.annotation.XmlOptional;
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
public class ExmlTestIntrospectionDecoratorOptionnal {
|
||||||
|
static final String NODE_NAME = "elem";
|
||||||
|
@BeforeAll
|
||||||
|
public static void beforeClass() {
|
||||||
|
Log.warning("================================================================");
|
||||||
|
}
|
||||||
|
// ************************************************************
|
||||||
|
// ** Attribute
|
||||||
|
// ************************************************************
|
||||||
|
|
||||||
|
@XmlDefaultOptional
|
||||||
|
public class TestNodeObject {
|
||||||
|
|
||||||
|
public int valueA;
|
||||||
|
@XmlOptional
|
||||||
|
public int valueB;
|
||||||
|
@XmlOptional(true)
|
||||||
|
public int valueC;
|
||||||
|
@XmlOptional(false)
|
||||||
|
public int valueD;
|
||||||
|
|
||||||
|
private int valueE;
|
||||||
|
private int valueF;
|
||||||
|
private int valueG;
|
||||||
|
private int valueH;
|
||||||
|
private int valueI;
|
||||||
|
private int valueJ;
|
||||||
|
private int valueK;
|
||||||
|
|
||||||
|
|
||||||
|
public final int finalValueM;
|
||||||
|
@XmlOptional
|
||||||
|
public final int finalValueN;
|
||||||
|
@XmlOptional(true)
|
||||||
|
public final int finalValueO;
|
||||||
|
@XmlOptional(false)
|
||||||
|
public final int finalValueP;
|
||||||
|
|
||||||
|
// special case for bijectivity with records
|
||||||
|
public final int finalValueQ;
|
||||||
|
public final int finalValueR;
|
||||||
|
public final int finalValueS;
|
||||||
|
public final int finalValueT;
|
||||||
|
|
||||||
|
private final int pFinalValueQ;
|
||||||
|
private final int pFinalValueR;
|
||||||
|
private final int pFinalValueS;
|
||||||
|
private final int pFinalValueT;
|
||||||
|
|
||||||
|
@XmlName({"finalValueM", "finalValueN", "finalValueO", "finalValueP",
|
||||||
|
"finalValueQ", "finalValueR", "finalValueS", "finalValueT",
|
||||||
|
"pFinalValueQ", "pFinalValueR", "pFinalValueS", "pFinalValueT"})
|
||||||
|
public TestNodeObject(
|
||||||
|
final int finalValueM, final int finalValueN, final int finalValueO, final int finalValueP,
|
||||||
|
final int finalValueQ, @XmlOptional final int finalValueR, @XmlOptional(true) final int finalValueS, @XmlOptional(false) final int finalValueT,
|
||||||
|
final int pFinalValueQ, final int pFinalValueR, final int pFinalValueS, final int pFinalValueT) {
|
||||||
|
this.finalValueM = finalValueM;
|
||||||
|
this.finalValueN = finalValueN;
|
||||||
|
this.finalValueO = finalValueO;
|
||||||
|
this.finalValueP = finalValueP;
|
||||||
|
this.finalValueQ = finalValueQ;
|
||||||
|
this.finalValueR = finalValueR;
|
||||||
|
this.finalValueS = finalValueS;
|
||||||
|
this.finalValueT = finalValueT;
|
||||||
|
this.pFinalValueQ = pFinalValueQ;
|
||||||
|
this.pFinalValueR = pFinalValueR;
|
||||||
|
this.pFinalValueS = pFinalValueS;
|
||||||
|
this.pFinalValueT = pFinalValueT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getValueE() {
|
||||||
|
return this.valueE;
|
||||||
|
}
|
||||||
|
public void setValueE(final int valueE) {
|
||||||
|
this.valueE = valueE;
|
||||||
|
}
|
||||||
|
@XmlOptional
|
||||||
|
public int getValueF() {
|
||||||
|
return this.valueF;
|
||||||
|
}
|
||||||
|
public void setValueF(final int valueF) {
|
||||||
|
this.valueF = valueF;
|
||||||
|
}
|
||||||
|
public int getValueG() {
|
||||||
|
return this.valueG;
|
||||||
|
}
|
||||||
|
@XmlOptional
|
||||||
|
public void setValueG(final int valueG) {
|
||||||
|
this.valueG = valueG;
|
||||||
|
}
|
||||||
|
@XmlOptional(true)
|
||||||
|
public int getValueH() {
|
||||||
|
return this.valueH;
|
||||||
|
}
|
||||||
|
public void setValueH(final int valueH) {
|
||||||
|
this.valueH = valueH;
|
||||||
|
}
|
||||||
|
public int getValueI() {
|
||||||
|
return this.valueI;
|
||||||
|
}
|
||||||
|
@XmlOptional(true)
|
||||||
|
public void setValueI(final int valueI) {
|
||||||
|
this.valueI = valueI;
|
||||||
|
}
|
||||||
|
@XmlOptional(false)
|
||||||
|
public int getValueJ() {
|
||||||
|
return this.valueJ;
|
||||||
|
}
|
||||||
|
public void setValueJ(final int valueJ) {
|
||||||
|
this.valueJ = valueJ;
|
||||||
|
}
|
||||||
|
public int getValueK() {
|
||||||
|
return this.valueK;
|
||||||
|
}
|
||||||
|
@XmlOptional(false)
|
||||||
|
public void setValueK(final int valueK) {
|
||||||
|
this.valueK = valueK;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPFinalValueQ() {
|
||||||
|
return this.pFinalValueQ;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlOptional
|
||||||
|
public int getPFinalValueR() {
|
||||||
|
return this.pFinalValueR;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlOptional(true)
|
||||||
|
public int getPFinalValueS() {
|
||||||
|
return this.pFinalValueS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlOptional(false)
|
||||||
|
public int getPFinalValueT() {
|
||||||
|
return this.pFinalValueT;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void testDefaultAttribute() {
|
||||||
|
TestNodeObject elem = new TestNodeObject(321,654,987,159,267,264,1524,182445, -552, -965, -98885, -8754);
|
||||||
|
elem.valueA = 55;
|
||||||
|
elem.valueB = 78;
|
||||||
|
elem.valueC = 51;
|
||||||
|
elem.valueD = 24;
|
||||||
|
elem.setValueE(651);
|
||||||
|
elem.setValueF(654);
|
||||||
|
elem.setValueG(8552);
|
||||||
|
elem.setValueH(9531);
|
||||||
|
elem.setValueI(87465);
|
||||||
|
elem.setValueJ(8247);
|
||||||
|
elem.setValueK(885522);
|
||||||
|
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionObject.NODE_NAME, builder));
|
||||||
|
String dataTest = builder.toString();
|
||||||
|
Log.warning("data generated: " + dataTest);
|
||||||
|
Assertions.assertEquals("<elem finalValueM=\"321\" finalValueN=\"654\" finalValueO=\"987\" finalValueQ=\"267\" finalValueR=\"264\" finalValueS=\"1524\" pFinalValueQ=\"-552\" pFinalValueR=\"-965\" pFinalValueS=\"-98885\" valueA=\"55\" valueB=\"78\" valueC=\"51\" valueE=\"651\" valueF=\"654\" valueG=\"8552\" valueH=\"9531\" valueI=\"87465\">\n"
|
||||||
|
+ " <finalValueP>159</finalValueP>\n"
|
||||||
|
+ " <finalValueT>182445</finalValueT>\n"
|
||||||
|
+ " <pFinalValueT>-8754</pFinalValueT>\n"
|
||||||
|
+ " <valueD>24</valueD>\n"
|
||||||
|
+ " <valueJ>8247</valueJ>\n"
|
||||||
|
+ " <valueK>885522</valueK>\n"
|
||||||
|
+ "</elem>", dataTest);
|
||||||
|
|
||||||
|
final TestNodeObject root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeObject.class, ExmlTestIntrospectionObject.NODE_NAME));
|
||||||
|
Assertions.assertEquals(55, root.valueA);
|
||||||
|
Assertions.assertEquals(78, root.valueB);
|
||||||
|
Assertions.assertEquals(51, root.valueC);
|
||||||
|
Assertions.assertEquals(24, root.valueD);
|
||||||
|
Assertions.assertEquals(651, root.getValueE());
|
||||||
|
Assertions.assertEquals(654, root.getValueF());
|
||||||
|
Assertions.assertEquals(8552, root.getValueG());
|
||||||
|
Assertions.assertEquals(9531, root.getValueH());
|
||||||
|
Assertions.assertEquals(87465, root.getValueI());
|
||||||
|
Assertions.assertEquals(8247, root.getValueJ());
|
||||||
|
Assertions.assertEquals(885522, root.getValueK());
|
||||||
|
Assertions.assertEquals(321, root.finalValueM);
|
||||||
|
Assertions.assertEquals(654, root.finalValueN);
|
||||||
|
Assertions.assertEquals(987, root.finalValueO);
|
||||||
|
Assertions.assertEquals(159, root.finalValueP);
|
||||||
|
Assertions.assertEquals(267, root.finalValueQ);
|
||||||
|
Assertions.assertEquals(264, root.finalValueR);
|
||||||
|
Assertions.assertEquals(1524, root.finalValueS);
|
||||||
|
Assertions.assertEquals(182445, root.finalValueT);
|
||||||
|
Assertions.assertEquals(-552, root.getPFinalValueQ());
|
||||||
|
Assertions.assertEquals(-965, root.getPFinalValueR());
|
||||||
|
Assertions.assertEquals(-98885, root.getPFinalValueS());
|
||||||
|
Assertions.assertEquals(-8754, root.getPFinalValueT());
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlDefaultOptional(true)
|
||||||
|
public class TestNodeObjectTrue {
|
||||||
|
public int valueA;
|
||||||
|
@XmlOptional
|
||||||
|
public int valueB;
|
||||||
|
@XmlOptional(true)
|
||||||
|
public int valueC;
|
||||||
|
@XmlOptional(false)
|
||||||
|
public int valueD;
|
||||||
|
|
||||||
|
private int valueE;
|
||||||
|
private int valueF;
|
||||||
|
private int valueG;
|
||||||
|
private int valueH;
|
||||||
|
private int valueI;
|
||||||
|
private int valueJ;
|
||||||
|
private int valueK;
|
||||||
|
|
||||||
|
|
||||||
|
public final int finalValueM;
|
||||||
|
@XmlOptional
|
||||||
|
public final int finalValueN;
|
||||||
|
@XmlOptional(true)
|
||||||
|
public final int finalValueO;
|
||||||
|
@XmlOptional(false)
|
||||||
|
public final int finalValueP;
|
||||||
|
|
||||||
|
// special case for bijectivity with records
|
||||||
|
public final int finalValueQ;
|
||||||
|
public final int finalValueR;
|
||||||
|
public final int finalValueS;
|
||||||
|
public final int finalValueT;
|
||||||
|
|
||||||
|
private final int pFinalValueQ;
|
||||||
|
private final int pFinalValueR;
|
||||||
|
private final int pFinalValueS;
|
||||||
|
private final int pFinalValueT;
|
||||||
|
|
||||||
|
@XmlName({"finalValueM", "finalValueN", "finalValueO", "finalValueP",
|
||||||
|
"finalValueQ", "finalValueR", "finalValueS", "finalValueT",
|
||||||
|
"pFinalValueQ", "pFinalValueR", "pFinalValueS", "pFinalValueT"})
|
||||||
|
public TestNodeObjectTrue(
|
||||||
|
final int finalValueM, final int finalValueN, final int finalValueO, final int finalValueP,
|
||||||
|
final int finalValueQ, @XmlOptional final int finalValueR, @XmlOptional(true) final int finalValueS, @XmlOptional(false) final int finalValueT,
|
||||||
|
final int pFinalValueQ, final int pFinalValueR, final int pFinalValueS, final int pFinalValueT) {
|
||||||
|
this.finalValueM = finalValueM;
|
||||||
|
this.finalValueN = finalValueN;
|
||||||
|
this.finalValueO = finalValueO;
|
||||||
|
this.finalValueP = finalValueP;
|
||||||
|
this.finalValueQ = finalValueQ;
|
||||||
|
this.finalValueR = finalValueR;
|
||||||
|
this.finalValueS = finalValueS;
|
||||||
|
this.finalValueT = finalValueT;
|
||||||
|
this.pFinalValueQ = pFinalValueQ;
|
||||||
|
this.pFinalValueR = pFinalValueR;
|
||||||
|
this.pFinalValueS = pFinalValueS;
|
||||||
|
this.pFinalValueT = pFinalValueT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getValueE() {
|
||||||
|
return this.valueE;
|
||||||
|
}
|
||||||
|
public void setValueE(final int valueE) {
|
||||||
|
this.valueE = valueE;
|
||||||
|
}
|
||||||
|
@XmlOptional
|
||||||
|
public int getValueF() {
|
||||||
|
return this.valueF;
|
||||||
|
}
|
||||||
|
public void setValueF(final int valueF) {
|
||||||
|
this.valueF = valueF;
|
||||||
|
}
|
||||||
|
public int getValueG() {
|
||||||
|
return this.valueG;
|
||||||
|
}
|
||||||
|
@XmlOptional
|
||||||
|
public void setValueG(final int valueG) {
|
||||||
|
this.valueG = valueG;
|
||||||
|
}
|
||||||
|
@XmlOptional(true)
|
||||||
|
public int getValueH() {
|
||||||
|
return this.valueH;
|
||||||
|
}
|
||||||
|
public void setValueH(final int valueH) {
|
||||||
|
this.valueH = valueH;
|
||||||
|
}
|
||||||
|
public int getValueI() {
|
||||||
|
return this.valueI;
|
||||||
|
}
|
||||||
|
@XmlOptional(true)
|
||||||
|
public void setValueI(final int valueI) {
|
||||||
|
this.valueI = valueI;
|
||||||
|
}
|
||||||
|
@XmlOptional(false)
|
||||||
|
public int getValueJ() {
|
||||||
|
return this.valueJ;
|
||||||
|
}
|
||||||
|
public void setValueJ(final int valueJ) {
|
||||||
|
this.valueJ = valueJ;
|
||||||
|
}
|
||||||
|
public int getValueK() {
|
||||||
|
return this.valueK;
|
||||||
|
}
|
||||||
|
@XmlOptional(false)
|
||||||
|
public void setValueK(final int valueK) {
|
||||||
|
this.valueK = valueK;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPFinalValueQ() {
|
||||||
|
return this.pFinalValueQ;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlOptional
|
||||||
|
public int getPFinalValueR() {
|
||||||
|
return this.pFinalValueR;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlOptional(true)
|
||||||
|
public int getPFinalValueS() {
|
||||||
|
return this.pFinalValueS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlOptional(false)
|
||||||
|
public int getPFinalValueT() {
|
||||||
|
return this.pFinalValueT;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void testDefaultAttributeTrue() {
|
||||||
|
TestNodeObjectTrue elem = new TestNodeObjectTrue(321,654,987,159,267,264,1524,182445, -552, -965, -98885, -8754);
|
||||||
|
elem.valueA = 55;
|
||||||
|
elem.valueB = 78;
|
||||||
|
elem.valueC = 51;
|
||||||
|
elem.valueD = 24;
|
||||||
|
elem.setValueE(651);
|
||||||
|
elem.setValueF(654);
|
||||||
|
elem.setValueG(8552);
|
||||||
|
elem.setValueH(9531);
|
||||||
|
elem.setValueI(87465);
|
||||||
|
elem.setValueJ(8247);
|
||||||
|
elem.setValueK(885522);
|
||||||
|
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionObject.NODE_NAME, builder));
|
||||||
|
String dataTest = builder.toString();
|
||||||
|
Log.warning("data generated: " + builder.toString());
|
||||||
|
Assertions.assertEquals("<elem finalValueM=\"321\" finalValueN=\"654\" finalValueO=\"987\" finalValueQ=\"267\" finalValueR=\"264\" finalValueS=\"1524\" pFinalValueQ=\"-552\" pFinalValueR=\"-965\" pFinalValueS=\"-98885\" valueA=\"55\" valueB=\"78\" valueC=\"51\" valueE=\"651\" valueF=\"654\" valueG=\"8552\" valueH=\"9531\" valueI=\"87465\">\n"
|
||||||
|
+ " <finalValueP>159</finalValueP>\n"
|
||||||
|
+ " <finalValueT>182445</finalValueT>\n"
|
||||||
|
+ " <pFinalValueT>-8754</pFinalValueT>\n"
|
||||||
|
+ " <valueD>24</valueD>\n"
|
||||||
|
+ " <valueJ>8247</valueJ>\n"
|
||||||
|
+ " <valueK>885522</valueK>\n"
|
||||||
|
+ "</elem>", dataTest);
|
||||||
|
|
||||||
|
final TestNodeObjectTrue root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeObjectTrue.class, ExmlTestIntrospectionObject.NODE_NAME));
|
||||||
|
Assertions.assertEquals(55, root.valueA);
|
||||||
|
Assertions.assertEquals(78, root.valueB);
|
||||||
|
Assertions.assertEquals(51, root.valueC);
|
||||||
|
Assertions.assertEquals(24, root.valueD);
|
||||||
|
Assertions.assertEquals(651, root.getValueE());
|
||||||
|
Assertions.assertEquals(654, root.getValueF());
|
||||||
|
Assertions.assertEquals(8552, root.getValueG());
|
||||||
|
Assertions.assertEquals(9531, root.getValueH());
|
||||||
|
Assertions.assertEquals(87465, root.getValueI());
|
||||||
|
Assertions.assertEquals(8247, root.getValueJ());
|
||||||
|
Assertions.assertEquals(885522, root.getValueK());
|
||||||
|
Assertions.assertEquals(321, root.finalValueM);
|
||||||
|
Assertions.assertEquals(654, root.finalValueN);
|
||||||
|
Assertions.assertEquals(987, root.finalValueO);
|
||||||
|
Assertions.assertEquals(159, root.finalValueP);
|
||||||
|
Assertions.assertEquals(267, root.finalValueQ);
|
||||||
|
Assertions.assertEquals(264, root.finalValueR);
|
||||||
|
Assertions.assertEquals(1524, root.finalValueS);
|
||||||
|
Assertions.assertEquals(182445, root.finalValueT);
|
||||||
|
Assertions.assertEquals(-552, root.getPFinalValueQ());
|
||||||
|
Assertions.assertEquals(-965, root.getPFinalValueR());
|
||||||
|
Assertions.assertEquals(-98885, root.getPFinalValueS());
|
||||||
|
Assertions.assertEquals(-8754, root.getPFinalValueT());
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlDefaultOptional(false)
|
||||||
|
public class TestNodeObjectFalse {
|
||||||
|
public int valueA;
|
||||||
|
@XmlOptional
|
||||||
|
public int valueB;
|
||||||
|
@XmlOptional(true)
|
||||||
|
public int valueC;
|
||||||
|
@XmlOptional(false)
|
||||||
|
public int valueD;
|
||||||
|
|
||||||
|
private int valueE;
|
||||||
|
private int valueF;
|
||||||
|
private int valueG;
|
||||||
|
private int valueH;
|
||||||
|
private int valueI;
|
||||||
|
private int valueJ;
|
||||||
|
private int valueK;
|
||||||
|
|
||||||
|
public final int finalValueM;
|
||||||
|
@XmlOptional
|
||||||
|
public final int finalValueN;
|
||||||
|
@XmlOptional(true)
|
||||||
|
public final int finalValueO;
|
||||||
|
@XmlOptional(false)
|
||||||
|
public final int finalValueP;
|
||||||
|
|
||||||
|
// special case for bijectivity with records
|
||||||
|
public final int finalValueQ;
|
||||||
|
public final int finalValueR;
|
||||||
|
public final int finalValueS;
|
||||||
|
public final int finalValueT;
|
||||||
|
|
||||||
|
private final int pFinalValueQ;
|
||||||
|
private final int pFinalValueR;
|
||||||
|
private final int pFinalValueS;
|
||||||
|
private final int pFinalValueT;
|
||||||
|
|
||||||
|
@XmlName({"finalValueM", "finalValueN", "finalValueO", "finalValueP",
|
||||||
|
"finalValueQ", "finalValueR", "finalValueS", "finalValueT",
|
||||||
|
"pFinalValueQ", "pFinalValueR", "pFinalValueS", "pFinalValueT"})
|
||||||
|
public TestNodeObjectFalse(
|
||||||
|
final int finalValueM, final int finalValueN, final int finalValueO, final int finalValueP,
|
||||||
|
final int finalValueQ, @XmlOptional final int finalValueR, @XmlOptional(true) final int finalValueS, @XmlOptional(false) final int finalValueT,
|
||||||
|
final int pFinalValueQ, final int pFinalValueR, final int pFinalValueS, final int pFinalValueT) {
|
||||||
|
this.finalValueM = finalValueM;
|
||||||
|
this.finalValueN = finalValueN;
|
||||||
|
this.finalValueO = finalValueO;
|
||||||
|
this.finalValueP = finalValueP;
|
||||||
|
this.finalValueQ = finalValueQ;
|
||||||
|
this.finalValueR = finalValueR;
|
||||||
|
this.finalValueS = finalValueS;
|
||||||
|
this.finalValueT = finalValueT;
|
||||||
|
this.pFinalValueQ = pFinalValueQ;
|
||||||
|
this.pFinalValueR = pFinalValueR;
|
||||||
|
this.pFinalValueS = pFinalValueS;
|
||||||
|
this.pFinalValueT = pFinalValueT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getValueE() {
|
||||||
|
return this.valueE;
|
||||||
|
}
|
||||||
|
public void setValueE(final int valueE) {
|
||||||
|
this.valueE = valueE;
|
||||||
|
}
|
||||||
|
@XmlOptional
|
||||||
|
public int getValueF() {
|
||||||
|
return this.valueF;
|
||||||
|
}
|
||||||
|
public void setValueF(final int valueF) {
|
||||||
|
this.valueF = valueF;
|
||||||
|
}
|
||||||
|
public int getValueG() {
|
||||||
|
return this.valueG;
|
||||||
|
}
|
||||||
|
@XmlOptional
|
||||||
|
public void setValueG(final int valueG) {
|
||||||
|
this.valueG = valueG;
|
||||||
|
}
|
||||||
|
@XmlOptional(true)
|
||||||
|
public int getValueH() {
|
||||||
|
return this.valueH;
|
||||||
|
}
|
||||||
|
public void setValueH(final int valueH) {
|
||||||
|
this.valueH = valueH;
|
||||||
|
}
|
||||||
|
public int getValueI() {
|
||||||
|
return this.valueI;
|
||||||
|
}
|
||||||
|
@XmlOptional(true)
|
||||||
|
public void setValueI(final int valueI) {
|
||||||
|
this.valueI = valueI;
|
||||||
|
}
|
||||||
|
@XmlOptional(false)
|
||||||
|
public int getValueJ() {
|
||||||
|
return this.valueJ;
|
||||||
|
}
|
||||||
|
public void setValueJ(final int valueJ) {
|
||||||
|
this.valueJ = valueJ;
|
||||||
|
}
|
||||||
|
public int getValueK() {
|
||||||
|
return this.valueK;
|
||||||
|
}
|
||||||
|
@XmlOptional(false)
|
||||||
|
public void setValueK(final int valueK) {
|
||||||
|
this.valueK = valueK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int getPFinalValueQ() {
|
||||||
|
return this.pFinalValueQ;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlOptional
|
||||||
|
public int getPFinalValueR() {
|
||||||
|
return this.pFinalValueR;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlOptional(true)
|
||||||
|
public int getPFinalValueS() {
|
||||||
|
return this.pFinalValueS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlOptional(false)
|
||||||
|
public int getPFinalValueT() {
|
||||||
|
return this.pFinalValueT;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void testDefaultAttributeFalse() {
|
||||||
|
TestNodeObjectFalse elem = new TestNodeObjectFalse(321,654,987,159,267,264,1524,182445, -552, -965, -98885, -8754);
|
||||||
|
elem.valueA = 55;
|
||||||
|
elem.valueB = 78;
|
||||||
|
elem.valueC = 51;
|
||||||
|
elem.valueD = 24;
|
||||||
|
elem.setValueE(651);
|
||||||
|
elem.setValueF(654);
|
||||||
|
elem.setValueG(8552);
|
||||||
|
elem.setValueH(9531);
|
||||||
|
elem.setValueI(87465);
|
||||||
|
elem.setValueJ(8247);
|
||||||
|
elem.setValueK(885522);
|
||||||
|
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
Assertions.assertDoesNotThrow(() -> Exml.generate(elem, ExmlTestIntrospectionObject.NODE_NAME, builder));
|
||||||
|
String dataTest = builder.toString();
|
||||||
|
Log.warning("data generated: " + builder.toString());
|
||||||
|
Assertions.assertEquals("<elem finalValueN=\"654\" finalValueO=\"987\" finalValueR=\"264\" finalValueS=\"1524\" pFinalValueR=\"-965\" pFinalValueS=\"-98885\" valueB=\"78\" valueC=\"51\" valueF=\"654\" valueG=\"8552\" valueH=\"9531\" valueI=\"87465\">\n"
|
||||||
|
+ " <finalValueM>321</finalValueM>\n"
|
||||||
|
+ " <finalValueP>159</finalValueP>\n"
|
||||||
|
+ " <finalValueQ>267</finalValueQ>\n"
|
||||||
|
+ " <finalValueT>182445</finalValueT>\n"
|
||||||
|
+ " <pFinalValueQ>-552</pFinalValueQ>\n"
|
||||||
|
+ " <pFinalValueT>-8754</pFinalValueT>\n"
|
||||||
|
+ " <valueA>55</valueA>\n"
|
||||||
|
+ " <valueD>24</valueD>\n"
|
||||||
|
+ " <valueE>651</valueE>\n"
|
||||||
|
+ " <valueJ>8247</valueJ>\n"
|
||||||
|
+ " <valueK>885522</valueK>\n"
|
||||||
|
+ "</elem>", dataTest);
|
||||||
|
|
||||||
|
final TestNodeObjectFalse root = Assertions.assertDoesNotThrow(() -> Exml.parseOne(dataTest, TestNodeObjectFalse.class, ExmlTestIntrospectionObject.NODE_NAME));
|
||||||
|
Assertions.assertEquals(55, root.valueA);
|
||||||
|
Assertions.assertEquals(78, root.valueB);
|
||||||
|
Assertions.assertEquals(51, root.valueC);
|
||||||
|
Assertions.assertEquals(24, root.valueD);
|
||||||
|
Assertions.assertEquals(651, root.getValueE());
|
||||||
|
Assertions.assertEquals(654, root.getValueF());
|
||||||
|
Assertions.assertEquals(8552, root.getValueG());
|
||||||
|
Assertions.assertEquals(9531, root.getValueH());
|
||||||
|
Assertions.assertEquals(87465, root.getValueI());
|
||||||
|
Assertions.assertEquals(8247, root.getValueJ());
|
||||||
|
Assertions.assertEquals(885522, root.getValueK());
|
||||||
|
Assertions.assertEquals(321, root.finalValueM);
|
||||||
|
Assertions.assertEquals(654, root.finalValueN);
|
||||||
|
Assertions.assertEquals(987, root.finalValueO);
|
||||||
|
Assertions.assertEquals(159, root.finalValueP);
|
||||||
|
Assertions.assertEquals(267, root.finalValueQ);
|
||||||
|
Assertions.assertEquals(264, root.finalValueR);
|
||||||
|
Assertions.assertEquals(1524, root.finalValueS);
|
||||||
|
Assertions.assertEquals(182445, root.finalValueT);
|
||||||
|
Assertions.assertEquals(-552, root.getPFinalValueQ());
|
||||||
|
Assertions.assertEquals(-965, root.getPFinalValueR());
|
||||||
|
Assertions.assertEquals(-98885, root.getPFinalValueS());
|
||||||
|
Assertions.assertEquals(-8754, root.getPFinalValueT());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user