]> git.mxchange.org Git - jcore.git/blobdiff - src/org/mxchange/jcore/BaseFrameworkSystem.java
Sorted imports (NetBeans' choice?)
[jcore.git] / src / org / mxchange / jcore / BaseFrameworkSystem.java
index c0cdc9c0b60effd4d05c13681b1c033be6d4906a..db3b9ed493a30a629f68c05dca4bc866ee672162 100644 (file)
@@ -33,6 +33,7 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.ResourceBundle;
 import java.util.StringTokenizer;
+import java.util.logging.Level;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.mxchange.jcore.application.Application;
@@ -649,11 +650,14 @@ public class BaseFrameworkSystem implements FrameworkInterface {
         */
        protected Object getField (final FrameworkInterface instance, final String targetClass, final String methodName) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
                // Trace messahe
-               this.getLogger().trace(MessageFormat.format("targetClass={0},methodName={1}", targetClass, methodName)); //NOI18N
+               this.getLogger().trace(MessageFormat.format("instance={0},targetClass={1},methodName={2}", instance, targetClass, methodName)); //NOI18N
 
                // Get method to call
                Method method = this.getMethodFromName(instance, targetClass, methodName);
 
+               // Debug message
+               this.getLogger().debug("method=" + method + ",instance=" + instance);
+
                // Get value from field
                Object value = method.invoke(instance);
 
@@ -678,7 +682,7 @@ public class BaseFrameworkSystem implements FrameworkInterface {
         */
        protected void setField (final FrameworkInterface instance, final String targetClass, final String methodName, final String columnName, final Object value) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
                // Trace messahe
-               this.getLogger().trace(MessageFormat.format("targetClass={0},methodName={1},value={2}", targetClass, methodName, value)); //NOI18N
+               this.getLogger().trace(MessageFormat.format("instance={0},targetClass={1},methodName={2},value={3}", instance, targetClass, methodName, value)); //NOI18N
 
                // Get field type
                Class<?> type = this.getType(instance, targetClass, columnName);
@@ -686,11 +690,42 @@ public class BaseFrameworkSystem implements FrameworkInterface {
                // Debug message
                this.getLogger().debug("type=" + type);
 
+               // Init object
+               Object object = value;
+
+               // Hard-coded "cast" again ... :-(
+               // @TODO Can't we get rid of this???
+               switch (type.getSimpleName()) {
+                       case "Long": // Long object
+                               object = Long.parseLong((String) value);
+                               break;
+
+                       case "Float": // Float object
+                               object = Float.parseFloat((String) value);
+                               break;
+
+                       case "Boolean": // Boolean object
+                               object = Boolean.parseBoolean((String) value);
+                               break;
+
+                       case "String": // String object
+                               break;
+
+                       default: // Unsupported type
+                               throw new IllegalArgumentException("value " + value + " has unsupported type " + type.getSimpleName());
+               }
+
+               // Debug message
+               this.getLogger().debug("object[" + object.getClass().getSimpleName() + "]=" + object);
+
                // Get method to call
                Method method = this.getMethodFromName(instance, targetClass, methodName, type);
 
+               // Debug message
+               this.getLogger().debug("method=" + method + ",instance=" + instance + ",value[" + value.getClass().getSimpleName() + "]=" + value);
+
                // Get value from field
-               method.invoke(instance, value);
+               method.invoke(instance, object);
 
                // Trace messahe
                this.getLogger().trace("EXIT!");