[DEV] update

This commit is contained in:
Edouard DUPIN 2023-07-27 07:33:48 +02:00
parent b040811197
commit eb5455693e
11 changed files with 261 additions and 188 deletions

View File

@ -1,15 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry including="**/*.java" kind="src" output="out/eclipse/classes-test" path="test/src">
<classpathentry kind="src" output="out/maven/test-classes" path="test/src">
<attributes>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="out/maven/classes" path="src">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="module" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5">
@ -17,10 +23,10 @@
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/atriasoft-etk">
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="module" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="out/eclipse/classes"/>
<classpathentry kind="output" path="out/maven/classes"/>
</classpath>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="false"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_DISABLED_BUILDER" value="net.sf.eclipsecs.core.CheckstyleBuilder"/>
<mapAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
</launchConfiguration>

View File

@ -12,12 +12,23 @@
</arguments>
</buildCommand>
<buildCommand>
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
<dictionary>
<key>LaunchConfigHandle</key>
<value>&lt;project&gt;/.externalToolBuilders/net.sf.eclipsecs.core.CheckstyleBuilder (1).launch</value>
</dictionary>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>

118
pom.xml Normal file
View File

@ -0,0 +1,118 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>jatria-soft</groupId>
<artifactId>aknot</artifactId>
<version>0.1.0</version>
<properties>
<maven.compiler.version>3.1</maven.compiler.version>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.dependency.version>3.1.1</maven.dependency.version>
</properties>
<repositories>
<repository>
<id>gitea</id>
<url>https://gitea.atria-soft.org/api/packages/jatria-soft/maven</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>gitea</id>
<url>https://gitea.atria-soft.org/api/packages/jatria-soft/maven</url>
</repository>
<snapshotRepository>
<id>gitea</id>
<url>https://gitea.atria-soft.org/api/packages/jatria-soft/maven</url>
</snapshotRepository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>jatria-soft</groupId>
<artifactId>etk</artifactId>
<version>0.1.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.9.3</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test/src</testSourceDirectory>
<directory>${project.basedir}/out/maven/</directory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.version}</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<!--<encoding>${project.build.sourceEncoding}</encoding>-->
</configuration>
</plugin>
<!-- Create the source bundle -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- junit results -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>fully.qualified.MainClass</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
<!-- Java-doc generation for stand-alone site -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<show>private</show>
<nohelp>true</nohelp>
</configuration>
</plugin>
</plugins>
</build>
<!-- Generate Java-docs As Part Of Project Reports -->
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<show>public</show>
</configuration>
</plugin>
</plugins>
</reporting>
</project>

View File

@ -12,6 +12,5 @@ open module org.atriasoft.aknot {
exports org.atriasoft.aknot.exception;
requires transitive org.atriasoft.etk;
requires transitive org.atriasoft.reggol;
requires java.base;
}

View File

