From: Roland Haeder Date: Thu, 27 Aug 2015 13:33:54 +0000 (+0200) Subject: New jar for merging arrays added X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=651408dabcf01c536a64c13ec60e37a3ce4a22ae;p=jcore.git New jar for merging arrays added Signed-off-by:Roland Häder --- diff --git a/lib/commons-lang3-3.4.jar b/lib/commons-lang3-3.4.jar new file mode 100644 index 0000000..8ec91d4 Binary files /dev/null and b/lib/commons-lang3-3.4.jar differ diff --git a/nbproject/project.properties b/nbproject/project.properties index 33c94ac..8659f92 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -32,6 +32,7 @@ dist.javadoc.dir=${dist.dir}/javadoc endorsed.classpath= excludes= file.reference.commons-codec-1.10.jar=lib/commons-codec-1.10.jar +file.reference.commons-lang3-3.4.jar=lib\\commons-lang3-3.4.jar file.reference.log4j-api-2.3.jar=lib/log4j-api-2.3.jar file.reference.log4j-core-2.3.jar=lib/log4j-core-2.3.jar includes=** @@ -41,7 +42,8 @@ jar.index=${jnlp.enabled} javac.classpath=\ ${file.reference.log4j-api-2.3.jar}:\ ${file.reference.log4j-core-2.3.jar}:\ - ${file.reference.commons-codec-1.10.jar} + ${file.reference.commons-codec-1.10.jar}:\ + ${file.reference.commons-lang3-3.4.jar} # Space-separated list of extra javac options javac.compilerargs=-Xlint:unchecked javac.deprecation=true @@ -62,6 +64,7 @@ javadoc.nonavbar=false javadoc.notree=false javadoc.private=true javadoc.reference.commons-codec-1.10.jar=/home/quix0r/MyProjects/JARs/commons-codec-1.10-javadoc.jar +javadoc.reference.commons-lang3-3.4.jar=C:\\Users\\KLC\\JARs\\commons-lang3-3.4-javadoc.jar javadoc.reference.log4j-api-2.3.jar=/home/quix0r/MyProjects/JARs/log4j-api-2.3-javadoc.jar javadoc.splitindex=true javadoc.use=true @@ -96,6 +99,7 @@ run.test.classpath=\ ${build.test.classes.dir} source.encoding=UTF-8 source.reference.commons-codec-1.10.jar=/home/quix0r/MyProjects/JARs/commons-codec-1.10-sources.jar +source.reference.commons-lang3-3.4.jar=C:\\Users\\KLC\\JARs\\commons-lang3-3.4-src.zip!/commons-lang3-3.4-src/src/main/java/ source.reference.log4j-api-2.3.jar=/home/quix0r/MyProjects/JARs/log4j-api-2.3-sources.jar src.dir=src test.src.dir=test diff --git a/src/org/mxchange/jcore/BaseFrameworkSystem.java b/src/org/mxchange/jcore/BaseFrameworkSystem.java index 25a0d3c..5443e55 100644 --- a/src/org/mxchange/jcore/BaseFrameworkSystem.java +++ b/src/org/mxchange/jcore/BaseFrameworkSystem.java @@ -33,6 +33,7 @@ import java.util.Map; import java.util.Properties; import java.util.ResourceBundle; import java.util.StringTokenizer; +import org.apache.commons.lang3.ArrayUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.mxchange.jcore.application.Application; @@ -220,11 +221,27 @@ public class BaseFrameworkSystem implements FrameworkInterface { // Trace messahe this.getLogger().trace(MessageFormat.format("targetClass={0},methodName={1}", targetClass, methodName)); //NOI18N - // Get target class instance - Class c = this.getClassFromTarget(instance, targetClass); - // Init field instance - Method method = c.getDeclaredMethod(methodName, new Class[0]); + // Init method instance + Method method = null; + + // Try it from target class + try { + // Get target class instance + Class c = this.getClassFromTarget(instance, targetClass); + + // Init field instance + method = c.getDeclaredMethod(methodName, new Class[0]); + } catch (final NoSuchMethodException e) { + // Didn't found it + this.getLogger().warn(e); + + // So try it from super class + Class c = this.getClassFromTarget(instance, "BaseFrameworkSystem"); //NOI18N + + // Init field instance + method = c.getDeclaredMethod(methodName, new Class[0]); + } // Assert on field assert (method instanceof Method) : "method is not a Method instance"; //NOI18N @@ -249,11 +266,26 @@ public class BaseFrameworkSystem implements FrameworkInterface { // Trace messahe this.getLogger().trace(MessageFormat.format("targetClass={0},methodName={1},type={2}", targetClass, methodName, type)); //NOI18N - // Get target class instance - Class c = this.getClassFromTarget(instance, targetClass); + // Init method instance + Method method = null; - // Init field instance - Method method = c.getDeclaredMethod(methodName, type); + // Try it from target class + try { + // Get target class instance + Class c = this.getClassFromTarget(instance, targetClass); + + // Init field instance + method = c.getDeclaredMethod(methodName, type); + } catch (final NoSuchMethodException e) { + // Didn't found it + this.getLogger().warn(e); + + // So try it from super class + Class c = this.getClassFromTarget(instance, "BaseFrameworkSystem"); //NOI18N + + // Init field instance + method = c.getDeclaredMethod(methodName, type); + } // Assert on field assert (method instanceof Method) : "method is not a Method instance"; //NOI18N @@ -1191,8 +1223,11 @@ public class BaseFrameworkSystem implements FrameworkInterface { // Init field tye Class type = null; + // Get super class fields + Field[] superFields = this.getClassFromTarget(instance, "BaseFrameworkSystem").getDeclaredFields(); //NOI18N + // Get all attributes from given instance - Field[] fields = this.getClassFromTarget(instance, targetClass).getFields(); + Field[] fields = ArrayUtils.addAll(superFields, this.getClassFromTarget(instance, targetClass).getDeclaredFields()); // Debug message this.getLogger().debug(MessageFormat.format("fields()={0}", fields.length)); //NOI18N @@ -1222,7 +1257,7 @@ public class BaseFrameworkSystem implements FrameworkInterface { } // Debug message - this.getLogger().debug(MessageFormat.format("type={0}", type)); + this.getLogger().debug(MessageFormat.format("type={0}", type)); //NOI18N // type should not be null if (null == type) {