Author: doogie
Date: Sun Aug 3 19:34:55 2008 New Revision: 682244 URL: http://svn.apache.org/viewvc?rev=682244&view=rev Log: Add a variant of isValidDatabaseId that takes a StringBuilder. Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilValidate.java Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilValidate.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilValidate.java?rev=682244&r1=682243&r2=682244&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilValidate.java (original) +++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilValidate.java Sun Aug 3 19:34:55 2008 @@ -1294,43 +1294,53 @@ return Character.forDigit(check, 10); } - public static boolean isValidDatabaseId(String fieldStr, StringBuffer errorDetails) { - boolean isValid = true; + public static String checkValidDatabaseId(String fieldStr) { if (fieldStr.indexOf(' ') >= 0) { - isValid = false; - errorDetails.append("[space found at position " + (fieldStr.indexOf(' ') + 1) + "]"); + return "[space found at position " + (fieldStr.indexOf(' ') + 1) + "]"; } if (fieldStr.indexOf('"') >= 0) { - isValid = false; - errorDetails.append("[double-quote found at position " + (fieldStr.indexOf('"') + 1) + "]"); + return "[double-quote found at position " + (fieldStr.indexOf('"') + 1) + "]"; } if (fieldStr.indexOf('\'') >= 0) { - isValid = false; - errorDetails.append("[single-quote found at position " + (fieldStr.indexOf('\'') + 1) + "]"); + return "[single-quote found at position " + (fieldStr.indexOf('\'') + 1) + "]"; } if (fieldStr.indexOf('&') >= 0) { - isValid = false; - errorDetails.append("[ampersand found at position " + (fieldStr.indexOf('&') + 1) + "]"); + return "[ampersand found at position " + (fieldStr.indexOf('&') + 1) + "]"; } if (fieldStr.indexOf('?') >= 0) { - isValid = false; - errorDetails.append("[question mark found at position " + (fieldStr.indexOf('?') + 1) + "]"); + return "[question mark found at position " + (fieldStr.indexOf('?') + 1) + "]"; } if (fieldStr.indexOf('<') >= 0) { - isValid = false; - errorDetails.append("[less-than sign found at position " + (fieldStr.indexOf('<') + 1) + "]"); + return "[less-than sign found at position " + (fieldStr.indexOf('<') + 1) + "]"; } if (fieldStr.indexOf('>') >= 0) { - isValid = false; - errorDetails.append("[greater-than sign found at position " + (fieldStr.indexOf('>') + 1) + "]"); + return "[greater-than sign found at position " + (fieldStr.indexOf('>') + 1) + "]"; } if (fieldStr.indexOf('\\') >= 0) { - isValid = false; - errorDetails.append("[back-slash found at position " + (fieldStr.indexOf('\\') + 1) + "]"); + return "[back-slash found at position " + (fieldStr.indexOf('\\') + 1) + "]"; } if (fieldStr.indexOf('/') >= 0) { + return "[forward-slash found at position " + (fieldStr.indexOf('/') + 1) + "]"; + } + return null; + } + + public static boolean isValidDatabaseId(String fieldStr, StringBuffer errorDetails) { + boolean isValid = true; + String checkMessage = checkValidDatabaseId(fieldStr); + if (checkMessage != null) { + isValid = false; + errorDetails.append(checkMessage); + } + return isValid; + } + + public static boolean isValidDatabaseId(String fieldStr, StringBuilder errorDetails) { + boolean isValid = true; + String checkMessage = checkValidDatabaseId(fieldStr); + if (checkMessage != null) { isValid = false; - errorDetails.append("[forward-slash found at position " + (fieldStr.indexOf('/') + 1) + "]"); + errorDetails.append(checkMessage); } return isValid; } |
Free forum by Nabble | Edit this page |