[DEV] rework to Maven

This commit is contained in:
Edouard DUPIN 2023-07-27 07:34:47 +02:00
parent 044c125b6f
commit c6cb79c8d7
21 changed files with 286 additions and 235 deletions

View File

@ -1,19 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" path="src"> <classpathentry kind="src" output="out/maven/classes" path="src">
<attributes> <attributes>
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<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> <attributes>
<attribute name="test" value="true"/> <attribute name="test" value="true"/>
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-14"> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes> <attributes>
<attribute name="module" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"> <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5">
@ -21,15 +23,10 @@
<attribute name="test" value="true"/> <attribute name="test" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/atriasoft-etk"> <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes> <attributes>
<attribute name="module" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/atriasoft-aknot"> <classpathentry kind="output" path="out/maven/classes"/>
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="out/eclipse/classes"/>
</classpath> </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

@ -17,12 +17,23 @@
</arguments> </arguments>
</buildCommand> </buildCommand>
<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 (2).launch</value>
</dictionary>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
</buildSpec> </buildSpec>
<natures> <natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.jdt.core.javanature</nature>
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature> <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
<nature>org.python.pydev.pythonNature</nature> <nature>org.python.pydev.pythonNature</nature>

129
pom.xml Normal file
View File

@ -0,0 +1,129 @@
<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>ejson</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>jatria-soft</groupId>
<artifactId>aknot</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>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.7</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

