From: Roland Haeder Date: Wed, 26 Aug 2015 12:37:54 +0000 (+0200) Subject: Added supported (alpha quality) for null references + added more debug log X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=bdac8ffd8a6a00b41786489a1c517def364828da;p=jcore.git Added supported (alpha quality) for null references + added more debug log Signed-off-by:Roland Häder --- diff --git a/src/org/mxchange/jcore/BaseFrameworkSystem.java b/src/org/mxchange/jcore/BaseFrameworkSystem.java index 1723cc8..047bcad 100644 --- a/src/org/mxchange/jcore/BaseFrameworkSystem.java +++ b/src/org/mxchange/jcore/BaseFrameworkSystem.java @@ -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 diff --git a/src/org/mxchange/jcore/criteria/searchable/SearchCriteria.java b/src/org/mxchange/jcore/criteria/searchable/SearchCriteria.java index b4ea760..e1886dd 100644 --- a/src/org/mxchange/jcore/criteria/searchable/SearchCriteria.java +++ b/src/org/mxchange/jcore/criteria/searchable/SearchCriteria.java @@ -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