@ -1,6 +1,8 @@
package org.atriasoft.aknot;
import java.lang.annotation.Annotation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
@ -26,9 +28,10 @@ import org.atriasoft.aknot.annotation.AknotOptional;
import org.atriasoft.aknot.annotation.AknotSignal;
import org.atriasoft.aknot.annotation.AknotText;
import org.atriasoft.aknot.exception.AknotException;
import org.atriasoft.aknot.internal.Log;
public class ReflectTools {
final static Logger LOGGER = LoggerFactory.getLogger(ReflectTools.class);
public static String getDescription(final Class<?> element) throws Exception {
final Annotation[] annotation = element.getDeclaredAnnotationsByType(AknotDescription.class);
if (annotation.length == 0) {
@ -570,7 +573,7 @@ public class ReflectTools {
final Type[] realType = plopppppp.getActualTypeArguments();
//Log.info("ppplllppp: " + realType.length);
if (realType.length > 0) {
Log.verbose(" -->> " + realType[0]);
LOGGER.trace(" -->> {}", realType[0]);
internalModelClass = Class.forName(realType[0].getTypeName());
}
}
@ -592,7 +595,7 @@ public class ReflectTools {
if (empppe[0] instanceof final ParameterizedType plopppppp) {
final Type[] realType = plopppppp.getActualTypeArguments();
if (realType.length > 0) {
Log.verbose(" -->> " + realType[0]);
LOGGER.trace(" -->> {}", realType[0]);
internalModelClass = Class.forName(realType[0].getTypeName());
}
}

View File

@ -1,81 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2021, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
package org.atriasoft.aknot.internal;
import org.atriasoft.reggol.LogLevel;
import org.atriasoft.reggol.Logger;
public class Log {
private static final String LIB_NAME = "aknot";
private static final boolean FORCE_ALL = false;
private static final String LIB_NAME_DRAW = Logger.getDrawableName(Log.LIB_NAME);
private static final boolean PRINT_CRITICAL = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.CRITICAL);
private static final boolean PRINT_DEBUG = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.DEBUG);
private static final boolean PRINT_ERROR = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.ERROR);
private static final boolean PRINT_INFO = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.INFO);
private static final boolean PRINT_PRINT = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.PRINT);
private static final boolean PRINT_TODO = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.TODO);
private static final boolean PRINT_VERBOSE = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.VERBOSE);
private static final boolean PRINT_WARNING = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.WARNING);
public static void critical(final Exception e, final String data) {
e.printStackTrace();
if (PRINT_CRITICAL || FORCE_ALL) {
Logger.critical(LIB_NAME_DRAW, data + " : " + e.getMessage());
}
}
public static void critical(final String data, final Object... objects) {
if (PRINT_CRITICAL || FORCE_ALL) {
Logger.critical(LIB_NAME_DRAW, data, objects);
}
}
public static void debug(final String data, final Object... objects) {
if (PRINT_DEBUG || FORCE_ALL) {
Logger.debug(LIB_NAME_DRAW, data, objects);
}
}
public static void error(final String data, final Object... objects) {
if (PRINT_ERROR || FORCE_ALL) {
Logger.error(LIB_NAME_DRAW, data, objects);
}
}
public static void info(final String data, final Object... objects) {
if (PRINT_INFO || FORCE_ALL) {
Logger.info(LIB_NAME_DRAW, data, objects);
}
}
public static void print(final String data, final Object... objects) {
if (PRINT_PRINT || FORCE_ALL) {
Logger.print(LIB_NAME_DRAW, data, objects);
}
}
public static void todo(final String data, final Object... objects) {
if (PRINT_TODO || FORCE_ALL) {
Logger.todo(LIB_NAME_DRAW, data, objects);
}
}
public static void verbose(final String data, final Object... objects) {
if (PRINT_VERBOSE || FORCE_ALL) {
Logger.verbose(LIB_NAME_DRAW, data, objects);
}
}
public static void warning(final String data, final Object... objects) {
if (PRINT_WARNING || FORCE_ALL) {
Logger.warning(LIB_NAME_DRAW, data, objects);
}
}
private Log() {}
}

View File

