]> git.mxchange.org Git - jcore.git/commitdiff
Added supported (alpha quality) for null references + added more debug log
authorRoland Haeder <roland@mxchange.org>
Wed, 26 Aug 2015 12:37:54 +0000 (14:37 +0200)
committerRoland Haeder <roland@mxchange.org>
Wed, 26 Aug 2015 12:37:54 +0000 (14:37 +0200)
Signed-off-by:Roland Häder <roland@mxchange.org>

src/org/mxchange/jcore/BaseFrameworkSystem.java
src/org/mxchange/jcore/criteria/searchable/SearchCriteria.java

index 1723cc8b4696f195860bb0de7904ca9daf497e4f..047bcadb7340100988203b1f3435daad0b62e23b 100644 (file)
@@ -702,30 +702,39 @@ public class BaseFrameworkSystem implements FrameworkInterface {
                // Init object
                Object object = value;
 
-               // Hard-coded "cast" again ... :-(
-               // @TODO Can't we get rid of this???
-               switch (type.getSimpleName()) {
-                       case "Long": // Long object //NOI18N
-                               object = Long.parseLong((String) value);
-                               break;
-
-                       case "Float": // Float object //NOI18N
-                               object = Float.parseFloat((String) value);
-                               break;
-
-                       case "Boolean": // Boolean object //NOI18N
-                               object = Boolean.parseBoolean((String) value);
-                               break;
-
-                       case "String": // String object //NOI18N
-                               break;
+               // Is the value null?
+               if ("null".equals(value)) { //NOI18N
+                       // Warning message
+                       this.getLogger().warn(MessageFormat.format("columnName={0} has null value.", columnName)); //NOI18N
 
-                       default: // Unsupported type
-                               throw new IllegalArgumentException(MessageFormat.format("value {0} has unsupported type {1}", value, type.getSimpleName())); //NOI18N
+                       // Set null
+                       object = null;
+               } else {
+                       // Hard-coded "cast" again ... :-(
+                       // @TODO Can't we get rid of this???
+                       switch (type.getSimpleName()) {
+                               case "Long": // Long object //NOI18N
+                                       object = Long.parseLong((String) value);
+                                       break;
+
+                               case "Float": // Float object //NOI18N
+                                       object = Float.parseFloat((String) value);
+                                       break;
+
+                               case "Boolean": // Boolean object //NOI18N
+                                       object = Boolean.parseBoolean((String) value);
+                                       break;
+
+                               case "String": // String object //NOI18N
+                                       break;
+
+                               default: // Unsupported type
+                                       throw new IllegalArgumentException(MessageFormat.format("value {0} has unsupported type {1}", value, type.getSimpleName())); //NOI18N
+                       }
                }
 
                // Debug message
-               this.getLogger().debug(MessageFormat.format("object[{0}]={1}", object.getClass().getSimpleName(), object)); //NOI18N
+               this.getLogger().debug(MessageFormat.format("object={0}", object)); //NOI18N
 
                // Get method to call
                Method method = this.getMethodFromName(instance, targetClass, methodName, type);
@@ -1153,19 +1162,30 @@ public class BaseFrameworkSystem implements FrameworkInterface {
                // Convert column_name to fieldName ;-)
                String fieldName = this.convertColumnNameToFieldName(columnName);
 
+               // Debug message
+               this.getLogger().debug(MessageFormat.format("fieldName={0}", fieldName)); //NOI18N
+
                // Search for proper field instance
                for (final Field field : fields) {
                        // Debug message
-                       this.getLogger().debug(MessageFormat.format("field={0},fieldName={1}", field, fieldName)); //NOI18N
+                       this.getLogger().debug(MessageFormat.format("getName()={0},fieldName={1}", field.getName(), fieldName)); //NOI18N
 
                        // Does it match?
                        if (field.getName().equals(fieldName)) {
                                // Found it
                                type = field.getType();
+
+                               // Debug message
+                               this.getLogger().debug(MessageFormat.format("Found fieldName={0}: setting type={1}", fieldName, type.getSimpleName())); //NOI18N
+
+                               // Don't continue with searching
                                break;
                        }
                }
 
+               // Debug message
+               this.getLogger().debug(MessageFormat.format("type={0}", type));
+
                // type should not be null
                if (type == null) {
                        // No null allowed
index b4ea7602131e4369b56e28ddbab9b5dccbd38c3e..e1886ddf0c19d5da9648314e009c2457f48d94ab 100644 (file)
@@ -77,7 +77,7 @@ public class SearchCriteria extends BaseCriteria implements SearchableCriteria {
                }
 
                // Debug message
-               this.getLogger().debug("this.entrySet().size()=" + this.entrySet().size()); //NOI18N //NOI18N
+               this.getLogger().debug(MessageFormat.format("this.entrySet().size()={0}", this.entrySet().size())); //NOI18N //NOI18N
 
                // No matches found?
                if (this.entrySet().isEmpty()) {
@@ -100,10 +100,10 @@ public class SearchCriteria extends BaseCriteria implements SearchableCriteria {
                        Object value = storeable.getValueFromColumn(criteria.getKey());
 
                        // Debug message
-                       this.getLogger().debug(MessageFormat.format("value[{0}]={1}", value.getClass().getSimpleName(), value)); //NOI18N
+                       this.getLogger().debug(MessageFormat.format("value={0},getValue()={1}", value, criteria.getValue())); //NOI18N
 
                        // Is both same?
-                       if (value.equals(criteria.getValue())) {
+                       if (((null == value) && ("null".equals(criteria.getValue()))) || ((value != null) && (value.equals(criteria.getValue())))) { //NOI18N
                                // Debug message
                                this.getLogger().debug(MessageFormat.format("value={0} - MATCHES!", value)); //NOI18N