diff --git a/.classpath b/.classpath index bb8e2b8..96b17c1 100644 --- a/.classpath +++ b/.classpath @@ -1,13 +1,14 @@ - + + - + - + @@ -20,5 +21,17 @@ - + + + + + + + + + + + + + diff --git a/.project b/.project index 8aa93d3..5946bd9 100644 --- a/.project +++ b/.project @@ -16,8 +16,14 @@ + + org.eclipse.m2e.core.maven2Builder + + + + org.eclipse.m2e.core.maven2Nature org.eclipse.jdt.core.javanature net.sf.eclipsecs.core.CheckstyleNature diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..e5147a7 --- /dev/null +++ b/pom.xml @@ -0,0 +1,119 @@ + + 4.0.0 + org.atriasoft + death + 0.1.0 + + 3.1 + 17 + 17 + + 3.1.1 + + + + + gitea + https://gitea.atria-soft.org/api/packages/org.atriasoft/maven + + + + + gitea + https://gitea.atria-soft.org/api/packages/org.atriasoft/maven + + + gitea + https://gitea.atria-soft.org/api/packages/org.atriasoft/maven + + + + + + org.junit.jupiter + junit-jupiter-api + 5.9.3 + test + + + org.slf4j + slf4j-simple + 2.0.7 + test + + + + + src + test/src + ${project.basedir}/out/maven/ + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven.compiler.version} + + ${maven.compiler.source} + ${maven.compiler.target} + + + + + + org.apache.maven.plugins + maven-source-plugin + + + attach-sources + + jar + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M5 + + + maven-assembly-plugin + + + + fully.qualified.MainClass + + + + jar-with-dependencies + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.2.0 + + private + true + + + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.2.0 + + public + + + + + + diff --git a/src/org/atriasoft/death/ActionList.java b/src/org/atriasoft/death/ActionList.java index e0b0062..9a84fd5 100644 --- a/src/org/atriasoft/death/ActionList.java +++ b/src/org/atriasoft/death/ActionList.java @@ -12,7 +12,7 @@ public class ActionList { public void add(final Class clazz) { final String name = PropertiesInterface.getCommand(clazz); if (name == null || name.isEmpty()) { - Log.error("Can not add an action without name. for: {}", clazz.getCanonicalName()); + LOGGER.error("Can not add an action without name. for: {}", clazz.getCanonicalName()); return; } this.subActions.put(name, clazz); diff --git a/src/org/atriasoft/death/ArgumentManager.java b/src/org/atriasoft/death/ArgumentManager.java index 5e32216..9b17176 100644 --- a/src/org/atriasoft/death/ArgumentManager.java +++ b/src/org/atriasoft/death/ArgumentManager.java @@ -46,78 +46,78 @@ public class ArgumentManager { if (value.startsWith("--")) { final String[] elements = value.split("="); elements[0] = elements[0].substring(2); - Log.verbose("find element (--) : {}", Arrays.toString(elements)); + LOGGER.trace("find element (--) : {}", Arrays.toString(elements)); final String parameter = elements[0]; String newValue = null; if (!this.properties.existParameter(parameter)) { - Log.error("Parameter Does not exist for '{}'", value); + LOGGER.error("Parameter Does not exist for '{}'", value); showHelpAndExitError(); } if (!this.properties.haveParameter(parameter)) { // Boolean value if (elements.length != 1) { - Log.error("Boolean parameter can not have parameters for '{}", value); + LOGGER.error("Boolean parameter can not have parameters for '{}", value); showHelpAndExitError(); } } else if (elements.length == 1) { if (iii == this.arguments.size() - 1) { - Log.error("Missing parameters for '{}' (no more arguments)", value); + LOGGER.error("Missing parameters for '{}' (no more arguments)", value); showHelpAndExitError(); } newValue = this.arguments.get(iii + 1); if (newValue.startsWith("-")) { - Log.error("Missing parameters for '{}' (next argument is a parameter (start with '-'))", value); + LOGGER.error("Missing parameters for '{}' (next argument is a parameter (start with '-'))", value); showHelpAndExitError(); } iii++; } else if (elements.length == 2) { newValue = elements[1]; } else { - Log.error("too much parameters for '{}' (only 1 = is authorized)", value); + LOGGER.error("too much parameters for '{}' (only 1 = is authorized)", value); showHelpAndExitError(); } this.properties.setParameter(tmp, parameter, newValue); } else if (value.startsWith("-")) { final String[] elements = value.split("="); elements[0] = elements[0].substring(1); - Log.verbose("find element (-) : {}", Arrays.toString(elements)); + LOGGER.trace("find element (-) : {}", Arrays.toString(elements)); if (elements[0].length() != 1) { - Log.error("Can not parse alias argument with a size != 1 for '{}'", value); + LOGGER.error("Can not parse alias argument with a size != 1 for '{}'", value); showHelpAndExitError(); } final char parameter = elements[0].charAt(0); String newValue = null; if (!this.properties.existParameterAlias(parameter)) { - Log.error("Parameter Does not exist for '{}'", value); + LOGGER.error("Parameter Does not exist for '{}'", value); showHelpAndExitError(); } if (!this.properties.haveParameterAlias(parameter)) { // Boolean value if (elements.length != 1) { - Log.critical("Boolean parameter can not have parameters for '{}'", value); + LOGGER.critical("Boolean parameter can not have parameters for '{}'", value); showHelpAndExitError(); } } else if (elements.length == 1) { if (iii == this.arguments.size() - 1) { - Log.error("Missing parameters for '{}' (no more arguments)", value); + LOGGER.error("Missing parameters for '{}' (no more arguments)", value); showHelpAndExitError(); } newValue = this.arguments.get(iii + 1); if (newValue.startsWith("-")) { - Log.error("Missing parameters for '{}' (next argument is a parameter (start with '-'))", value); + LOGGER.error("Missing parameters for '{}' (next argument is a parameter (start with '-'))", value); showHelpAndExitError(); } iii++; } else if (elements.length == 2) { newValue = elements[1]; } else { - Log.error("too much parameters for '{}' (only 1 = is authorized)", value); + LOGGER.error("too much parameters for '{}' (only 1 = is authorized)", value); showHelpAndExitError(); } this.properties.setParameterAlias(tmp, parameter, newValue); } else { - Log.verbose("find element ( ) : {}", value); + LOGGER.trace("find element ( ) : {}", value); if (this.properties.actions != null && this.properties.actions.exist(value)) { // Find end of parsing ... endParsing = true; @@ -153,10 +153,10 @@ public class ArgumentManager { final List executor = localManager.properties.getExecutor(); for (final Method exec : executor) { if (nbParameters != exec.getParameterCount()) { - Log.error("Rejected executor, {} nbParameter={} injected={}", exec.getName(), exec.getParameterCount(), nbParameters); + LOGGER.error("Rejected executor, {} nbParameter={} injected={}", exec.getName(), exec.getParameterCount(), nbParameters); continue; } - Log.verbose("find executor, {}", exec.getName()); + LOGGER.trace("find executor, {}", exec.getName()); try { switch (nbParameters) { case 0: @@ -258,7 +258,7 @@ public class ArgumentManager { localManager.argumentPostConfigure.get(10)); break; default: - Log.error("Does not manage more than 11 arguments"); + LOGGER.error("Does not manage more than 11 arguments"); break; } } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { diff --git a/src/org/atriasoft/death/FieldProperty.java b/src/org/atriasoft/death/FieldProperty.java index d3a880a..2d1a467 100644 --- a/src/org/atriasoft/death/FieldProperty.java +++ b/src/org/atriasoft/death/FieldProperty.java @@ -75,7 +75,7 @@ public class FieldProperty { list += elem; } list += "]"; - Log.critical("Can not find property '{}'in the choice values : {}", newValue, list); + LOGGER.critical("Can not find property '{}'in the choice values : {}", newValue, list); return null; } @@ -98,19 +98,19 @@ public class FieldProperty { public void print() { if (this.name != null) { - Log.print("Detect element: --{}", this.name); + LOGGER.print("Detect element: --{}", this.name); } if (this.alias != null) { - Log.print(" alias: -{}", this.alias); + LOGGER.print(" alias: -{}", this.alias); } if (this.types[1] == null) { - Log.print(" type: {}", this.types[0].getCanonicalName()); + LOGGER.print(" type: {}", this.types[0].getCanonicalName()); } else { - Log.print(" type: {} / {}", this.types[0].getCanonicalName(), this.types[1].getCanonicalName()); + LOGGER.print(" type: {} / {}", this.types[0].getCanonicalName(), this.types[1].getCanonicalName()); } - Log.print(" description: {}", this.description); + LOGGER.print(" description: {}", this.description); if (this.choice != null) { - Log.print(" choice: {}", Arrays.toString(this.choice)); + LOGGER.print(" choice: {}", Arrays.toString(this.choice)); } } } diff --git a/src/org/atriasoft/death/PropertiesInterface.java b/src/org/atriasoft/death/PropertiesInterface.java index 962278e..7b2d238 100644 --- a/src/org/atriasoft/death/PropertiesInterface.java +++ b/src/org/atriasoft/death/PropertiesInterface.java @@ -50,7 +50,7 @@ public class PropertiesInterface { // -- Find property Field // ------------------------------------------------------------------------ final Field[] fields = clazz.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())) { @@ -63,13 +63,13 @@ public class PropertiesInterface { if (type[0] == ActionList.class) { final Object data = elem.get(null); if (data == null) { - Log.error("set a @ArgSubActions on a wrong field"); + LOGGER.error("set a @ArgSubActions on a wrong field"); } else if (data instanceof final ActionList tmp) { this.actions = tmp; } } } catch (final Exception e) { - Log.error("get error on @ArgSubActions !!!"); + LOGGER.error("get error on @ArgSubActions !!!"); e.printStackTrace(); } continue; @@ -88,7 +88,7 @@ public class PropertiesInterface { || element.types[0] == double.class || element.types[0] == Double.class || element.types[0] == String.class) { // all is good } else { - Log.error("Can not manage other type than: [boolean,Boolean,String,int,Integer,long,Long,short,Short,float,Float,double,Double]"); + LOGGER.error("Can not manage other type than: [boolean,Boolean,String,int,Integer,long,Long,short,Short,float,Float,double,Double]"); } this.properties.add(element); //element.print(); @@ -98,7 +98,7 @@ public class PropertiesInterface { // ------------------------------------------------------------------------ final Method[] methods = clazz.getMethods(); for (final Method elem : methods) { - Log.verbose("Detect function : {}", elem.getName()); + LOGGER.trace("Detect function : {}", elem.getName()); // we does not manage static field if (Modifier.isStatic(elem.getModifiers())) { continue; @@ -130,12 +130,12 @@ public class PropertiesInterface { public void displayHelp(final boolean withActions, int baseIndent) { if (baseIndent == 0) { - Log.print("Usage:"); + LOGGER.print("Usage:"); } final StringBuilder applicationLine = new StringBuilder(spaces(4 + baseIndent)); if (baseIndent != 0) { baseIndent += 4; - Log.print("{}-----------------------------", spaces(baseIndent)); + LOGGER.print("{}-----------------------------", spaces(baseIndent)); } if (this.classCommand != null) { applicationLine.append(this.classCommand).append(" "); @@ -148,37 +148,37 @@ public class PropertiesInterface { if (this.actions != null && this.actions.getActions().size() != 0) { applicationLine.append(" [options-action]"); } - Log.print(applicationLine.toString()); + LOGGER.print(applicationLine.toString()); if (this.classDescription != null) { - Log.print("{}{}", spaces(baseIndent), this.classDescription); + LOGGER.print("{}{}", spaces(baseIndent), this.classDescription); } if (this.properties.size() != 0) { - Log.print("{} [options]", spaces(baseIndent)); + LOGGER.print("{} [options]", spaces(baseIndent)); for (final FieldProperty prop : this.properties) { final String parameterExpect = haveParameter(prop) ? " [PARAMETER]" : ""; if (prop.alias != null && prop.name != null) { - Log.print("{} -{} / --{}{}", spaces(baseIndent), prop.alias, prop.name, parameterExpect); + LOGGER.print("{} -{} / --{}{}", spaces(baseIndent), prop.alias, prop.name, parameterExpect); } else if (prop.alias != null) { - Log.print("{} -{}{}", spaces(baseIndent), prop.alias, parameterExpect); + LOGGER.print("{} -{}{}", spaces(baseIndent), prop.alias, parameterExpect); } else if (prop.name != null) { - Log.print("{} --{}{}", spaces(baseIndent), prop.name, parameterExpect); + LOGGER.print("{} --{}{}", spaces(baseIndent), prop.name, parameterExpect); } if (prop.description != null) { - Log.print("{} {}", spaces(baseIndent), prop.description); + LOGGER.print("{} {}", spaces(baseIndent), prop.description); } if (prop.choice != null) { for (final ChoiceElement elem : prop.getChoiceList()) { if (elem.destination() == null) { - Log.print("{} - {}", spaces(baseIndent), elem.origin()); + LOGGER.print("{} - {}", spaces(baseIndent), elem.origin()); } else { - Log.print("{} - {} ==> {}", spaces(baseIndent), elem.origin(), elem.destination()); + LOGGER.print("{} - {} ==> {}", spaces(baseIndent), elem.origin(), elem.destination()); } } } } } if (this.actions != null && this.actions.getActions().size() != 0) { - Log.print("{} ", spaces(baseIndent)); + LOGGER.print("{} ", spaces(baseIndent)); final Set actions = this.actions.getActions(); int sizeOfActions = 0; @@ -190,10 +190,10 @@ public class PropertiesInterface { if (!withActions) { final String description = PropertiesInterface.getDescription(clazz); if (description == null || description.isEmpty()) { - Log.print("{} {}", spaces(baseIndent), action); + LOGGER.print("{} {}", spaces(baseIndent), action); } else { final String emptyString = spaces(sizeOfActions - action.length()); - Log.print("{} {}:{} {}", spaces(baseIndent), action, emptyString, description); + LOGGER.print("{} {}:{} {}", spaces(baseIndent), action, emptyString, description); } } else { final PropertiesInterface tmpInterface = new PropertiesInterface(clazz); @@ -201,8 +201,8 @@ public class PropertiesInterface { } } if (!withActions) { - Log.print(" [options-action]"); - Log.print(" Action have theire specifi help. (add -h or --help after action)"); + LOGGER.print(" [options-action]"); + LOGGER.print(" Action have theire specifi help. (add -h or --help after action)"); } } } @@ -292,11 +292,11 @@ public class PropertiesInterface { property.field.set(tmp, newValue); } else { // Impossible case !!! - Log.critical("Dead code"); + LOGGER.critical("Dead code"); } } catch (IllegalArgumentException | IllegalAccessException e) { // TODO Auto-generated catch block - Log.critical("Can not SET the value : {}: {}", parameter, newValue); + LOGGER.critical("Can not SET the value : {}: {}", parameter, newValue); } } diff --git a/src/org/atriasoft/death/ReflectTools.java b/src/org/atriasoft/death/ReflectTools.java index 93b548e..777b5e6 100644 --- a/src/org/atriasoft/death/ReflectTools.java +++ b/src/org/atriasoft/death/ReflectTools.java @@ -137,9 +137,9 @@ public class ReflectTools { if (empppe.length > paramId) { if (empppe[paramId] instanceof final ParameterizedType plopppppp) { final Type[] realType = plopppppp.getActualTypeArguments(); - //Log.info("ppplllppp: {}", realType.length); + //LOGGER.info("ppplllppp: {}", realType.length); if (realType.length > 0) { - Log.warning(" -->> {}", realType[0]); + LOGGER.warn(" -->> {}", realType[0]); internalModelClass = Class.forName(realType[0].getTypeName()); } } @@ -161,7 +161,7 @@ public class ReflectTools { if (empppe[0] instanceof final ParameterizedType plopppppp) { final Type[] realType = plopppppp.getActualTypeArguments(); if (realType.length > 0) { - Log.warning(" -->> {}", realType[0]); + LOGGER.warn(" -->> {}", realType[0]); internalModelClass = Class.forName(realType[0].getTypeName()); } }