]> git.mxchange.org Git - jcore.git/commitdiff
Some fixes
authorRoland Haeder <roland@mxchange.org>
Fri, 7 Aug 2015 11:27:32 +0000 (13:27 +0200)
committerRoland Haeder <roland@mxchange.org>
Fri, 7 Aug 2015 11:27:53 +0000 (13:27 +0200)
Signed-off-by:Roland Häder <roland@mxchange.org>

src/org/mxchange/jcore/BaseFrameworkSystem.java
src/org/mxchange/jcore/FrameworkInterface.java
src/org/mxchange/jcore/contact/BaseContact.java

index 5f74161b26bd28c790a5ff9cada55dead595c118..33923f8263e121685e4b0fad7936e570b92cc921 100644 (file)
@@ -175,9 +175,10 @@ public class BaseFrameworkSystem implements FrameworkInterface {
         *
         * @param columnName Column name
         * @return Value from field
+        * @throws  IllegalArgumentException Some implementations may throw this.
         */
        @Override
-       public Object getValueFromColumn (final String columnName) {
+       public Object getValueFromColumn (final String columnName) throws IllegalArgumentException {
                throw new UnsupportedOperationException(MessageFormat.format("Not implemented. columnName={0}", columnName)); //NOI18N
        }
 
@@ -554,7 +555,7 @@ public class BaseFrameworkSystem implements FrameworkInterface {
        }
 
        /**
-        * Returns boolean field value from given method call
+        * Returns boolean field value from given method name by invoking it
         *
         * @param instance The instance to call
         * @param targetClass Target class to look in
@@ -598,7 +599,7 @@ public class BaseFrameworkSystem implements FrameworkInterface {
        }
 
        /**
-        * Returns any field value from given method call
+        * Returns any field value from given method name by invoking it
         *
         * @param instance The instance to call
         * @param targetClass Target class to look in
@@ -753,8 +754,7 @@ public class BaseFrameworkSystem implements FrameworkInterface {
        }
 
        /**
-        * Creates an iterator from given instance and class name. The class name
-        * is required in getValueFromColumn() to make a proper call.
+        * Creates an iterator from given instance and class name.
         * 
         * @param instance Instance to run getter calls on
         * @param className Class name to iterate over
@@ -765,18 +765,36 @@ public class BaseFrameworkSystem implements FrameworkInterface {
                this.getLogger().trace(MessageFormat.format("instance={0},className={1} - CALLED!", instance, className));
 
                // Get all attributes from given instance
-               Field[] fields = instance.getClass().getDeclaredFields();
+               Field[] fields = this.getClassFromTarget(instance, className).getDeclaredFields();
+
+               // Debug message
+               this.getLogger().debug(MessageFormat.format("Found {0} fields.", fields.length));
 
                // A list is fine
                List<Object> list = new ArrayList<>(fields.length);
 
                // Walk through all
                for (final Field field : fields) {
+                       // Debug log
+                       this.getLogger().debug(MessageFormat.format("field={0}", field.getName()));
+
+                       // Does the field start with "$"?
+                       if (field.getName().startsWith("$")) {
+                               // Skip it silently
+                               continue;
+                       }
+
                        // Get value from it
                        Object value = this.getValueFromColumn(field.getName());
 
+                       // Debug message
+                       this.getLogger().debug(MessageFormat.format("value={0}", value));
+
                        // Add it to list
-                       assert(list.add(value)) : MessageFormat.format("value {0} has not been added", value);
+                       boolean added = list.add(value);
+
+                       // Debug log
+                       this.getLogger().debug("added=" + added);
                }
 
                // Debug message
index 71ddb0079fc15e7379e4283481004cd6cb6b266d..57c6436b2ec3ea8c6e15e4762fafc2b45b80d39c 100644 (file)
@@ -95,6 +95,7 @@ public interface FrameworkInterface {
         *
         * @param columnName Column name
         * @return Value from field
+        * @throws IllegalArgumentException Some implementations may throw this
         */
-       public Object getValueFromColumn (final String columnName);
+       public Object getValueFromColumn (final String columnName) throws IllegalArgumentException;
 }
index 9085faa92c51f39ed415da4788e99fd7669ea024..2465158fa5b9dfa2ef9be258fabc820f88593354 100644 (file)
@@ -480,14 +480,23 @@ public class BaseContact extends BaseFrameworkSystem implements Contact {
         * @return Value from field
         */
        @Override
-       public Object getValueFromColumn (final String columnName) {
+       public Object getValueFromColumn (final String columnName) throws IllegalArgumentException {
                // Trace message
                this.getLogger().trace(MessageFormat.format("columnName={0} - CALLED!", columnName));
 
+               // A '$' means not our field
+               if (columnName.startsWith("$")) {
+                       // Don't handle these
+                       throw new IllegalArgumentException("columnsName contains $");
+               }
+
                // Determine if the given column is boolean
                if (this.isBooleanField(this, "BaseContact", columnName)) {
+                       // Debug message
+                       this.getLogger().debug("Column " + columnName + " represents a boolean field.");
+
                        // Yes, then call other method
-                       return this.getBooleanField(this, "BaseContact", columnName);
+                       return this.getBooleanField(this, "BaseContact", this.convertColumnNameToGetterMethod(columnName, true));
                }
 
                // Convert column name to field name