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;
*/
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);
*/
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);
// 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 "Object": // General object
+ 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!");