@ -4,10 +4,13 @@ import java.util.List;
import java.util.Map;
import org.atriasoft.aknot.exception.AknotException;
import org.atriasoft.aknot.internal.Log;
import org.atriasoft.aknot.pojo.IntrospectionProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public abstract class IntrospectionModel {
final static Logger LOGGER = LoggerFactory.getLogger(IntrospectionModel.class);
public static final String STUPID_TOCKEN = "___aé\"'__-è==**ù!^$:;,;AZEARTYUIOPMLKJHGFDSQW>XCVBN?"; // can not exist ....
protected static final Boolean DEFAULT_ATTRIBUTE = false;
protected static final Boolean DEFAULT_IGNORE_UNBKNOWN = false;
@ -106,7 +109,7 @@ public abstract class IntrospectionModel {
*/
public Object getValueConverted(final Object value, final Class<?> classTypeLocal) throws AknotException {
// Note if the type is an Array<>() or a List<>() ==> we parse element by element ... then we need to keep the undertype...
Log.debug("======>>>>>>> convert : {} ==> {} ", value.getClass().getCanonicalName(), classTypeLocal.getCanonicalName());
LOGGER.debug("======>>>>>>> convert : {} ==> {} ", value.getClass().getCanonicalName(), classTypeLocal.getCanonicalName());
if (value.getClass() == Long.class) {
if (classTypeLocal == long.class || classTypeLocal == Long.class) {
return value;
@ -197,7 +200,7 @@ public abstract class IntrospectionModel {
return (double) 0;
}
}
Log.error("======>>>>>>> convert : {} ==> {} Can not do it !!!", value.getClass().getCanonicalName(), classTypeLocal.getCanonicalName());
LOGGER.error("======>>>>>>> convert : {} ==> {} Can not do it !!!", value.getClass().getCanonicalName(), classTypeLocal.getCanonicalName());
return value;
}

View File

@ -19,13 +19,15 @@ import org.atriasoft.aknot.ReflectClass;
import org.atriasoft.aknot.ReflectTools;
import org.atriasoft.aknot.StringSerializer;
import org.atriasoft.aknot.exception.AknotException;
import org.atriasoft.aknot.internal.Log;
import org.atriasoft.aknot.model.ConstructorModel;
import org.atriasoft.aknot.model.IntrospectionModel;
import org.atriasoft.etk.Tools;
import org.atriasoft.etk.util.ArraysTools;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class IntrospectionModelComplex extends IntrospectionModel {
final static Logger LOGGER = LoggerFactory.getLogger(IntrospectionModelComplex.class);
private final boolean isRecord;
// TODO Optimize this with external object for basic types....
private final Method valueof; // used for the set Text if the object is an end point...
@ -53,18 +55,18 @@ public class IntrospectionModelComplex extends IntrospectionModel {
}
this.isRecord = Record.class.isAssignableFrom(classType);
if (classType.isPrimitive()) {
Log.critical("Detect primitive ==> impossible case !!! ");
LOGGER.error("[CRITICAL] Detect primitive ==> impossible case !!! ");
}
final Boolean isDefaultManaged = ReflectTools.getIsDefaultManaged(classType, IntrospectionModel.DEFAULT_MANAGED);
// ------------------------------------------------------------------------
// -- Parse constructor
// ------------------------------------------------------------------------
Log.error("Introspect class: '" + classType.getCanonicalName() + "'");
LOGGER.error("Introspect class: '" + classType.getCanonicalName() + "'");
final Constructor<?>[] constructors = this.classType.getConstructors();
Log.warning(" Constructors: (" + constructors.length + ")");
LOGGER.warn(" Constructors: (" + constructors.length + ")");
Constructor<?> emptyConstructorTmp = null;
for (final Constructor<?> elem : constructors) {
Log.error(" Constructor ??? : {}", elem.toGenericString());
LOGGER.error(" Constructor ??? : {}", elem.toGenericString());
// we does not manage private field
if (!Modifier.isPublic(elem.getModifiers())) {
continue;
@ -76,7 +78,7 @@ public class IntrospectionModelComplex extends IntrospectionModel {
}
if (elem.getParameterCount() == 0) {
emptyConstructorTmp = elem;
Log.error(" >>> " + elem.toGenericString());
LOGGER.error(" >>> " + elem.toGenericString());
} else {
int offsetSubClass = 0;
if (this.isSubClass) {
@ -84,7 +86,7 @@ public class IntrospectionModelComplex extends IntrospectionModel {
}
if (elem.getParameterCount() == 1 && offsetSubClass == 1) {
emptyConstructorTmp = elem;
Log.error(" >>> " + elem.toGenericString());
LOGGER.error(" >>> " + elem.toGenericString());
} else {
// Retrieve full description in constructor properties...
String[] namesBeans = ReflectTools.getNames(elem, null);
@ -129,8 +131,8 @@ public class IntrospectionModelComplex extends IntrospectionModel {
continue;
}
if (checkIfOneIsNull(namesBeans, 0)) {
Log.verbose(" - " + elem.toGenericString());
Log.verbose(" ==> unmanaged (missing names description: " + Arrays.toString(namesBeans) + ")");
LOGGER.trace(" - " + elem.toGenericString());
LOGGER.trace(" ==> unmanaged (missing names description: " + Arrays.toString(namesBeans) + ")");
} else {
// check default attributes in the global list ... (do it at the end to be sure the constructor is VALID ...
for (int iii = 0; iii < namesBeans.length; iii++) {
@ -197,11 +199,11 @@ public class IntrospectionModelComplex extends IntrospectionModel {
}
}
this.constructorEmpty = emptyConstructorTmp;
Log.error(" ==> constructor = {}", this.constructorEmpty);
LOGGER.error(" ==> constructor = {}", this.constructorEmpty);
// Order the constructor from the bigger number of element to the lowest...
Collections.sort(this.constructors, (a, b) -> a.values().length - b.values().length);
for (final ConstructorModel elem : this.constructors) {
Log.verbose(" * " + elem.constructor().toGenericString());
LOGGER.trace(" * " + elem.constructor().toGenericString());
final StringBuilder tmpPrint = new StringBuilder(" ==> (");
if (this.isSubClass) {
tmpPrint.append("null, ");
@ -213,7 +215,7 @@ public class IntrospectionModelComplex extends IntrospectionModel {
tmpPrint.append(elem.values()[iii]);
}
tmpPrint.append(")");
Log.verbose(tmpPrint.toString());
LOGGER.trace(tmpPrint.toString());
}
final List<String> recordAllPossibleValues = new ArrayList<>();
@ -231,7 +233,7 @@ public class IntrospectionModelComplex extends IntrospectionModel {
// -- Parse Field
// ------------------------------------------------------------------------
final Field[] fields = this.classType.getFields();
Log.verbose(" Fields: (" + fields.length + ")");
LOGGER.trace(" Fields: (" + fields.length + ")");
for (final Field elem : fields) {
// we does not manage static field
if (Modifier.isStatic(elem.getModifiers())) {
@ -313,14 +315,14 @@ public class IntrospectionModelComplex extends IntrospectionModel {
prop.setSetter(modifier);
prop.setGetter(modifier);
}
Log.verbose(" - " + elem.toGenericString());
LOGGER.trace(" - " + elem.toGenericString());
}
final List<Method> methods = ReflectClass.getFilterGenericFucntion(this.classType, recordAllPossibleValues, true, true, true);
Log.verbose(" Methods: (" + methods.size() + ")");
LOGGER.trace(" Methods: (" + methods.size() + ")");
for (final Method elem : methods) {
Log.verbose(" - " + elem.toGenericString());
LOGGER.trace(" - " + elem.toGenericString());
}
// Separate the methods and filer as:
@ -549,8 +551,8 @@ public class IntrospectionModelComplex extends IntrospectionModel {
throw new AknotException("No constructor accessible for class: " + this.classType.getCanonicalName());
}
try {
Log.error("create class : {} with subClass={}", this.classType.getCanonicalName(), this.isSubClass);
Log.error(" ==> constructor = {}", this.constructorEmpty);
LOGGER.error("create class : {} with subClass={}", this.classType.getCanonicalName(), this.isSubClass);
LOGGER.error(" ==> constructor = {}", this.constructorEmpty);
if (this.isSubClass) {
final Object tmp2 = null;
tmp = this.constructorEmpty.newInstance(tmp2);
@ -573,51 +575,51 @@ public class IntrospectionModelComplex extends IntrospectionModel {
}
public void display() {
Log.print("Class: {} nbProperty:{}", this.classType.getCanonicalName(), this.elements.size());
Log.print("Managed:");
LOGGER.info("Class: {} nbProperty:{}", this.classType.getCanonicalName(), this.elements.size());
LOGGER.info("Managed:");
for (final IntrospectionProperty prop : this.elements) {
Log.print(" * Property/node : {}", prop.getBeanName());
Log.print(" names: {}", Arrays.toString(prop.getNames()));
Log.print(" list: {}", prop.getListName());
//Log.print(" managed: {}", prop.isManaged());
Log.print(" attribute: {}", prop.isAttribute());
Log.print(" text: {}", prop.isText());
Log.print(" case-sensitive: {}", prop.isCaseSensitive());
Log.print(" optionnal: {}", prop.isOptionnal());
Log.print(" constructor: {}", prop.isCanBeSetByConstructor());
Log.print(" get/set: {} / {}", prop.canGetValue(), prop.canSetValue());
Log.print(" type: {}", prop.getType().getCanonicalName());
LOGGER.info(" * Property/node : {}", prop.getBeanName());
LOGGER.info(" names: {}", Arrays.toString(prop.getNames()));
LOGGER.info(" list: {}", prop.getListName());
//LOGGER.info(" managed: {}", prop.isManaged());
LOGGER.info(" attribute: {}", prop.isAttribute());
LOGGER.info(" text: {}", prop.isText());
LOGGER.info(" case-sensitive: {}", prop.isCaseSensitive());
LOGGER.info(" optionnal: {}", prop.isOptionnal());
LOGGER.info(" constructor: {}", prop.isCanBeSetByConstructor());
LOGGER.info(" get/set: {} / {}", prop.canGetValue(), prop.canSetValue());
LOGGER.info(" type: {}", prop.getType().getCanonicalName());
if (prop.getSubType() != null) {
Log.print(" sub-type: {}", prop.getSubType().getCanonicalName());
LOGGER.info(" sub-type: {}", prop.getSubType().getCanonicalName());
} else {
Log.print(" sub-type: null");
LOGGER.info(" sub-type: null");
}
}
Log.info("Un-Managed:");
LOGGER.info("Un-Managed:");
for (final IntrospectionProperty prop : this.elementUnManaged) {
Log.print(" * Property/node : {}", prop.getBeanName());
Log.print(" names: {}", Arrays.toString(prop.getNames()));
Log.print(" list: {}", prop.getListName());
//Log.print(" managed: {}", prop.isManaged());
Log.print(" attribute: {}", prop.isAttribute());
Log.print(" text: {}", prop.isText());
Log.print(" case-sensitive: {}", prop.isCaseSensitive());
Log.print(" optionnal: {}", prop.isOptionnal());
Log.print(" constructor: {}", prop.isCanBeSetByConstructor());
Log.print(" get/set: {} / {}", prop.canGetValue(), prop.canSetValue());
Log.print(" type: {}", prop.getType().getCanonicalName());
LOGGER.info(" * Property/node : {}", prop.getBeanName());
LOGGER.info(" names: {}", Arrays.toString(prop.getNames()));
LOGGER.info(" list: {}", prop.getListName());
//LOGGER.info(" managed: {}", prop.isManaged());
LOGGER.info(" attribute: {}", prop.isAttribute());
LOGGER.info(" text: {}", prop.isText());
LOGGER.info(" case-sensitive: {}", prop.isCaseSensitive());
LOGGER.info(" optionnal: {}", prop.isOptionnal());
LOGGER.info(" constructor: {}", prop.isCanBeSetByConstructor());
LOGGER.info(" get/set: {} / {}", prop.canGetValue(), prop.canSetValue());
LOGGER.info(" type: {}", prop.getType().getCanonicalName());
if (prop.getSubType() != null) {
Log.print(" sub-type: {}", prop.getSubType().getCanonicalName());
LOGGER.info(" sub-type: {}", prop.getSubType().getCanonicalName());
} else {
Log.print(" sub-type: null");
LOGGER.info(" sub-type: null");
}
}
}
protected IntrospectionProperty findBeanNodeDescription(final String propertyBeanName, final boolean attributeIndependent) throws AknotException {
Log.debug("Find node description for element: {}", propertyBeanName);
LOGGER.debug("Find node description for element: {}", propertyBeanName);
for (final IntrospectionProperty prop : this.elements) {
Log.debug(" ==> {} => {}", prop.getBeanName(), prop.isAttribute());
LOGGER.debug(" ==> {} => {}", prop.getBeanName(), prop.isAttribute());
if (!attributeIndependent && prop.isAttribute()) {
continue;
}
@ -755,10 +757,10 @@ public class IntrospectionModelComplex extends IntrospectionModel {
@Override
public String getTreeNameOfSubNode(final String nodeBeanName, final boolean attributeIndependent) throws AknotException {
Log.debug(" nodeType='" + nodeBeanName + "'");
LOGGER.debug(" nodeType='" + nodeBeanName + "'");
final IntrospectionProperty propMethode = findBeanNodeDescription(nodeBeanName, attributeIndependent);
if (propMethode != null && propMethode.canSetValue()) {
Log.debug(" ==> find '" + propMethode.getNames());
LOGGER.debug(" ==> find '" + propMethode.getNames());
return propMethode.getListName();
}
throw new AknotException("can not find the field '" + nodeBeanName + "'");
@ -766,10 +768,10 @@ public class IntrospectionModelComplex extends IntrospectionModel {
@Override
public Class<?> getTypeOfProperty(final String nodeName) throws AknotException {
Log.debug("nodeType='" + nodeName + "'");
LOGGER.debug("nodeType='" + nodeName + "'");
final IntrospectionProperty propField = findPropertyDescription(nodeName);
if (propField != null && propField.canSetValue()) {
Log.debug(" ==> find '" + propField.getNames());
LOGGER.debug(" ==> find '" + propField.getNames());
return propField.getType();
}
@ -785,10 +787,10 @@ public class IntrospectionModelComplex extends IntrospectionModel {
public Class<?> getTypeOfSubNode(final String nodeBeanNames, final boolean attributeIndependent) throws AknotException {
final String[] elemstNames = nodeBeanNames.split("#");
final String nodeBeanName = elemstNames[0];
Log.debug("NodeType='" + nodeBeanName + "'");
LOGGER.debug("NodeType='" + nodeBeanName + "'");
final IntrospectionProperty propMethode = findBeanNodeDescription(nodeBeanName, attributeIndependent);
if (propMethode != null && propMethode.canSetValue()) {
Log.debug(" ==> find '" + propMethode.getNames());
LOGGER.debug(" ==> find '" + propMethode.getNames());
if (propMethode.hasFactory()) {
return propMethode.getCompatible(elemstNames[1]);
} else {
@ -802,10 +804,10 @@ public class IntrospectionModelComplex extends IntrospectionModel {
public Class<?> getTypeOfSubNodeList(final String nodeBeanNames, final boolean attributeIndependent) throws AknotException {
final String[] elemstNames = nodeBeanNames.split("#");
final String nodeBeanName = elemstNames[0];
Log.debug(" nodeType='" + nodeBeanName + "'");
LOGGER.debug(" nodeType='" + nodeBeanName + "'");
final IntrospectionProperty propMethode = findBeanNodeDescription(nodeBeanName, attributeIndependent);
if (propMethode != null && propMethode.canSetValue()) {
Log.debug(" ==> find '" + propMethode.getNames());
LOGGER.debug(" ==> find '" + propMethode.getNames());
if (propMethode.hasFactory()) {
return propMethode.getCompatible(elemstNames[1]);
} else {
@ -817,10 +819,10 @@ public class IntrospectionModelComplex extends IntrospectionModel {
@Override
public Class<?> getTypeOfSubProperty(final String nodeName) throws AknotException {
Log.debug(" nodeType='" + nodeName + "'");
LOGGER.debug(" nodeType='" + nodeName + "'");
final IntrospectionProperty propField = findPropertyDescription(nodeName);
if (propField != null && propField.canSetValue()) {
Log.debug(" ==> find '" + propField.getNames());
LOGGER.debug(" ==> find '" + propField.getNames());
return propField.getSubType();
}
throw new AknotException("can not find the field '" + nodeName + "' available: " + getNodeAvaillable());
@ -839,17 +841,17 @@ public class IntrospectionModelComplex extends IntrospectionModel {
@Override
public Object getValue(final String propertyName, final String propertyValue) throws AknotException {
Log.debug(" propertyName='" + propertyName + "' propertyValue='" + propertyValue + "' ");
LOGGER.debug(" propertyName='" + propertyName + "' propertyValue='" + propertyValue + "' ");
// by default use setter to set the property
final IntrospectionProperty propMethode = findNodeDescription(propertyName);
if (propMethode != null && propMethode.canSetValue()) {
Log.verbose(" ==> find '" + propMethode.getNames());
LOGGER.trace(" ==> find '" + propMethode.getNames());
return propMethode.createValue(propertyValue);
}
// try with direct field
final IntrospectionProperty propField = findPropertyDescription(propertyName);
if (propField != null && propField.canSetValue()) {
Log.verbose(" ==> find '" + propField.getNames());
LOGGER.trace(" ==> find '" + propField.getNames());
return propField.createValue(propertyValue);
}
throw new AknotException("can not find the field '" + propertyName + "'");
@ -859,8 +861,8 @@ public class IntrospectionModelComplex extends IntrospectionModel {
public Object getValueFromText(final String text) throws AknotException {
// Note if the type is an Array<>() or a List<>() ==> we parse element by element ... then we need to keep the undertype...
Class<?> classTypeLocal = this.classType;
Log.debug("======>>>>>>> Get input type : " + this.classType.getCanonicalName());
//Log.debug("======>>>>>>> Get input component type : " + this.classType.getComponentType().getCanonicalName());
LOGGER.debug("======>>>>>>> Get input type : " + this.classType.getCanonicalName());
//LOGGER.debug("======>>>>>>> Get input component type : " + this.classType.getComponentType().getCanonicalName());
if (this.classType.isArray()) {
// generic array ...
classTypeLocal = this.classType.getComponentType();
@ -881,12 +883,12 @@ public class IntrospectionModelComplex extends IntrospectionModel {
*/
//Type tmpp = classType.getGenericSuperclass();
// Class<?> tmpp = classType.getInterfaces();
// Log.warning("======>>>>>>> Find List '" + tmpp + "'");
// LOGGER.warn("======>>>>>>> Find List '" + tmpp + "'");
// for (int iii = 0; iii < tmpp.length; iii++) {
// Log.warning(" - " + tmpp[iii]);
// LOGGER.warn(" - " + tmpp[iii]);
// }
}
Log.debug("======>>>>>>> subElement input type : " + classTypeLocal.getCanonicalName());
LOGGER.debug("======>>>>>>> subElement input type : " + classTypeLocal.getCanonicalName());
if (this.valueof == null) {
if (StringSerializer.contains(classTypeLocal)) {
@ -908,9 +910,9 @@ public class IntrospectionModelComplex extends IntrospectionModel {
@Override
public boolean hasTextModel() {
Log.warning("in {}", this.classType.getCanonicalName());
LOGGER.warn("in {}", this.classType.getCanonicalName());
for (final IntrospectionProperty prop : this.elements) {
Log.warning(" check {}, manage={} cas setValue={} isText={}", prop.getBeanName(), prop.isManaged(), prop.canSetValue(), prop.isText());
LOGGER.warn(" check {}, manage={} cas setValue={} isText={}", prop.getBeanName(), prop.isManaged(), prop.canSetValue(), prop.isText());
final Boolean isText = prop.isText();
if (isText != null && isText) {
return true;
@ -925,12 +927,12 @@ public class IntrospectionModelComplex extends IntrospectionModel {
}
private void setValue(final Object data, final String beanName, final Object value, final boolean attributeIndependent) throws AknotException {
Log.verbose(" Set value ='" + beanName + "' propertyValue='" + value + "' " + value.getClass().getCanonicalName());
LOGGER.trace(" Set value ='" + beanName + "' propertyValue='" + value + "' " + value.getClass().getCanonicalName());
{
// by default use setter to set the property
final IntrospectionProperty propMethode = findBeanNodeDescription(beanName, attributeIndependent);
if (propMethode != null && propMethode.canSetValue()) {
Log.verbose(" ==> find '" + Arrays.toString(propMethode.getNames()) + " type=" + propMethode.getType() + " sub-type=" + propMethode.getSubType());
LOGGER.trace(" ==> find '" + Arrays.toString(propMethode.getNames()) + " type=" + propMethode.getType() + " sub-type=" + propMethode.getSubType());
if (propMethode.getType().isAssignableFrom(value.getClass())) {
propMethode.setExistingValue(data, value);
} else if (value instanceof List) {
@ -941,8 +943,8 @@ public class IntrospectionModelComplex extends IntrospectionModel {
final Object newData = ArraysTools.listToPrimitiveAuto(propMethode.getType().componentType(), tmpp);
propMethode.setExistingValue(data, newData);
} else {
Log.verbose(" datas type: " + autoCast(propMethode.getType().componentType(), tmpp).getClass().getCanonicalName());
Log.verbose(" methode type: " + propMethode.getType().getCanonicalName());
LOGGER.trace(" datas type: " + autoCast(propMethode.getType().componentType(), tmpp).getClass().getCanonicalName());
LOGGER.trace(" methode type: " + propMethode.getType().getCanonicalName());
propMethode.setExistingValue(data, autoCast(propMethode.getType().componentType(), tmpp));
}
} else if (tmpp.size() == 1) {
@ -981,7 +983,7 @@ public class IntrospectionModelComplex extends IntrospectionModel {
{
final IntrospectionProperty propField = findBeanPropertyDescription(beanName);
if (propField != null && propField.canSetValue()) {
Log.verbose(" ==> find '" + Arrays.toString(propField.getNames()) + " type=" + propField.getType() + " sub-type=" + propField.getSubType());
LOGGER.trace(" ==> find '" + Arrays.toString(propField.getNames()) + " type=" + propField.getType() + " sub-type=" + propField.getSubType());
if (propField.getType().isAssignableFrom(value.getClass())) {
propField.setExistingValue(data, value);
// Some specific case for primitives values
@ -1032,8 +1034,8 @@ public class IntrospectionModelComplex extends IntrospectionModel {
final double[] datas = ArraysTools.listDoubleToPrimitive(tmpp);
propField.setExistingValue(data, datas);
} else {
Log.verbose(" datas type: " + autoCast(propField.getType().componentType(), tmpp).getClass().getCanonicalName());
Log.verbose(" methode type: " + propField.getType().getCanonicalName());
LOGGER.trace(" datas type: " + autoCast(propField.getType().componentType(), tmpp).getClass().getCanonicalName());
LOGGER.trace(" methode type: " + propField.getType().getCanonicalName());
propField.setExistingValue(data, autoCast(propField.getType().componentType(), tmpp));
}
} else if (tmpp.size() == 1) {

View File

@ -8,12 +8,14 @@ import java.util.Map.Entry;
import org.atriasoft.aknot.StringSerializer;
import org.atriasoft.aknot.exception.AknotException;
import org.atriasoft.aknot.internal.Log;
import org.atriasoft.aknot.model.InterfaceFactoryAccess;
import org.atriasoft.aknot.model.IntrospectionPropertyGetter;
import org.atriasoft.aknot.model.IntrospectionPropertySetter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class IntrospectionProperty {
final static Logger LOGGER = LoggerFactory.getLogger(IntrospectionProperty.class);
// if the element is not managed by us (set at null while not define by a function attribute, parameter ...)
private Boolean managed = null;
// Case sensitive in parsing XML or not (set at null while not define by a function attribute, parameter ...)
@ -118,18 +120,18 @@ public final class IntrospectionProperty {
if (this.caseSensitive) {
for (final String elem : this.names) {
if (elem.contentEquals(name)) {
Log.verbose(" - '{}' ==> true", elem);
LOGGER.trace(" - '{}' ==> true", elem);
return getType();
}
Log.verbose(" - '{}' == false", elem);
LOGGER.trace(" - '{}' == false", elem);
}
} else {
for (final String elem : this.names) {
if (elem.equalsIgnoreCase(name)) {
Log.verbose(" - '{}' ==> true", elem);
LOGGER.trace(" - '{}' ==> true", elem);
return getType();
}
Log.verbose(" - '{}' == false", elem);
LOGGER.trace(" - '{}' == false", elem);
}
}
return null;
@ -216,25 +218,25 @@ public final class IntrospectionProperty {
* @return true if the element is compatible, false otherwise
*/
public boolean isCompatible(final String name) {
Log.verbose("Check compatible : '{}' in {}", name, Arrays.toString(this.names));
LOGGER.trace("Check compatible : '{}' in {}", name, Arrays.toString(this.names));
final InterfaceFactoryAccess factoryGenerator = getFactory();
if (factoryGenerator != null) {
Log.verbose(" ===> Detect factory !!!!");
LOGGER.trace(" ===> Detect factory !!!!");
if (this.caseSensitive) {
for (final Entry<String, Class<?>> elem : factoryGenerator.getConversionMap().entrySet()) {
if (elem.getKey().contentEquals(name)) {
Log.verbose(" + '{}' ==> true", elem.getKey());
LOGGER.trace(" + '{}' ==> true", elem.getKey());
return true;
}
Log.verbose(" + '{}' == false", elem.getKey());
LOGGER.trace(" + '{}' == false", elem.getKey());
}
} else {
for (final Entry<String, Class<?>> elem : factoryGenerator.getConversionMap().entrySet()) {
if (elem.getKey().equalsIgnoreCase(name)) {
Log.verbose(" + '{}' ==> true", elem.getKey());
LOGGER.trace(" + '{}' ==> true", elem.getKey());
return true;
}
Log.verbose(" + '{}' == false", elem.getKey());
LOGGER.trace(" + '{}' == false", elem.getKey());
}
}
return false;
@ -242,18 +244,18 @@ public final class IntrospectionProperty {
if (this.caseSensitive) {
for (final String elem : this.names) {
if (elem.contentEquals(name)) {
Log.verbose(" - '{}' ==> true", elem);
LOGGER.trace(" - '{}' ==> true", elem);
return true;
}
Log.verbose(" - '{}' == false", elem);
LOGGER.trace(" - '{}' == false", elem);
}
} else {
for (final String elem : this.names) {
if (elem.equalsIgnoreCase(name)) {
Log.verbose(" - '{}' ==> true", elem);
LOGGER.trace(" - '{}' ==> true", elem);
return true;
}
Log.verbose(" - '{}' == false", elem);
LOGGER.trace(" - '{}' == false", elem);
}
}
return false;

View File

@ -5,15 +5,18 @@
*/
package test.atriasoft.aknot;
import org.atriasoft.aknot.internal.Log;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ExmlTestElement {
final static Logger LOGGER = LoggerFactory.getLogger(ExmlTestElement.class);
@BeforeAll
public static void beforeClass() {
Log.verbose("----------------------------------------------------------------");
LOGGER.trace("----------------------------------------------------------------");
}
@Test