|
Author: jleroux
Date: Tue Nov 24 09:24:32 2009 New Revision: 883634 URL: http://svn.apache.org/viewvc?rev=883634&view=rev Log: Scott detected that UtilValidate.is(Not)Empty did not exist for CharSequence and reverted changes I did in EntitySaxReader.java This commit adds UtilValidate.is(Not)Empty for CharSequence; and uses it in EntitySaxReader.java and everywhere else it might still be used (because of my changes) Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilValidate.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntitySaxReader.java Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilValidate.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilValidate.java?rev=883634&r1=883633&r2=883634&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilValidate.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilValidate.java Tue Nov 24 09:24:32 2009 @@ -201,6 +201,11 @@ return ((c == null) || (c.size() == 0)); } + /** Check whether charsequence c is empty. */ + public static <E> boolean isEmpty(CharSequence c) { + return ((c == null) || (c.length() == 0)); + } + /** Check whether string s is NOT empty. */ public static boolean isNotEmpty(String s) { return ((s != null) && (s.length() > 0)); @@ -211,6 +216,11 @@ return ((c != null) && (c.size() > 0)); } + /** Check whether charsequence c is NOT empty. */ + public static <E> boolean isNotEmpty(CharSequence c) { + return ((c != null) && (c.length() > 0)); + } + public static boolean isString(Object obj) { return ((obj != null) && (obj instanceof java.lang.String)); } Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntitySaxReader.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntitySaxReader.java?rev=883634&r1=883633&r2=883634&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntitySaxReader.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntitySaxReader.java Tue Nov 24 09:24:32 2009 @@ -375,7 +375,7 @@ if (currentValue != null) { if (currentFieldName != null) { - if (currentFieldValue != null && currentFieldValue.length() > 0) { + if (UtilValidate.isNotEmpty(currentFieldValue)) { if (currentValue.getModelEntity().isField(currentFieldName.toString())) { ModelEntity modelEntity = currentValue.getModelEntity(); ModelField modelField = modelEntity.getField(currentFieldName.toString()); @@ -499,7 +499,7 @@ CharSequence name = attributes.getLocalName(i); CharSequence value = attributes.getValue(i); - if (name == null || name.length() == 0) { + if (UtilValidate.isEmpty(name)) { name = attributes.getQName(i); } newElement.setAttribute(name.toString(), value.toString()); @@ -548,12 +548,12 @@ CharSequence name = attributes.getLocalName(i); CharSequence value = attributes.getValue(i); - if (name == null || name.length() == 0) { + if (UtilValidate.isEmpty(name)) { name = attributes.getQName(i); } try { // treat empty strings as nulls - if (value != null && value.length() > 0) { + if (UtilValidate.isNotEmpty(value)) { if (currentValue.getModelEntity().isField(name.toString())) { currentValue.setString(name.toString(), value.toString()); } else { |
| Free forum by Nabble | Edit this page |