@ -11,20 +11,22 @@ import org.atriasoft.ejson.builder.BuilderGeneric;
import org.atriasoft.ejson.exception.EjsonBuilderException; import org.atriasoft.ejson.exception.EjsonBuilderException;
import org.atriasoft.ejson.exception.EjsonParserErrorMulti; import org.atriasoft.ejson.exception.EjsonParserErrorMulti;
import org.atriasoft.ejson.generator.GeneratorGeneric; import org.atriasoft.ejson.generator.GeneratorGeneric;
import org.atriasoft.ejson.internal.Log;
import org.atriasoft.ejson.model.JsonNode; import org.atriasoft.ejson.model.JsonNode;
import org.atriasoft.ejson.parser.ParseJson; import org.atriasoft.ejson.parser.ParseJson;
import org.atriasoft.ejson.parser.ParsingProperty; import org.atriasoft.ejson.parser.ParsingProperty;
import org.atriasoft.etk.Uri; import org.atriasoft.etk.Uri;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Ejson { public class Ejson {
final static Logger LOGGER = LoggerFactory.getLogger(Ejson.class);
/** /**
* Display the Document on console * Display the Document on console
*/ */
public static void display(final JsonNode root) { public static void display(final JsonNode root) {
final StringBuilder tmpp = new StringBuilder(); final StringBuilder tmpp = new StringBuilder();
GeneratorGeneric.serialize(root, tmpp, 0); GeneratorGeneric.serialize(root, tmpp, 0);
Log.info("Generated JSON : \n{}", tmpp.toString()); LOGGER.info("Generated JSON : \n{}", tmpp.toString());
} }
/** /**
@ -51,7 +53,7 @@ public class Ejson {
property.setDisplayError(true); property.setDisplayError(true);
final byte[] elemData = Uri.getAllData(data); final byte[] elemData = Uri.getAllData(data);
if (elemData == null) { if (elemData == null) {
Log.error("Can not read the Stream : {}", data); LOGGER.error("Can not read the Stream : {}", data);
return null; return null;
} }
final String dataToParse = new String(elemData); final String dataToParse = new String(elemData);

View File

@ -13,12 +13,14 @@ import org.atriasoft.ejson.builder.BuilderIntrospection;
import org.atriasoft.ejson.builder.IntrospectionObject; import org.atriasoft.ejson.builder.IntrospectionObject;
import org.atriasoft.ejson.exception.EjsonException; import org.atriasoft.ejson.exception.EjsonException;
import org.atriasoft.ejson.exception.EjsonNodeDoesNotExist; import org.atriasoft.ejson.exception.EjsonNodeDoesNotExist;
import org.atriasoft.ejson.internal.Log;
import org.atriasoft.ejson.parser.ParseJson; import org.atriasoft.ejson.parser.ParseJson;
import org.atriasoft.ejson.parser.ParsingProperty; import org.atriasoft.ejson.parser.ParsingProperty;
import org.atriasoft.etk.Uri; import org.atriasoft.etk.Uri;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class JsonMapper { public class JsonMapper {
final static Logger LOGGER = LoggerFactory.getLogger(JsonMapper.class);
private static String readFile(final Path path, final Charset encoding) throws IOException { private static String readFile(final Path path, final Charset encoding) throws IOException {
final byte[] encoded = Files.readAllBytes(path); final byte[] encoded = Files.readAllBytes(path);
@ -67,7 +69,7 @@ public class JsonMapper {
final IntrospectionObject introspectionObject = (IntrospectionObject) parser.parse(data, property); final IntrospectionObject introspectionObject = (IntrospectionObject) parser.parse(data, property);
introspectionObject.generateTheObject(true); introspectionObject.generateTheObject(true);
final Object listRet = introspectionObject.getData(); final Object listRet = introspectionObject.getData();
Log.error("elements: {} , {}", listRet.getClass(), classType); LOGGER.error("elements: {} , {}", listRet.getClass(), classType);
if (listRet != null && !listRet.getClass().isArray() && listRet.getClass() == classType) { if (listRet != null && !listRet.getClass().isArray() && listRet.getClass() == classType) {
return (T) listRet; return (T) listRet;
} else if (listRet != null && listRet.getClass().isArray() && listRet.getClass().componentType() == classType) { } else if (listRet != null && listRet.getClass().isArray() && listRet.getClass().componentType() == classType) {
@ -97,7 +99,7 @@ public class JsonMapper {
final byte[] elemData = Uri.getAllData(uri); final byte[] elemData = Uri.getAllData(uri);
if (elemData == null) { if (elemData == null) {
Log.error("Can not read the Stream : " + uri); LOGGER.error("Can not read the Stream : " + uri);
return null; return null;
} }
final String content = new String(elemData); final String content = new String(elemData);

View File

@ -13,12 +13,15 @@ import org.atriasoft.aknot.exception.AknotException;
import org.atriasoft.aknot.model.IntrospectionModel; import org.atriasoft.aknot.model.IntrospectionModel;
import org.atriasoft.aknot.model.ModelType; import org.atriasoft.aknot.model.ModelType;
import org.atriasoft.aknot.pojo.CacheIntrospectionModel; import org.atriasoft.aknot.pojo.CacheIntrospectionModel;
import org.atriasoft.aknot.pojo.IntrospectionProperty;
import org.atriasoft.ejson.exception.EjsonBuilderException; import org.atriasoft.ejson.exception.EjsonBuilderException;
import org.atriasoft.ejson.exception.EjsonException; import org.atriasoft.ejson.exception.EjsonException;
import org.atriasoft.ejson.exception.EjsonNodeDoesNotExist; import org.atriasoft.ejson.exception.EjsonNodeDoesNotExist;
import org.atriasoft.ejson.internal.Log; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class BuilderIntrospection implements Builder { public class BuilderIntrospection implements Builder {
final static Logger LOGGER = LoggerFactory.getLogger(BuilderIntrospection.class);
// Keep in cach all the object alredy parsed ==> optimize CPU // Keep in cach all the object alredy parsed ==> optimize CPU
CacheIntrospectionModel cacheModel = new CacheIntrospectionModel(); CacheIntrospectionModel cacheModel = new CacheIntrospectionModel();
// The root class (need to keep it if we use 2 time the builder, the root class is no more accessible). // The root class (need to keep it if we use 2 time the builder, the root class is no more accessible).
@ -33,7 +36,7 @@ public class BuilderIntrospection implements Builder {
@Override @Override
public void endParsing(final Object element) throws EjsonBuilderException, AknotException { public void endParsing(final Object element) throws EjsonBuilderException, AknotException {
Log.verbose("End of Element: {}", element); LOGGER.trace("End of Element: {}", element);
if (element == null) { if (element == null) {
return; return;
} }
@ -63,13 +66,13 @@ public class BuilderIntrospection implements Builder {
if (parent == null) { if (parent == null) {
return null; return null;
} }
Log.verbose("new element on NodeName=" + nodeName); LOGGER.trace("new element on NodeName=" + nodeName);
final IntrospectionObject introspectionObject = (IntrospectionObject) parent; final IntrospectionObject introspectionObject = (IntrospectionObject) parent;
final IntrospectionModel model = introspectionObject.getModelIntrospection(); final IntrospectionModel model = introspectionObject.getModelIntrospection();
Class<?> typeClass = null; Class<?> typeClass = null;
String listTreeName = null; String listTreeName = null;
if (!introspectionObject.isSubNodeOrPropertyExist(nodeName) && model.isIgnoreUnknown()) { if (!introspectionObject.isSubNodeOrPropertyExist(nodeName) && model.isIgnoreUnknown()) {
Log.debug("Ignore array: '" + nodeName + "', it does not exist."); LOGGER.debug("Ignore array: '" + nodeName + "', it does not exist.");
return null; return null;
} }
try { try {
@ -86,7 +89,7 @@ public class BuilderIntrospection implements Builder {
// specific case for List ==> need to get the subType in introspection ... // specific case for List ==> need to get the subType in introspection ...
if (typeClass.isArray()) { if (typeClass.isArray()) {
final Class<?> subTypeClass = typeClass.getComponentType(); final Class<?> subTypeClass = typeClass.getComponentType();
Log.verbose("Create array new 'SUB' class: '" + typeClass.getCanonicalName() + "' for node '" + nodeName + "'"); LOGGER.trace("Create array new 'SUB' class: '" + typeClass.getCanonicalName() + "' for node '" + nodeName + "'");
IntrospectionModel inferData = null; IntrospectionModel inferData = null;
inferData = this.cacheModel.findOrCreate(ModelType.LIST, listTreeName, subTypeClass); inferData = this.cacheModel.findOrCreate(ModelType.LIST, listTreeName, subTypeClass);
// Create the data when object is ended created... // Create the data when object is ended created...
@ -99,13 +102,13 @@ public class BuilderIntrospection implements Builder {
} catch (final AknotException e) { } catch (final AknotException e) {
throw new EjsonBuilderException("Node does not exist: " + e.getMessage()); throw new EjsonBuilderException("Node does not exist: " + e.getMessage());
} }
Log.verbose("Create List new 'SUB' class: '" + typeClass.getCanonicalName() + "' for node '" + nodeName + "'"); LOGGER.trace("Create List new 'SUB' class: '" + typeClass.getCanonicalName() + "' for node '" + nodeName + "'");
IntrospectionModel inferData = null; IntrospectionModel inferData = null;
inferData = this.cacheModel.findOrCreate(ModelType.LIST, listTreeName, subTypeClass); inferData = this.cacheModel.findOrCreate(ModelType.LIST, listTreeName, subTypeClass);
// Create the data when object is ended created... // Create the data when object is ended created...
return new IntrospectionObject(inferData); return new IntrospectionObject(inferData);
} }
Log.verbose("Create new class: '" + typeClass.getCanonicalName() + "' for node '" + nodeName + "'"); LOGGER.trace("Create new class: '" + typeClass.getCanonicalName() + "' for node '" + nodeName + "'");
final IntrospectionModel inferData = this.cacheModel.findOrCreate(ModelType.NORMAL, null, typeClass); final IntrospectionModel inferData = this.cacheModel.findOrCreate(ModelType.NORMAL, null, typeClass);
// Create the data when object is ended created... // Create the data when object is ended created...
return new IntrospectionObject(inferData); return new IntrospectionObject(inferData);
@ -115,7 +118,7 @@ public class BuilderIntrospection implements Builder {
@Override @Override
public void newArrayFinished(final Object parent, String tmpName, final Object element) throws EjsonException, AknotException { public void newArrayFinished(final Object parent, String tmpName, final Object element) throws EjsonException, AknotException {
Log.error("New element fionished : ==> " + tmpName); LOGGER.error("New element fionished : ==> " + tmpName);
if (parent == null || element == null) { if (parent == null || element == null) {
return; return;
} }
@ -279,7 +282,7 @@ public class BuilderIntrospection implements Builder {
throw new EjsonBuilderException("Object created inside a non list ... ==> impssible case"); throw new EjsonBuilderException("Object created inside a non list ... ==> impssible case");
} }
final Class<?> typeClass = model.getClassType(); final Class<?> typeClass = model.getClassType();
Log.verbose("Create new class: '" + typeClass.getCanonicalName() + "'"); LOGGER.trace("Create new class: '" + typeClass.getCanonicalName() + "'");
final IntrospectionModel inferData = this.cacheModel.findOrCreate(ModelType.NORMAL, null, typeClass); final IntrospectionModel inferData = this.cacheModel.findOrCreate(ModelType.NORMAL, null, typeClass);
// Create the data when object is ended created... // Create the data when object is ended created...
return new IntrospectionObject(inferData); return new IntrospectionObject(inferData);
@ -289,7 +292,7 @@ public class BuilderIntrospection implements Builder {
@Override @Override
public Object newObject(final Object parent, final String nodeName) throws EjsonException, AknotException { public Object newObject(final Object parent, final String nodeName) throws EjsonException, AknotException {
Log.verbose("new element on NodeName=" + nodeName); LOGGER.trace("new element on NodeName=" + nodeName);
final IntrospectionObject introspectionObject = (IntrospectionObject) parent; final IntrospectionObject introspectionObject = (IntrospectionObject) parent;
final IntrospectionModel model = introspectionObject.getModelIntrospection(); final IntrospectionModel model = introspectionObject.getModelIntrospection();
Class<?> typeClass = null; Class<?> typeClass = null;
@ -298,7 +301,7 @@ public class BuilderIntrospection implements Builder {
throw new EjsonBuilderException("Object is not compatible with an requested array: " + nodeName); throw new EjsonBuilderException("Object is not compatible with an requested array: " + nodeName);
} else { } else {
if (!introspectionObject.isSubNodeOrPropertyExist(nodeName) && model.isIgnoreUnknown()) { if (!introspectionObject.isSubNodeOrPropertyExist(nodeName) && model.isIgnoreUnknown()) {
Log.debug("Ignore node: '" + nodeName + "' Does not exist..."); LOGGER.debug("Ignore node: '" + nodeName + "' Does not exist...");
return null; return null;
} }
try { try {
@ -312,7 +315,7 @@ public class BuilderIntrospection implements Builder {
// specific case for List ==> need to get the subType in introspection ... // specific case for List ==> need to get the subType in introspection ...
if (typeClass.isArray()) { if (typeClass.isArray()) {
final Class<?> subTypeClass = typeClass.getComponentType(); final Class<?> subTypeClass = typeClass.getComponentType();
Log.verbose("Create array new 'SUB' class: '" + typeClass.getCanonicalName() + "' for node '" + nodeName + "'"); LOGGER.trace("Create array new 'SUB' class: '" + typeClass.getCanonicalName() + "' for node '" + nodeName + "'");
IntrospectionModel inferData = null; IntrospectionModel inferData = null;
// when we request a list elements, we need to add the element in a list, then we need the return is LIST and not ARRAY // when we request a list elements, we need to add the element in a list, then we need the return is LIST and not ARRAY
inferData = this.cacheModel.findOrCreate(ModelType.LIST, listTreeName, subTypeClass); inferData = this.cacheModel.findOrCreate(ModelType.LIST, listTreeName, subTypeClass);
@ -327,13 +330,13 @@ public class BuilderIntrospection implements Builder {
} catch (final AknotException e) { } catch (final AknotException e) {
throw new EjsonBuilderException("Node does not exist: " + e.getMessage()); throw new EjsonBuilderException("Node does not exist: " + e.getMessage());
} }
Log.verbose("Create List new 'SUB' class: '" + typeClass.getCanonicalName() + "' for node '" + nodeName + "'"); LOGGER.trace("Create List new 'SUB' class: '" + typeClass.getCanonicalName() + "' for node '" + nodeName + "'");
IntrospectionModel inferData = null; IntrospectionModel inferData = null;
inferData = this.cacheModel.findOrCreate(ModelType.LIST, listTreeName, subTypeClass); inferData = this.cacheModel.findOrCreate(ModelType.LIST, listTreeName, subTypeClass);
// Create the data when object is ended created... // Create the data when object is ended created...
return new IntrospectionObject(inferData); return new IntrospectionObject(inferData);
} }
Log.verbose("Create new class: '" + typeClass.getCanonicalName() + "' for node '" + nodeName + "'"); LOGGER.trace("Create new class: '" + typeClass.getCanonicalName() + "' for node '" + nodeName + "'");
final IntrospectionModel inferData = this.cacheModel.findOrCreate(ModelType.NORMAL, listTreeName, typeClass); final IntrospectionModel inferData = this.cacheModel.findOrCreate(ModelType.NORMAL, listTreeName, typeClass);
// Create the data when object is ended created... // Create the data when object is ended created...
return new IntrospectionObject(inferData); return new IntrospectionObject(inferData);
@ -361,7 +364,7 @@ public class BuilderIntrospection implements Builder {
final String beanName = model.getTextBeanName(); final String beanName = model.getTextBeanName();
if (beanName == null) { if (beanName == null) {
if (model.isIgnoreUnknown()) { if (model.isIgnoreUnknown()) {
Log.debug("Ignore node : **TEXT**"); LOGGER.debug("Ignore node : **TEXT**");
return; return;
} }
throw new EjsonBuilderException("The node **TEXT** Does not exist..."); throw new EjsonBuilderException("The node **TEXT** Does not exist...");
@ -373,7 +376,7 @@ public class BuilderIntrospection implements Builder {
final Object out = StringSerializer.valueOf(typeClass, value); final Object out = StringSerializer.valueOf(typeClass, value);
introspectionObject.putProperty(beanName, out); introspectionObject.putProperty(beanName, out);
} else if (typeClass.isArray()) { } else if (typeClass.isArray()) {
Log.error("Not managed !!! "); LOGGER.error("Not managed !!! ");
/* /*
final String[] elems = propertyValue.split(";"); final String[] elems = propertyValue.split(";");
final Class<?> subTypeClass = typeClass.getComponentType(); final Class<?> subTypeClass = typeClass.getComponentType();
@ -386,11 +389,11 @@ public class BuilderIntrospection implements Builder {
introspectionObject.putProperty(propertyName, out); introspectionObject.putProperty(propertyName, out);
*/ */
} else if (List.class.isAssignableFrom(typeClass)) { } else if (List.class.isAssignableFrom(typeClass)) {
Log.error("Not managed !!! "); LOGGER.error("Not managed !!! ");
/* /*
final String[] elems = propertyValue.split(";"); final String[] elems = propertyValue.split(";");
final Class<?> subTypeClass = introspectionObject.getTypeOfSubProperty(propertyName); final Class<?> subTypeClass = introspectionObject.getTypeOfSubProperty(propertyName);
Log.verbose("Create List new 'SUB' class: '" + typeClass.getCanonicalName() + "' for property '" + propertyName + "'"); LOGGER.trace("Create List new 'SUB' class: '" + typeClass.getCanonicalName() + "' for property '" + propertyName + "'");
final IntrospectionModel inferData = this.cacheModel.findOrCreate(ModelType.NORMAL, null, subTypeClass); final IntrospectionModel inferData = this.cacheModel.findOrCreate(ModelType.NORMAL, null, subTypeClass);
final List<Object> out = new ArrayList<>(); final List<Object> out = new ArrayList<>();
for (int iii = 0; iii < elems.length; iii++) { for (int iii = 0; iii < elems.length; iii++) {
@ -400,7 +403,7 @@ public class BuilderIntrospection implements Builder {
introspectionObject.putProperty(propertyName, out); introspectionObject.putProperty(propertyName, out);
*/ */
} else { } else {
//Log.error("Not managed !!! "); //LOGGER.error("Not managed !!! ");
final IntrospectionModel inferData = this.cacheModel.findOrCreate(ModelType.NORMAL, null, typeClass); final IntrospectionModel inferData = this.cacheModel.findOrCreate(ModelType.NORMAL, null, typeClass);
final Object out = inferData.getValueFromText(value); final Object out = inferData.getValueFromText(value);
introspectionObject.putProperty(IntrospectionObject.PUBLIC_TEXT_NAME, out); introspectionObject.putProperty(IntrospectionObject.PUBLIC_TEXT_NAME, out);
@ -426,7 +429,7 @@ public class BuilderIntrospection implements Builder {
} else if (List.class.isAssignableFrom(typeClass)) { } else if (List.class.isAssignableFrom(typeClass)) {
final String[] elems = value.split(";"); final String[] elems = value.split(";");
final Class<?> subTypeClass = introspectionObject.getTypeOfSubNode(value, true); final Class<?> subTypeClass = introspectionObject.getTypeOfSubNode(value, true);
Log.verbose("Create List new 'SUB' class: '" + typeClass.getCanonicalName() + "' for property '" + value + "'"); LOGGER.trace("Create List new 'SUB' class: '" + typeClass.getCanonicalName() + "' for property '" + value + "'");
final IntrospectionModel inferData = this.cacheModel.findOrCreate(ModelType.NORMAL, null, subTypeClass); final IntrospectionModel inferData = this.cacheModel.findOrCreate(ModelType.NORMAL, null, subTypeClass);
final List<Object> out = new ArrayList<>(); final List<Object> out = new ArrayList<>();
for (int iii = 0; iii < elems.length; iii++) { for (int iii = 0; iii < elems.length; iii++) {
@ -459,7 +462,7 @@ public class BuilderIntrospection implements Builder {
final String beanName = model.getBeanName(nodeName); final String beanName = model.getBeanName(nodeName);
if (beanName == null) { if (beanName == null) {
if (model.isIgnoreUnknown()) { if (model.isIgnoreUnknown()) {
Log.debug("Ignore node : '" + nodeName + "'"); LOGGER.debug("Ignore node : '" + nodeName + "'");
return; return;
} }
throw new EjsonBuilderException("The node '" + nodeName + "' Does not exist..."); throw new EjsonBuilderException("The node '" + nodeName + "' Does not exist...");
@ -484,7 +487,7 @@ public class BuilderIntrospection implements Builder {
} else if (List.class.isAssignableFrom(typeClass)) { } else if (List.class.isAssignableFrom(typeClass)) {
final String[] elems = value.split(";"); final String[] elems = value.split(";");
final Class<?> subTypeClass = introspectionObject.getTypeOfSubNode(value, true); final Class<?> subTypeClass = introspectionObject.getTypeOfSubNode(value, true);
Log.verbose("Create List new 'SUB' class: '" + typeClass.getCanonicalName() + "' for property '" + value + "'"); LOGGER.trace("Create List new 'SUB' class: '" + typeClass.getCanonicalName() + "' for property '" + value + "'");
final IntrospectionModel inferData = this.cacheModel.findOrCreate(ModelType.NORMAL, null, subTypeClass); final IntrospectionModel inferData = this.cacheModel.findOrCreate(ModelType.NORMAL, null, subTypeClass);
final List<Object> out = new ArrayList<>(); final List<Object> out = new ArrayList<>();
for (int iii = 0; iii < elems.length; iii++) { for (int iii = 0; iii < elems.length; iii++) {

View File

@ -7,11 +7,14 @@ import java.util.Map;
import org.atriasoft.aknot.exception.AknotException; import org.atriasoft.aknot.exception.AknotException;
import org.atriasoft.aknot.model.IntrospectionModel; import org.atriasoft.aknot.model.IntrospectionModel;
import org.atriasoft.aknot.pojo.IntrospectionProperty;
import org.atriasoft.ejson.exception.EjsonException; import org.atriasoft.ejson.exception.EjsonException;
import org.atriasoft.ejson.exception.EjsonNodeDoesNotExist; import org.atriasoft.ejson.exception.EjsonNodeDoesNotExist;
import org.atriasoft.ejson.internal.Log; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class IntrospectionObject { public class IntrospectionObject {
final static Logger LOGGER = LoggerFactory.getLogger(IntrospectionObject.class);
public static final String PUBLIC_TEXT_NAME = "##<< ** TEXT-ZONE ** >>##"; public static final String PUBLIC_TEXT_NAME = "##<< ** TEXT-ZONE ** >>##";
private final IntrospectionModel modelInterface; private final IntrospectionModel modelInterface;
private Object data = null; private Object data = null;
@ -23,19 +26,19 @@ public class IntrospectionObject {
} }
public void addData(final Object value) throws AknotException, EjsonException { public void addData(final Object value) throws AknotException, EjsonException {
Log.warning("Add Object in list {}", value); LOGGER.warn("Add Object in list {}", value);
final Object value2 = this.modelInterface.getValueConverted(value, this.modelInterface.getClassType()); final Object value2 = this.modelInterface.getValueConverted(value, this.modelInterface.getClassType());
final String uniqueName = this.modelInterface.getTokenBasicList(); final String uniqueName = this.modelInterface.getTokenBasicList();
if (!this.nodes.containsKey(uniqueName)) { if (!this.nodes.containsKey(uniqueName)) {
final List<Object> tmp = new ArrayList<>(); final List<Object> tmp = new ArrayList<>();
tmp.add(value2); tmp.add(value2);
Log.warning(" ==> new list"); LOGGER.warn(" ==> new list");
this.nodes.put(uniqueName, tmp); this.nodes.put(uniqueName, tmp);
} else { } else {
Log.warning(" ==> previous list"); LOGGER.warn(" ==> previous list");
this.nodes.get(uniqueName).add(value2); this.nodes.get(uniqueName).add(value2);
Log.warning(" >> {}", this.nodes.get(uniqueName)); LOGGER.warn(" >> {}", this.nodes.get(uniqueName));
} }
} }
@ -60,14 +63,14 @@ public class IntrospectionObject {
if (List.class.isAssignableFrom(value.getClass())) { if (List.class.isAssignableFrom(value.getClass())) {
node = (List<Object>) value; node = (List<Object>) value;
} else if (value.getClass().isArray()) { } else if (value.getClass().isArray()) {
Log.error("this is a big problem ..."); LOGGER.error("this is a big problem ...");
} else { } else {
node = new ArrayList<>(); node = new ArrayList<>();
node.add(value); node.add(value);
} }
this.nodes.put(beanName, node); this.nodes.put(beanName, node);
} else if (value.getClass().isArray()) { } else if (value.getClass().isArray()) {
Log.error("this is a big problem ..."); LOGGER.error("this is a big problem ...");
} else if (List.class.isAssignableFrom(value.getClass())) { } else if (List.class.isAssignableFrom(value.getClass())) {
final List<Object> nodeIn = (List<Object>) value; final List<Object> nodeIn = (List<Object>) value;
node.addAll(nodeIn); node.addAll(nodeIn);
@ -81,10 +84,10 @@ public class IntrospectionObject {
// nothing to do ... ==> element already created // nothing to do ... ==> element already created
return; return;
} }
Log.warning("Create the element for the Specific node ... type = " + this.modelInterface.getClassType().getCanonicalName() + (this.modelInterface.isArray() ? "[array]" : "") LOGGER.warn("Create the element for the Specific node ... type = " + this.modelInterface.getClassType().getCanonicalName() + (this.modelInterface.isArray() ? "[array]" : "")
+ (this.modelInterface.isList() ? "[List]" : "")); + (this.modelInterface.isList() ? "[List]" : ""));
Log.warning(" Properties : " + this.properties.keySet()); LOGGER.warn(" Properties : " + this.properties.keySet());
Log.warning(" Nodes : " + this.nodes.keySet()); LOGGER.warn(" Nodes : " + this.nodes.keySet());
this.data = this.modelInterface.createObject(this.properties, this.nodes, attributeIndependent); this.data = this.modelInterface.createObject(this.properties, this.nodes, attributeIndependent);
} }

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.ejson.internal;
import org.atriasoft.reggol.LogLevel;
import org.atriasoft.reggol.Logger;
public class Log {
private static final boolean FORCE_ALL = false;
private static final String LIB_NAME = "ejson";
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

@ -9,13 +9,16 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import org.atriasoft.aknot.pojo.IntrospectionProperty;
import org.atriasoft.ejson.exception.EjsonNodeDoesNotExist; import org.atriasoft.ejson.exception.EjsonNodeDoesNotExist;
import org.atriasoft.ejson.internal.Log; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Basic element Node of an XML document lt;YYYYYgt; * Basic element Node of an XML document lt;YYYYYgt;
*/ */
public class JsonArray extends JsonNode { public class JsonArray extends JsonNode {
final static Logger LOGGER = LoggerFactory.getLogger(JsonArray.class);
protected List<JsonNode> listSub = new ArrayList<>(); //!< List of subNodes; protected List<JsonNode> listSub = new ArrayList<>(); //!< List of subNodes;
/** /**
@ -30,12 +33,12 @@ public class JsonArray extends JsonNode {
*/ */
public void add(final JsonNode node) { public void add(final JsonNode node) {
if (node == null) { if (node == null) {
Log.error("Try to set an empty node"); LOGGER.error("Try to set an empty node");
return; return;
} }
for (final JsonNode jsonNode : this.listSub) { for (final JsonNode jsonNode : this.listSub) {
if (jsonNode == node) { if (jsonNode == node) {
Log.error("Try to add a node that is already added before !!!"); LOGGER.error("Try to add a node that is already added before !!!");
return; return;
} }
} }

View File

@ -9,8 +9,10 @@ import java.util.Collections;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import org.atriasoft.aknot.pojo.IntrospectionProperty;
import org.atriasoft.ejson.exception.EjsonNodeDoesNotExist; import org.atriasoft.ejson.exception.EjsonNodeDoesNotExist;
import org.atriasoft.ejson.internal.Log; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** @file /** @file
* @author Edouard DUPIN * @author Edouard DUPIN
@ -21,6 +23,7 @@ import org.atriasoft.ejson.internal.Log;
* Basic element Node of an JSON document &lt;&gt; * Basic element Node of an JSON document &lt;&gt;
*/ */
public class JsonObject extends JsonNode { public class JsonObject extends JsonNode {
final static Logger LOGGER = LoggerFactory.getLogger(JsonObject.class);
protected Map<String, JsonNode> listSub = new LinkedHashMap<>(); // !< List of subNodes; protected Map<String, JsonNode> listSub = new LinkedHashMap<>(); // !< List of subNodes;
/** /**
@ -93,7 +96,7 @@ public class JsonObject extends JsonNode {
*/ */
public void put(final String nodeName, final JsonNode node) { public void put(final String nodeName, final JsonNode node) {
if (node == null) { if (node == null) {
Log.error("Try to set an empty node"); LOGGER.error("Try to set an empty node");
return; return;
} }
this.listSub.put(nodeName, node); this.listSub.put(nodeName, node);

View File

@ -1,16 +1,19 @@
package org.atriasoft.ejson.parser; package org.atriasoft.ejson.parser;
import org.atriasoft.aknot.exception.AknotException; import org.atriasoft.aknot.exception.AknotException;
import org.atriasoft.aknot.pojo.IntrospectionProperty;
import org.atriasoft.ejson.builder.Builder; import org.atriasoft.ejson.builder.Builder;
import org.atriasoft.ejson.exception.EjsonBuilderException; import org.atriasoft.ejson.exception.EjsonBuilderException;
import org.atriasoft.ejson.exception.EjsonException; import org.atriasoft.ejson.exception.EjsonException;
import org.atriasoft.ejson.exception.EjsonParserError; import org.atriasoft.ejson.exception.EjsonParserError;
import org.atriasoft.ejson.exception.EjsonParserErrorMulti; import org.atriasoft.ejson.exception.EjsonParserErrorMulti;
import org.atriasoft.ejson.internal.Log;
import org.atriasoft.etk.Tools; import org.atriasoft.etk.Tools;
import org.atriasoft.etk.util.FilePos; import org.atriasoft.etk.util.FilePos;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ParseJson { public class ParseJson {
final static Logger LOGGER = LoggerFactory.getLogger(ParseJson.class);
// global builder that is generate the final Tree // global builder that is generate the final Tree
private final Builder builder; private final Builder builder;
@ -244,7 +247,7 @@ public class ParseJson {
} }
public Object parse(final String data, final ParsingProperty property) throws EjsonException, AknotException { public Object parse(final String data, final ParsingProperty property) throws EjsonException, AknotException {
Log.verbose("Start parsing document (type: string) size={}", data.length()); //LOGGER.trace("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);
final PositionParsing parsePos = new PositionParsing(); final PositionParsing parsePos = new PositionParsing();

View File

@ -4,11 +4,14 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import org.atriasoft.aknot.pojo.IntrospectionProperty;
import org.atriasoft.ejson.exception.EjsonParserError; import org.atriasoft.ejson.exception.EjsonParserError;
import org.atriasoft.ejson.internal.Log;
import org.atriasoft.etk.Tools; import org.atriasoft.etk.Tools;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ParsingProperty { public class ParsingProperty {
final static Logger LOGGER = LoggerFactory.getLogger(ParsingProperty.class);
/// check the case sensitive of the nodes (end marker) and attribute (duplicates) /// check the case sensitive of the nodes (end marker) and attribute (duplicates)
private boolean caseSensitive = true; private boolean caseSensitive = true;
// List of all error detected // List of all error detected
@ -71,7 +74,7 @@ public class ParsingProperty {
* @param error The error to display. * @param error The error to display.
*/ */
public void displayError(final EjsonParserError error) { public void displayError(final EjsonParserError error) {
Log.error("{} {}\n{}\n", error.getFilePos(), error.getMessage(), error.getDataLine(), Tools.createPosPointer(error.getDataLine(), error.getFilePos().getCol())); LOGGER.error("{} {}\n{}\n", error.getFilePos(), error.getMessage(), error.getDataLine(), Tools.createPosPointer(error.getDataLine(), error.getFilePos().getCol()));
} }
/** /**

View File

@ -0,0 +1,35 @@
# SLF4J's SimpleLogger configuration file
# Simple implementation of Logger that sends all enabled log messages, for all defined loggers, to System.err.
# Default logging detail level for all instances of SimpleLogger.
# Must be one of ("trace", "debug", "info", "warn", or "error").
# If not specified, defaults to "info".
org.slf4j.simpleLogger.defaultLogLevel=trace
# Logging detail level for a SimpleLogger instance named "xxxxx".
# Must be one of ("trace", "debug", "info", "warn", or "error").
# If not specified, the default logging detail level is used.
#org.slf4j.simpleLogger.log.xxxxx=
# Set to true if you want the current date and time to be included in output messages.
# Default is false, and will output the number of milliseconds elapsed since startup.
#org.slf4j.simpleLogger.showDateTime=false
# The date and time format to be used in the output messages.
# The pattern describing the date and time format is the same that is used in java.text.SimpleDateFormat.
# If the format is not specified or is invalid, the default format is used.
# The default format is yyyy-MM-dd HH:mm:ss:SSS Z.
#org.slf4j.simpleLogger.dateTimeFormat=yyyy-MM-dd HH:mm:ss:SSS Z
# Set to true if you want to output the current thread name.
# Defaults to true.
org.slf4j.simpleLogger.showThreadName=true
# Set to true if you want the Logger instance name to be included in output messages.
# Defaults to true.
#org.slf4j.simpleLogger.showLogName=true
# Set to true if you want the last component of the name to be included in output messages.
# Defaults to false.
#org.slf4j.simpleLogger.showShortLogName=false

View File

@ -7,15 +7,18 @@ package test.atriasoft.ejson.generic;
import org.atriasoft.ejson.Ejson; import org.atriasoft.ejson.Ejson;
import org.atriasoft.ejson.model.JsonNode; import org.atriasoft.ejson.model.JsonNode;
import org.atriasoft.ejson.parser.ParsingProperty;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import test.atriasoft.ejson.internal.Log;
class EjsonLocal { class EjsonLocal {
final static Logger LOGGER = LoggerFactory.getLogger(ParsingProperty.class);
// errorPos : -1 : no error , 1 : parsing error, 2 generation error, 3 comparaison error ???? // errorPos : -1 : no error , 1 : parsing error, 2 generation error, 3 comparaison error ????
public static void test(final String ref, final String input, final int errorPos) { public static void test(final String ref, final String input, final int errorPos) {
//doc.setCaseSensitive(!caseInSensitive); //doc.setCaseSensitive(!caseInSensitive);
Log.verbose("parse : \n{}", input); LOGGER.trace("parse : \n{}", input);
JsonNode root = null; JsonNode root = null;
try { try {
root = Ejson.parse(input); root = Ejson.parse(input);

View File

@ -7,10 +7,12 @@ package test.atriasoft.ejson.generic;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import test.atriasoft.ejson.internal.Log;
public class EjsonTestAll { public class EjsonTestAll {
final static Logger LOGGER = LoggerFactory.getLogger(EjsonTestAll.class);
//@formatter:off //@formatter:off
private static String refOutputAll = """ private static String refOutputAll = """
{ {
@ -31,7 +33,7 @@ public class EjsonTestAll {
@BeforeAll @BeforeAll
public static void beforeClass() { public static void beforeClass() {
Log.verbose("----------------------------------------------------------------"); LOGGER.trace("----------------------------------------------------------------");
} }
@Test @Test

View File

@ -8,17 +8,19 @@ package test.atriasoft.ejson.generic;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import test.atriasoft.ejson.internal.Log;
public class EjsonTestBoolean { public class EjsonTestBoolean {
final static Logger LOGGER = LoggerFactory.getLogger(EjsonTestBoolean.class);
private static String refOutputBoolean1 = "{\n\t\"tmpElement\": true\n}"; private static String refOutputBoolean1 = "{\n\t\"tmpElement\": true\n}";
private static String refOutputBoolean2 = "{\n\t\"tmpElement\": false\n}"; private static String refOutputBoolean2 = "{\n\t\"tmpElement\": false\n}";
@BeforeAll @BeforeAll
public static void beforeClass() { public static void beforeClass() {
Log.verbose("----------------------------------------------------------------"); LOGGER.trace("----------------------------------------------------------------");
} }
@Test @Test

View File

@ -8,15 +8,17 @@ package test.atriasoft.ejson.generic;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import test.atriasoft.ejson.internal.Log;
public class EjsonTestNull { public class EjsonTestNull {
final static Logger LOGGER = LoggerFactory.getLogger(EjsonTestNull.class);
private static final String REF_OUTPUT_NULL = "{\n\t\"tmpElement\": null\n}"; private static final String REF_OUTPUT_NULL = "{\n\t\"tmpElement\": null\n}";
@BeforeAll @BeforeAll
public static void beforeClass() { public static void beforeClass() {
Log.verbose("----------------------------------------------------------------"); LOGGER.trace("----------------------------------------------------------------");
} }
@Test @Test

View File

@ -8,15 +8,17 @@ package test.atriasoft.ejson.generic;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import test.atriasoft.ejson.internal.Log;
public class EjsonTestNumber { public class EjsonTestNumber {
final static Logger LOGGER = LoggerFactory.getLogger(EjsonTestNumber.class);
private static final String REF_OUTPUT_NUMBER = "{\n\t\"tmpElement\": 956256\n}"; private static final String REF_OUTPUT_NUMBER = "{\n\t\"tmpElement\": 956256\n}";
@BeforeAll @BeforeAll
public static void beforeClass() { public static void beforeClass() {
Log.verbose("----------------------------------------------------------------"); LOGGER.trace("----------------------------------------------------------------");
} }
@Test @Test

View File

@ -1,82 +0,0 @@
package test.atriasoft.ejson.internal;
/** @file
* @author Edouard DUPIN
* @copyright 2021, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
import org.atriasoft.reggol.LogLevel;
import org.atriasoft.reggol.Logger;
public class Log {
private static final boolean FORCE_ALL = false;
private static final String LIB_NAME = "ejson-test";
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

@ -15,8 +15,9 @@ import org.atriasoft.ejson.exception.EjsonParserErrorMulti;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import test.atriasoft.ejson.internal.Log;
import test.atriasoft.ejson.introspection.model.ClassMethodEnum; import test.atriasoft.ejson.introspection.model.ClassMethodEnum;
import test.atriasoft.ejson.introspection.model.ClassPublicChild; import test.atriasoft.ejson.introspection.model.ClassPublicChild;
import test.atriasoft.ejson.introspection.model.ClassPublicMemberOnly; import test.atriasoft.ejson.introspection.model.ClassPublicMemberOnly;
@ -26,9 +27,10 @@ import test.atriasoft.ejson.introspection.model.ClassPublicMethodeStructured;
import test.atriasoft.ejson.introspection.model.SimpleEnum; import test.atriasoft.ejson.introspection.model.SimpleEnum;
public class EjsonTestIntrospection { public class EjsonTestIntrospection {
final static Logger LOGGER = LoggerFactory.getLogger(EjsonTestIntrospection.class);
@BeforeAll @BeforeAll
public static void beforeClass() { public static void beforeClass() {
Log.verbose("----------------------------------------------------------------"); LOGGER.trace("----------------------------------------------------------------");
} }
@Test @Test