Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilMisc.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilMisc.java?rev=1818495&r1=1818494&r2=1818495&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilMisc.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilMisc.java Sun Dec 17 16:57:56 2017 @@ -72,12 +72,10 @@ public final class UtilMisc { if (obj1 == null) { if (obj2 == null) { return 0; - } else { - return 1; } - } else { - return obj1.compareTo(obj2); + return 1; } + return obj1.compareTo(obj2); } public static <E> int compare(List<E> obj1, List<E> obj2) { @@ -103,10 +101,10 @@ public final class UtilMisc { * @return The resulting Iterator */ public static <T> Iterator<T> toIterator(Collection<T> col) { - if (col == null) + if (col == null) { return null; - else - return col.iterator(); + } + return col.iterator(); } /** @@ -123,7 +121,7 @@ public final class UtilMisc { Debug.logInfo(e, module); throw e; } - Map<String, V> map = new HashMap<String, V>(); + Map<String, V> map = new HashMap<>(); for (int i = 0; i < data.length;) { map.put((String) data[i++], (V) data[i++]); } @@ -142,23 +140,27 @@ public final class UtilMisc { } public static <T> List<T> makeListWritable(Collection<? extends T> col) { - List<T> result = new LinkedList<T>(); - if (col != null) result.addAll(col); + List<T> result = new LinkedList<>(); + if (col != null) { + result.addAll(col); + } return result; } public static <K, V> Map<K, V> makeMapWritable(Map<K, ? extends V> map) { if (map == null) { - return new HashMap<K, V>(); + return new HashMap<>(); } - Map<K, V> result = new HashMap<K, V>(map.size()); + Map<K, V> result = new HashMap<>(map.size()); result.putAll(map); return result; } public static <T> Set<T> makeSetWritable(Collection<? extends T> col) { - Set<T> result = new LinkedHashSet<T>(); - if (col != null) result.addAll(col); + Set<T> result = new LinkedHashSet<>(); + if (col != null) { + result.addAll(col); + } return result; } @@ -170,12 +172,11 @@ public final class UtilMisc { */ public static <V> void makeMapSerializable(Map<String, V> map) { // now filter out all non-serializable values - Set<String> keysToRemove = new LinkedHashSet<String>(); + Set<String> keysToRemove = new LinkedHashSet<>(); for (Map.Entry<String, V> mapEntry: map.entrySet()) { Object entryValue = mapEntry.getValue(); if (entryValue != null && !(entryValue instanceof Serializable)) { keysToRemove.add(mapEntry.getKey()); - //Debug.logInfo("Found Map value that is not Serializable: " + mapEntry.getKey() + "=" + mapEntry.getValue(), module); } } for (String keyToRemove: keysToRemove) { map.remove(keyToRemove); } @@ -188,9 +189,10 @@ public final class UtilMisc { * @return a new List of sorted Maps. */ public static List<Map<Object, Object>> sortMaps(List<Map<Object, Object>> listOfMaps, List<? extends String> sortKeys) { - if (listOfMaps == null || sortKeys == null) + if (listOfMaps == null || sortKeys == null) { return null; - List<Map<Object, Object>> toSort = new ArrayList<Map<Object, Object>>(listOfMaps.size()); + } + List<Map<Object, Object>> toSort = new ArrayList<>(listOfMaps.size()); toSort.addAll(listOfMaps); try { MapComparator mc = new MapComparator(sortKeys); @@ -208,7 +210,7 @@ public final class UtilMisc { public static <K, IK, V> Map<IK, V> getMapFromMap(Map<K, Object> outerMap, K key) { Map<IK, V> innerMap = UtilGenerics.<IK, V>checkMap(outerMap.get(key)); if (innerMap == null) { - innerMap = new HashMap<IK, V>(); + innerMap = new HashMap<>(); outerMap.put(key, innerMap); } return innerMap; @@ -220,7 +222,7 @@ public final class UtilMisc { public static <K, V> List<V> getListFromMap(Map<K, Object> outerMap, K key) { List<V> innerList = UtilGenerics.<V>checkList(outerMap.get(key)); if (innerList == null) { - innerList = new LinkedList<V>(); + innerList = new LinkedList<>(); outerMap.put(key, innerList); } return innerList; @@ -257,21 +259,23 @@ public final class UtilMisc { } public static <T> Set<T> collectionToSet(Collection<T> c) { - if (c == null) return null; + if (c == null) { + return null; + } Set<T> theSet = null; if (c instanceof Set<?>) { theSet = (Set<T>) c; } else { - theSet = new LinkedHashSet<T>(); + theSet = new LinkedHashSet<>(); c.remove(null); theSet.addAll(c); } return theSet; } - + /** * Generates a String from given values delimited by delimiter. - * + * * @param values * @param delimiter * @return String @@ -301,7 +305,7 @@ public final class UtilMisc { if (data == null) { return null; } - Set<T> theSet = new LinkedHashSet<T>(); + Set<T> theSet = new LinkedHashSet<>(); for (T elem : data) { theSet.add(elem); } @@ -309,27 +313,28 @@ public final class UtilMisc { } public static <T> Set<T> toSet(Collection<T> collection) { - if (collection == null) return null; + if (collection == null) { + return null; + } if (collection instanceof Set<?>) { return (Set<T>) collection; - } else { - Set<T> theSet = new LinkedHashSet<T>(); - theSet.addAll(collection); - return theSet; } + Set<T> theSet = new LinkedHashSet<>(); + theSet.addAll(collection); + return theSet; } public static <T> Set<T> toSetArray(T[] data) { if (data == null) { return null; } - Set<T> set = new LinkedHashSet<T>(); + Set<T> set = new LinkedHashSet<>(); for (T value: data) { set.add(value); } return set; } - + /** * Creates a list from passed objects. * @param data @@ -340,8 +345,8 @@ public final class UtilMisc { if(data == null){ return null; } - - List<T> list = new LinkedList<T>(); + + List<T> list = new LinkedList<>(); for(T t : data){ list.add(t); @@ -351,21 +356,22 @@ public final class UtilMisc { } public static <T> List<T> toList(Collection<T> collection) { - if (collection == null) return null; + if (collection == null) { + return null; + } if (collection instanceof List<?>) { return (List<T>) collection; - } else { - List<T> list = new LinkedList<T>(); - list.addAll(collection); - return list; } + List<T> list = new LinkedList<>(); + list.addAll(collection); + return list; } public static <T> List<T> toListArray(T[] data) { if (data == null) { return null; } - List<T> list = new LinkedList<T>(); + List<T> list = new LinkedList<>(); for (T value: data) { list.add(value); } @@ -375,7 +381,7 @@ public final class UtilMisc { public static <K, V> void addToListInMap(V element, Map<K, Object> theMap, K listKey) { List<V> theList = UtilGenerics.checkList(theMap.get(listKey)); if (theList == null) { - theList = new LinkedList<V>(); + theList = new LinkedList<>(); theMap.put(listKey, theList); } theList.add(element); @@ -384,7 +390,7 @@ public final class UtilMisc { public static <K, V> void addToSetInMap(V element, Map<K, Set<V>> theMap, K setKey) { Set<V> theSet = UtilGenerics.checkSet(theMap.get(setKey)); if (theSet == null) { - theSet = new LinkedHashSet<V>(); + theSet = new LinkedHashSet<>(); theMap.put(setKey, theSet); } theSet.add(element); @@ -393,7 +399,7 @@ public final class UtilMisc { public static <K, V> void addToSortedSetInMap(V element, Map<K, Set<V>> theMap, K setKey) { Set<V> theSet = UtilGenerics.checkSet(theMap.get(setKey)); if (theSet == null) { - theSet = new TreeSet<V>(); + theSet = new TreeSet<>(); theMap.put(setKey, theSet); } theSet.add(element); @@ -562,7 +568,7 @@ public final class UtilMisc { private static final List<Locale> availableLocaleList = getAvailableLocaleList(); private static List<Locale> getAvailableLocaleList() { - TreeMap<String, Locale> localeMap = new TreeMap<String, Locale>(); + TreeMap<String, Locale> localeMap = new TreeMap<>(); String localesString = UtilProperties.getPropertyValue("general", "locales.available"); if (UtilValidate.isNotEmpty(localesString)) { List<String> idList = StringUtil.split(localesString, ","); @@ -579,7 +585,7 @@ public final class UtilMisc { } } } - return Collections.unmodifiableList(new ArrayList<Locale>(localeMap.values())); + return Collections.unmodifiableList(new ArrayList<>(localeMap.values())); } } @@ -597,18 +603,16 @@ public final class UtilMisc { public static void copyFile(File sourceLocation , File targetLocation) throws IOException { if (sourceLocation.isDirectory()) { throw new IOException("File is a directory, not a file, cannot copy") ; - } else { - - try ( - InputStream in = new FileInputStream(sourceLocation); - OutputStream out = new FileOutputStream(targetLocation); - ) { - // Copy the bits from instream to outstream - byte[] buf = new byte[1024]; - int len; - while ((len = in.read(buf)) > 0) { - out.write(buf, 0, len); - } + } + try ( + InputStream in = new FileInputStream(sourceLocation); + OutputStream out = new FileOutputStream(targetLocation); + ) { + // Copy the bits from instream to outstream + byte[] buf = new byte[1024]; + int len; + while ((len = in.read(buf)) > 0) { + out.write(buf, 0, len); } } } @@ -646,5 +650,5 @@ public final class UtilMisc { } return result; } - + } Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilNumber.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilNumber.java?rev=1818495&r1=1818494&r2=1818495&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilNumber.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilNumber.java Sun Dec 17 16:57:56 2017 @@ -168,7 +168,7 @@ public final class UtilNumber { // hash map to store ICU4J rule sets keyed to Locale private static HashMap<Locale, String> rbnfRuleSets; static { - rbnfRuleSets = new HashMap<Locale, String>(); + rbnfRuleSets = new HashMap<>(); rbnfRuleSets.put(Locale.US, ruleSet_en_US); rbnfRuleSets.put(new Locale("th"), ruleSet_th_TH); rbnfRuleSets.put(new Locale("en", "IN"), ruleSet_en_IN); @@ -183,8 +183,12 @@ public final class UtilNumber { * @return int - Scale factor to pass to BigDecimal's methods. Defaults to DEFAULT_BD_SCALE (2) */ public static int getBigDecimalScale(String file, String property) { - if (UtilValidate.isEmpty(file)) return DEFAULT_BD_SCALE; - if (UtilValidate.isEmpty(property)) return DEFAULT_BD_SCALE; + if (UtilValidate.isEmpty(file)) { + return DEFAULT_BD_SCALE; + } + if (UtilValidate.isEmpty(property)) { + return DEFAULT_BD_SCALE; + } int scale = -1; String value = UtilProperties.getPropertyValue(file, property); @@ -213,8 +217,12 @@ public final class UtilNumber { * @return int - Rounding mode to pass to BigDecimal's methods. Defaults to DEFAULT_BD_ROUNDING_MODE (BigDecimal.ROUND_HALF_UP) */ public static int getBigDecimalRoundingMode(String file, String property) { - if (UtilValidate.isEmpty(file)) return DEFAULT_BD_SCALE; - if (UtilValidate.isEmpty(property)) return DEFAULT_BD_ROUNDING_MODE; + if (UtilValidate.isEmpty(file)) { + return DEFAULT_BD_SCALE; + } + if (UtilValidate.isEmpty(property)) { + return DEFAULT_BD_ROUNDING_MODE; + } String value = UtilProperties.getPropertyValue(file, property); int mode = roundingModeFromString(value); @@ -238,16 +246,27 @@ public final class UtilNumber { * @return int - The int value of the mode (e.g, BigDecimal.ROUND_HALF_UP) or -1 if the input was bad. */ public static int roundingModeFromString(String value) { - if (value == null) return -1; + if (value == null) { + return -1; + } value = value.trim(); - if ("ROUND_HALF_UP".equals(value)) return BigDecimal.ROUND_HALF_UP; - else if ("ROUND_HALF_DOWN".equals(value)) return BigDecimal.ROUND_HALF_DOWN; - else if ("ROUND_HALF_EVEN".equals(value)) return BigDecimal.ROUND_HALF_EVEN; - else if ("ROUND_UP".equals(value)) return BigDecimal.ROUND_UP; - else if ("ROUND_DOWN".equals(value)) return BigDecimal.ROUND_DOWN; - else if ("ROUND_CEILING".equals(value)) return BigDecimal.ROUND_CEILING; - else if ("ROUND_FLOOR".equals(value)) return BigDecimal.ROUND_FLOOR; - else if ("ROUND_UNNECCESSARY".equals(value)) return BigDecimal.ROUND_UNNECESSARY; + if ("ROUND_HALF_UP".equals(value)) { + return BigDecimal.ROUND_HALF_UP; + } else if ("ROUND_HALF_DOWN".equals(value)) { + return BigDecimal.ROUND_HALF_DOWN; + } else if ("ROUND_HALF_EVEN".equals(value)) { + return BigDecimal.ROUND_HALF_EVEN; + } else if ("ROUND_UP".equals(value)) { + return BigDecimal.ROUND_UP; + } else if ("ROUND_DOWN".equals(value)) { + return BigDecimal.ROUND_DOWN; + } else if ("ROUND_CEILING".equals(value)) { + return BigDecimal.ROUND_CEILING; + } else if ("ROUND_FLOOR".equals(value)) { + return BigDecimal.ROUND_FLOOR; + } else if ("ROUND_UNNECCESSARY".equals(value)) { + return BigDecimal.ROUND_UNNECESSARY; + } return -1; } Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilObject.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilObject.java?rev=1818495&r1=1818494&r2=1818495&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilObject.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilObject.java Sun Dec 17 16:57:56 2017 @@ -131,9 +131,7 @@ public final class UtilObject { Object obj = null; try { obj = getObjectException(bytes); - } catch (ClassNotFoundException e) { - Debug.logError(e, module); - } catch (IOException e) { + } catch (ClassNotFoundException | IOException e) { Debug.logError(e, module); } return obj; @@ -181,7 +179,9 @@ public final class UtilObject { } public static int doHashCode(Object o1) { - if (o1 == null) return 0; + if (o1 == null) { + return 0; + } if (o1.getClass().isArray()) { int length = Array.getLength(o1); int result = 0; Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilPlist.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilPlist.java?rev=1818495&r1=1818494&r2=1818495&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilPlist.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilPlist.java Sun Dec 17 16:57:56 2017 @@ -41,12 +41,14 @@ public final class UtilPlist { public static final String module = UtilPlist.class.getName(); private UtilPlist() {} - + /** simple 4 char indentation */ private static final String indentFourString = " "; public static void writePlistProperty(String name, Object value, int indentLevel, PrintWriter writer) { - for (int i = 0; i < indentLevel; i++) writer.print(indentFourString); + for (int i = 0; i < indentLevel; i++) { + writer.print(indentFourString); + } writer.print(name); writer.print(" = "); if (value instanceof Map<?, ?>) { @@ -62,12 +64,16 @@ public final class UtilPlist { } } public static void writePlistPropertyMap(Map<String, Object> propertyMap, int indentLevel, PrintWriter writer, boolean appendComma) { - for (int i = 0; i < indentLevel; i++) writer.print(indentFourString); + for (int i = 0; i < indentLevel; i++) { + writer.print(indentFourString); + } writer.println("{"); for (Map.Entry<String, Object> property: propertyMap.entrySet()) { writePlistProperty(property.getKey(), property.getValue(), indentLevel + 1, writer); } - for (int i = 0; i < indentLevel; i++) writer.print(indentFourString); + for (int i = 0; i < indentLevel; i++) { + writer.print(indentFourString); + } if (appendComma) { writer.println("},"); } else { @@ -75,7 +81,9 @@ public final class UtilPlist { } } public static void writePlistPropertyValueList(List<Object> propertyValueList, int indentLevel, PrintWriter writer) { - for (int i = 0; i < indentLevel; i++) writer.print(indentFourString); + for (int i = 0; i < indentLevel; i++) { + writer.print(indentFourString); + } writer.print("("); Iterator<Object> propertyValueIter = propertyValueList.iterator(); @@ -86,16 +94,22 @@ public final class UtilPlist { writePlistPropertyMap(propertyMap, indentLevel + 1, writer, propertyValueIter.hasNext()); } else { writer.print(propertyValue); - if (propertyValueIter.hasNext()) writer.print(", "); + if (propertyValueIter.hasNext()) { + writer.print(", "); + } } } - for (int i = 0; i < indentLevel; i++) writer.print(indentFourString); + for (int i = 0; i < indentLevel; i++) { + writer.print(indentFourString); + } writer.println(");"); } public static void writePlistPropertyXml(String name, Object value, int indentLevel, PrintWriter writer) { - for (int i = 0; i < indentLevel; i++) writer.print(indentFourString); + for (int i = 0; i < indentLevel; i++) { + writer.print(indentFourString); + } writer.print("<key>"); writer.print(name); writer.println("</key>"); @@ -106,23 +120,31 @@ public final class UtilPlist { List<Object> list = checkList(value); writePlistPropertyValueListXml(list, indentLevel, writer); } else { - for (int i = 0; i < indentLevel; i++) writer.print(indentFourString); + for (int i = 0; i < indentLevel; i++) { + writer.print(indentFourString); + } writer.print("<string>"); writer.print(value); writer.println("</string>"); } } public static void writePlistPropertyMapXml(Map<String, Object> propertyMap, int indentLevel, PrintWriter writer) { - for (int i = 0; i < indentLevel; i++) writer.print(indentFourString); + for (int i = 0; i < indentLevel; i++) { + writer.print(indentFourString); + } writer.println("<dict>"); for (Map.Entry<String, Object> property: propertyMap.entrySet()) { writePlistPropertyXml(property.getKey(), property.getValue(), indentLevel + 1, writer); } - for (int i = 0; i < indentLevel; i++) writer.print(indentFourString); + for (int i = 0; i < indentLevel; i++) { + writer.print(indentFourString); + } writer.println("</dict>"); } public static void writePlistPropertyValueListXml(List<Object> propertyValueList, int indentLevel, PrintWriter writer) { - for (int i = 0; i < indentLevel; i++) writer.print(indentFourString); + for (int i = 0; i < indentLevel; i++) { + writer.print(indentFourString); + } writer.println("<array>"); indentLevel++; @@ -133,7 +155,9 @@ public final class UtilPlist { Map<String, Object> propertyMap = checkMap(propertyValue); writePlistPropertyMapXml(propertyMap, indentLevel, writer); } else { - for (int i = 0; i < indentLevel; i++) writer.print(indentFourString); + for (int i = 0; i < indentLevel; i++) { + writer.print(indentFourString); + } writer.print("<string>"); writer.print(propertyValue); writer.println("</string>"); @@ -141,7 +165,9 @@ public final class UtilPlist { } indentLevel--; - for (int i = 0; i < indentLevel; i++) writer.print(indentFourString); + for (int i = 0; i < indentLevel; i++) { + writer.print(indentFourString); + } writer.println("</array>"); } Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilProperties.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilProperties.java?rev=1818495&r1=1818494&r2=1818495&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilProperties.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilProperties.java Sun Dec 17 16:57:56 2017 @@ -74,7 +74,7 @@ public final class UtilProperties implem */ private static final UtilCache<String, Properties> urlCache = UtilCache.createUtilCache("properties.UtilPropertiesUrlCache"); - private static final Set<String> propertiesNotFound = new HashSet<String>(); + private static final Set<String> propertiesNotFound = new HashSet<>(); /** Compares the specified property to the compareString, returns true if they are the same, false otherwise * @param resource The name of the resource - if the properties file is 'webevent.properties', the resource name is 'webevent' @@ -110,10 +110,10 @@ public final class UtilProperties implem public static String getPropertyValue(String resource, String name, String defaultValue) { String value = getPropertyValue(resource, name); - if (UtilValidate.isEmpty(value)) + if (UtilValidate.isEmpty(value)) { return defaultValue; - else - return value; + } + return value; } public static double getPropertyNumber(String resource, String name, double defaultValue) { @@ -144,12 +144,12 @@ public final class UtilProperties implem if (UtilValidate.isEmpty(str)) { Debug.logWarning("Error converting String \"" + str + "\" to " + type + "; using defaultNumber " + defaultNumber + ".", module); return defaultNumber; - } else - try { - return (Number)(ObjectType.simpleTypeConvert(str, type, null, null)); - } catch (GeneralException e) { - Debug.logWarning("Error converting String \"" + str + "\" to " + type + "; using defaultNumber " + defaultNumber + ".", module); - } + } + try { + return (Number)(ObjectType.simpleTypeConvert(str, type, null, null)); + } catch (GeneralException e) { + Debug.logWarning("Error converting String \"" + str + "\" to " + type + "; using defaultNumber " + defaultNumber + ".", module); + } return defaultNumber; } @@ -163,9 +163,13 @@ public final class UtilProperties implem */ public static Boolean getPropertyAsBoolean(String resource, String name, boolean defaultValue) { String str = getPropertyValue(resource, name); - if ("true".equalsIgnoreCase(str)) return Boolean.TRUE; - else if ("false".equalsIgnoreCase(str)) return Boolean.FALSE; - else return defaultValue; + if ("true".equalsIgnoreCase(str)) { + return Boolean.TRUE; + } else if ("false".equalsIgnoreCase(str)) { + return Boolean.FALSE; + } else { + return defaultValue; + } } /** @@ -260,8 +264,12 @@ public final class UtilProperties implem * @return The value of the property in the properties file */ public static String getPropertyValue(String resource, String name) { - if (UtilValidate.isEmpty(resource)) return ""; - if (UtilValidate.isEmpty(name)) return ""; + if (UtilValidate.isEmpty(resource)) { + return ""; + } + if (UtilValidate.isEmpty(name)) { + return ""; + } Properties properties = getProperties(resource); if (properties == null) { @@ -282,7 +290,7 @@ public final class UtilProperties implem * Returns a new <code>Properties</code> instance created from <code>fileName</code>. * <p>This method is intended for low-level framework classes that need to read * properties files before OFBiz has been fully initialized.</p> - * + * * @param fileName The full name of the properties file ("foo.properties") * @return A new <code>Properties</code> instance created from <code>fileName</code>, or * <code>null</code> if the file was not found @@ -363,7 +371,9 @@ public final class UtilProperties implem public static boolean propertyValueEquals(URL url, String name, String compareString) { String value = getPropertyValue(url, name); - if (value == null) return false; + if (value == null) { + return false; + } return value.trim().equals(compareString); } @@ -376,7 +386,9 @@ public final class UtilProperties implem public static boolean propertyValueEqualsIgnoreCase(URL url, String name, String compareString) { String value = getPropertyValue(url, name); - if (value == null) return false; + if (value == null) { + return false; + } return value.trim().equalsIgnoreCase(compareString); } @@ -390,10 +402,10 @@ public final class UtilProperties implem public static String getPropertyValue(URL url, String name, String defaultValue) { String value = getPropertyValue(url, name); - if (UtilValidate.isEmpty(value)) + if (UtilValidate.isEmpty(value)) { return defaultValue; - else - return value; + } + return value; } public static double getPropertyNumber(URL url, String name, double defaultValue) { @@ -419,8 +431,12 @@ public final class UtilProperties implem * @return The value of the property in the properties file */ public static String getPropertyValue(URL url, String name) { - if (url == null) return ""; - if (UtilValidate.isEmpty(name)) return ""; + if (url == null) { + return ""; + } + if (UtilValidate.isEmpty(name)) { + return ""; + } Properties properties = getProperties(url); if (properties == null) { @@ -446,8 +462,12 @@ public final class UtilProperties implem * @return The value of the split property from the properties file */ public static String getSplitPropertyValue(URL url, String name) { - if (url == null) return ""; - if (UtilValidate.isEmpty(name)) return ""; + if (url == null) { + return ""; + } + if (UtilValidate.isEmpty(name)) { + return ""; + } Properties properties = getProperties(url); @@ -479,8 +499,12 @@ public final class UtilProperties implem * @param name The name of the property in the properties file * @param value The value of the property in the properties file */ public static void setPropertyValue(String resource, String name, String value) { - if (UtilValidate.isEmpty(resource)) return; - if (UtilValidate.isEmpty(name)) return; + if (UtilValidate.isEmpty(resource)) { + return; + } + if (UtilValidate.isEmpty(name)) { + return; + } Properties properties = getProperties(resource); if (properties == null) { @@ -556,8 +580,12 @@ public final class UtilProperties implem * @param name The name of the property in the resource * @param value The value of the property to set in memory */ public static void setPropertyValueInMemory(String resource, String name, String value) { - if (UtilValidate.isEmpty(resource)) return; - if (UtilValidate.isEmpty(name)) return; + if (UtilValidate.isEmpty(resource)) { + return; + } + if (UtilValidate.isEmpty(name)) { + return; + } Properties properties = getProperties(resource); if (properties == null) { @@ -576,12 +604,18 @@ public final class UtilProperties implem * @return The value of the property in the properties file */ public static String getMessage(String resource, String name, Locale locale) { - if (UtilValidate.isEmpty(resource)) return ""; - if (UtilValidate.isEmpty(name)) return ""; + if (UtilValidate.isEmpty(resource)) { + return ""; + } + if (UtilValidate.isEmpty(name)) { + return ""; + } ResourceBundle bundle = getResourceBundle(resource, locale); - if (bundle == null) return name; + if (bundle == null) { + return name; + } String value = null; if (bundle.containsKey(name)) { @@ -606,12 +640,11 @@ public final class UtilProperties implem if (UtilValidate.isEmpty(value)) { return ""; - } else { - if (arguments != null && arguments.length > 0) { - value = MessageFormat.format(value, arguments); - } - return value; } + if (arguments != null && arguments.length > 0) { + value = MessageFormat.format(value, arguments); + } + return value; } /** Returns the value of the specified property name from the specified resource/properties file corresponding @@ -627,12 +660,11 @@ public final class UtilProperties implem if (UtilValidate.isEmpty(value)) { return ""; - } else { - if (UtilValidate.isNotEmpty(arguments)) { - value = MessageFormat.format(value, arguments.toArray()); - } - return value; } + if (UtilValidate.isNotEmpty(arguments)) { + value = MessageFormat.format(value, arguments.toArray()); + } + return value; } public static String getMessageList(String resource, String name, Locale locale, Object... arguments) { @@ -652,19 +684,18 @@ public final class UtilProperties implem if (UtilValidate.isEmpty(value)) { return ""; - } else { - if (UtilValidate.isNotEmpty(context)) { - value = FlexibleStringExpander.expandString(value, context, locale); - } - return value; } + if (UtilValidate.isNotEmpty(context)) { + value = FlexibleStringExpander.expandString(value, context, locale); + } + return value; } public static String getMessageMap(String resource, String name, Locale locale, Object... context) { return getMessage(resource, name, UtilGenerics.toMap(String.class, context), locale); } - private static Set<String> resourceNotFoundMessagesShown = new HashSet<String>(); + private static Set<String> resourceNotFoundMessagesShown = new HashSet<>(); /** Returns the specified resource/properties file as a ResourceBundle * @param resource The name of the resource - can be a file, class, or URL * @param locale The locale that the given resource will correspond to @@ -744,7 +775,9 @@ public final class UtilProperties implem } } if (UtilValidate.isNotEmpty(properties)) { - if (Debug.verboseOn()) Debug.logVerbose("Loaded " + properties.size() + " properties for: " + resource + " (" + locale + ")", module); + if (Debug.verboseOn()) { + Debug.logVerbose("Loaded " + properties.size() + " properties for: " + resource + " (" + locale + ")", module); + } } return properties; } @@ -785,7 +818,7 @@ public final class UtilProperties implem * @return A list of candidate locales. */ public static List<Locale> localeToCandidateList(Locale locale) { - List<Locale> localeList = new LinkedList<Locale>(); + List<Locale> localeList = new LinkedList<>(); localeList.add(locale); String localeString = locale.toString(); int pos = localeString.lastIndexOf("_", localeString.length()); @@ -802,7 +835,7 @@ public final class UtilProperties implem private static Set<Locale> defaultCandidateLocales = getDefaultCandidateLocales(); private static Set<Locale> getDefaultCandidateLocales() { - Set<Locale> defaultCandidateLocales = new LinkedHashSet<Locale>(); + Set<Locale> defaultCandidateLocales = new LinkedHashSet<>(); defaultCandidateLocales.addAll(localeToCandidateList(Locale.getDefault())); defaultCandidateLocales.addAll(localeToCandidateList(getFallbackLocale())); defaultCandidateLocales.add(Locale.ROOT); @@ -831,10 +864,10 @@ public final class UtilProperties implem if (Locale.ROOT.equals(locale)) { return UtilMisc.toList(locale); } - Set<Locale> localeSet = new LinkedHashSet<Locale>(); + Set<Locale> localeSet = new LinkedHashSet<>(); localeSet.addAll(localeToCandidateList(locale)); localeSet.addAll(getDefaultCandidateLocales()); - List<Locale> localeList = new ArrayList<Locale>(localeSet); + List<Locale> localeList = new ArrayList<>(localeSet); return localeList; } @@ -866,7 +899,7 @@ public final class UtilProperties implem return propertiesNotFound.contains(createResourceName(resource, locale, removeExtension)); } - /** + /** * Resolve a properties file URL. * <p>This method uses the following strategy:</p> * <ul> @@ -959,7 +992,7 @@ public final class UtilProperties implem return null; } - /** + /** * Convert XML property file to Properties instance. This method will convert * both the Java XML properties file format and the OFBiz custom XML * properties file format. @@ -1070,7 +1103,7 @@ public final class UtilProperties implem UtilResourceBundle bundle = bundleCache.get(resourceName); if (bundle == null) { double startTime = System.currentTimeMillis(); - List<Locale> candidateLocales = (List<Locale>) getCandidateLocales(locale); + List<Locale> candidateLocales = getCandidateLocales(locale); UtilResourceBundle parentBundle = null; int numProperties = 0; while (candidateLocales.size() > 0) { Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilTimer.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilTimer.java?rev=1818495&r1=1818494&r2=1818495&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilTimer.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilTimer.java Sun Dec 17 16:57:56 2017 @@ -30,7 +30,7 @@ import java.util.concurrent.ConcurrentHa public class UtilTimer { public static final String module = UtilTimer.class.getName(); - protected static final ConcurrentHashMap<String, UtilTimer> staticTimers = new ConcurrentHashMap<String, UtilTimer>(); + protected static final ConcurrentHashMap<String, UtilTimer> staticTimers = new ConcurrentHashMap<>(); protected String timerName = null; protected String lastMessage = null; @@ -107,7 +107,9 @@ public class UtilTimer { lastMessage = message; String retString = retBuf.toString(); - if (log) Debug.log(Debug.TIMING, null, retString, module, "org.apache.ofbiz.base.util.UtilTimer"); + if (log) { + Debug.log(Debug.TIMING, null, retString, module, "org.apache.ofbiz.base.util.UtilTimer"); + } // have lastMessageTime come as late as possible to just time what happens between calls lastMessageTime = System.currentTimeMillis(); @@ -197,7 +199,9 @@ public class UtilTimer { lastMessageTime = System.currentTimeMillis(); String retString = retStringBuf.toString(); - if (log && Debug.timingOn()) Debug.logTiming(retString, module); + if (log && Debug.timingOn()) { + Debug.logTiming(retString, module); + } return retString; } Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilURL.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilURL.java?rev=1818495&r1=1818494&r2=1818495&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilURL.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilURL.java Sun Dec 17 16:57:56 2017 @@ -31,7 +31,7 @@ import java.util.concurrent.ConcurrentHa public final class UtilURL { public static final String module = UtilURL.class.getName(); - private static final Map<String, URL> urlMap = new ConcurrentHashMap<String, URL>(); + private static final Map<String, URL> urlMap = new ConcurrentHashMap<>(); private UtilURL() {} @@ -39,7 +39,9 @@ public final class UtilURL { String resourceName = contextClass.getName(); int dotIndex = resourceName.lastIndexOf('.'); - if (dotIndex != -1) resourceName = resourceName.substring(0, dotIndex); + if (dotIndex != -1) { + resourceName = resourceName.substring(0, dotIndex); + } resourceName += ".properties"; return fromResource(contextClass, resourceName); @@ -51,7 +53,7 @@ public final class UtilURL { * <p>This method uses various ways to locate the resource, and in all * cases it tests to see if the resource exists - so it * is very inefficient.</p> - * + * * @param resourceName * @return */ @@ -60,10 +62,10 @@ public final class UtilURL { } public static <C> URL fromResource(Class<C> contextClass, String resourceName) { - if (contextClass == null) + if (contextClass == null) { return fromResource(resourceName, null); - else - return fromResource(resourceName, contextClass.getClassLoader()); + } + return fromResource(resourceName, contextClass.getClassLoader()); } /** @@ -72,7 +74,7 @@ public final class UtilURL { * <p>This method uses various ways to locate the resource, and in all * cases it tests to see if the resource exists - so it * is very inefficient.</p> - * + * * @param resourceName * @param loader * @return @@ -122,12 +124,16 @@ public final class UtilURL { } public static URL fromFilename(String filename) { - if (filename == null) return null; + if (filename == null) { + return null; + } File file = new File(filename); URL url = null; try { - if (file.exists()) url = file.toURI().toURL(); + if (file.exists()) { + url = file.toURI().toURL(); + } } catch (java.net.MalformedURLException e) { Debug.logError(e, "unable to retrieve URL for file: " + filename, module); url = null; Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilValidate.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilValidate.java?rev=1818495&r1=1818494&r2=1818495&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilValidate.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilValidate.java Sun Dec 17 16:57:56 2017 @@ -157,9 +157,8 @@ public final class UtilValidate { public static boolean areEqual(Object obj, Object obj2) { if (obj == null) { return obj2 == null; - } else { - return obj.equals(obj2); } + return obj.equals(obj2); } /** Check whether an object is empty, will see if it is a String, Map, Collection, etc. */ @@ -224,7 +223,9 @@ public final class UtilValidate { /** Returns true if string s is empty or whitespace characters only. */ public static boolean isWhitespace(String s) { // Is s empty? - if (isEmpty(s)) return true; + if (isEmpty(s)) { + return true; + } // Search through string's characters one by one // until we find a non-whitespace character. @@ -233,7 +234,9 @@ public final class UtilValidate { // Check that current character isn't whitespace. char c = s.charAt(i); - if (whitespace.indexOf(c) == -1) return false; + if (whitespace.indexOf(c) == -1) { + return false; + } } // All characters are whitespace. return true; @@ -249,7 +252,9 @@ public final class UtilValidate { for (i = 0; i < s.length(); i++) { char c = s.charAt(i); - if (bag.indexOf(c) == -1) stringBuilder.append(c); + if (bag.indexOf(c) == -1) { + stringBuilder.append(c); + } } return stringBuilder.toString(); } @@ -264,7 +269,9 @@ public final class UtilValidate { for (i = 0; i < s.length(); i++) { char c = s.charAt(i); - if (bag.indexOf(c) != -1) stringBuilder.append(c); + if (bag.indexOf(c) != -1) { + stringBuilder.append(c); + } } return stringBuilder.toString(); } @@ -285,7 +292,9 @@ public final class UtilValidate { public static String stripInitialWhitespace(String s) { int i = 0; - while ((i < s.length()) && charInString(s.charAt(i), whitespace)) i++; + while ((i < s.length()) && charInString(s.charAt(i), whitespace)) { + i++; + } return s.substring(i); } @@ -319,7 +328,9 @@ public final class UtilValidate { * point, exponential notation, etc. */ public static boolean isInteger(String s) { - if (isEmpty(s)) return defaultEmptyOK; + if (isEmpty(s)) { + return defaultEmptyOK; + } // Search through string's characters one by one // until we find a non-numeric character. @@ -328,7 +339,9 @@ public final class UtilValidate { // Check that current character is number. char c = s.charAt(i); - if (!isDigit(c)) return false; + if (!isDigit(c)) { + return false; + } } // All characters are numbers. @@ -341,7 +354,9 @@ public final class UtilValidate { * Does not accept floating point, exponential notation, etc. */ public static boolean isSignedInteger(String s) { - if (isEmpty(s)) return defaultEmptyOK; + if (isEmpty(s)) { + return defaultEmptyOK; + } try { Integer.parseInt(s); return true; @@ -356,7 +371,9 @@ public final class UtilValidate { * Does not accept floating point, exponential notation, etc. */ public static boolean isSignedLong(String s) { - if (isEmpty(s)) return defaultEmptyOK; + if (isEmpty(s)) { + return defaultEmptyOK; + } try { Long.parseLong(s); return true; @@ -370,12 +387,16 @@ public final class UtilValidate { * NOTE: using the Java Long object for greatest precision */ public static boolean isPositiveInteger(String s) { - if (isEmpty(s)) return defaultEmptyOK; + if (isEmpty(s)) { + return defaultEmptyOK; + } try { long temp = Long.parseLong(s); - if (temp > 0) return true; + if (temp > 0) { + return true; + } return false; } catch (Exception e) { return false; @@ -386,12 +407,16 @@ public final class UtilValidate { * Returns true if string s is an integer >= 0 */ public static boolean isNonnegativeInteger(String s) { - if (isEmpty(s)) return defaultEmptyOK; + if (isEmpty(s)) { + return defaultEmptyOK; + } try { int temp = Integer.parseInt(s); - if (temp >= 0) return true; + if (temp >= 0) { + return true; + } return false; } catch (Exception e) { return false; @@ -402,28 +427,36 @@ public final class UtilValidate { * Returns true if string s is an integer < 0 */ public static boolean isNegativeInteger(String s) { - if (isEmpty(s)) return defaultEmptyOK; + if (isEmpty(s)) { + return defaultEmptyOK; + } try { int temp = Integer.parseInt(s); - if (temp < 0) return true; + if (temp < 0) { + return true; + } return false; } catch (Exception e) { return false; } } - /** + /** * Returns true if string s is an integer <= 0 */ public static boolean isNonpositiveInteger(String s) { - if (isEmpty(s)) return defaultEmptyOK; + if (isEmpty(s)) { + return defaultEmptyOK; + } try { int temp = Integer.parseInt(s); - if (temp <= 0) return true; + if (temp <= 0) { + return true; + } return false; } catch (Exception e) { return false; @@ -439,11 +472,15 @@ public final class UtilValidate { * Does not accept exponential notation. */ public static boolean isFloat(String s) { - if (isEmpty(s)) return defaultEmptyOK; + if (isEmpty(s)) { + return defaultEmptyOK; + } boolean seenDecimalPoint = false; - if (s.startsWith(decimalPointDelimiter)) return false; + if (s.startsWith(decimalPointDelimiter)) { + return false; + } // Search through string's characters one by one // until we find a non-numeric character. @@ -459,7 +496,9 @@ public final class UtilValidate { return false; } } else { - if (!isDigit(c)) return false; + if (!isDigit(c)) { + return false; + } } } // All characters are numbers. @@ -469,21 +508,33 @@ public final class UtilValidate { /** General routine for testing whether a string is a float. */ public static boolean isFloat(String s, boolean allowNegative, boolean allowPositive, int minDecimal, int maxDecimal) { - if (isEmpty(s)) return defaultEmptyOK; + if (isEmpty(s)) { + return defaultEmptyOK; + } try { float temp = Float.parseFloat(s); - if (!allowNegative && temp < 0) return false; - if (!allowPositive && temp > 0) return false; + if (!allowNegative && temp < 0) { + return false; + } + if (!allowPositive && temp > 0) { + return false; + } int decimalPoint = s.indexOf("."); if (decimalPoint == -1) { - if (minDecimal > 0) return false; + if (minDecimal > 0) { + return false; + } return true; } // 1.2345; length=6; point=1; num=4 int numDecimals = s.length() - decimalPoint - 1; - if (minDecimal >= 0 && numDecimals < minDecimal) return false; - if (maxDecimal >= 0 && numDecimals > maxDecimal) return false; + if (minDecimal >= 0 && numDecimals < minDecimal) { + return false; + } + if (maxDecimal >= 0 && numDecimals > maxDecimal) { + return false; + } return true; } catch (Exception e) { return false; @@ -493,21 +544,33 @@ public final class UtilValidate { /** General routine for testing whether a string is a double. */ public static boolean isDouble(String s, boolean allowNegative, boolean allowPositive, int minDecimal, int maxDecimal) { - if (isEmpty(s)) return defaultEmptyOK; + if (isEmpty(s)) { + return defaultEmptyOK; + } try { double temp = Double.parseDouble(s); - if (!allowNegative && temp < 0) return false; - if (!allowPositive && temp > 0) return false; + if (!allowNegative && temp < 0) { + return false; + } + if (!allowPositive && temp > 0) { + return false; + } int decimalPoint = s.indexOf("."); if (decimalPoint == -1) { - if (minDecimal > 0) return false; + if (minDecimal > 0) { + return false; + } return true; } // 1.2345; length=6; point=1; num=4 int numDecimals = s.length() - decimalPoint - 1; - if (minDecimal >= 0 && numDecimals < minDecimal) return false; - if (maxDecimal >= 0 && numDecimals > maxDecimal) return false; + if (minDecimal >= 0 && numDecimals < minDecimal) { + return false; + } + if (maxDecimal >= 0 && numDecimals > maxDecimal) { + return false; + } return true; } catch (Exception e) { return false; @@ -522,7 +585,9 @@ public final class UtilValidate { * first call isSignedInteger, then call isSignedFloat. */ public static boolean isSignedFloat(String s) { - if (isEmpty(s)) return defaultEmptyOK; + if (isEmpty(s)) { + return defaultEmptyOK; + } try { Float.parseFloat(s); return true; @@ -539,7 +604,9 @@ public final class UtilValidate { * first call isSignedInteger, then call isSignedFloat. */ public static boolean isSignedDouble(String s) { - if (isEmpty(s)) return defaultEmptyOK; + if (isEmpty(s)) { + return defaultEmptyOK; + } try { Double.parseDouble(s); return true; @@ -554,7 +621,9 @@ public final class UtilValidate { * since it now uses Character.isLetter() */ public static boolean isAlphabetic(String s) { - if (isEmpty(s)) return defaultEmptyOK; + if (isEmpty(s)) { + return defaultEmptyOK; + } // Search through string's characters one by one // until we find a non-alphabetic character. @@ -563,8 +632,9 @@ public final class UtilValidate { // Check that current character is letter. char c = s.charAt(i); - if (!isLetter(c)) + if (!isLetter(c)) { return false; + } } // All characters are letters. @@ -578,7 +648,9 @@ public final class UtilValidate { * sets and orderings for various languages and platforms. */ public static boolean isAlphanumeric(String s) { - if (isEmpty(s)) return defaultEmptyOK; + if (isEmpty(s)) { + return defaultEmptyOK; + } // Search through string's characters one by one // until we find a non-alphanumeric character. @@ -587,7 +659,9 @@ public final class UtilValidate { // Check that current character is number or letter. char c = s.charAt(i); - if (!isLetterOrDigit(c)) return false; + if (!isLetterOrDigit(c)) { + return false; + } } // All characters are numbers or letters. @@ -598,7 +672,9 @@ public final class UtilValidate { /** isSSN returns true if string s is a valid U.S. Social Security Number. Must be 9 digits. */ public static boolean isSSN(String s) { - if (isEmpty(s)) return defaultEmptyOK; + if (isEmpty(s)) { + return defaultEmptyOK; + } String normalizedSSN = stripCharsInBag(s, SSNDelimiters); @@ -610,7 +686,9 @@ public final class UtilValidate { **/ @Deprecated public static boolean isUSPhoneNumber(String s) { - if (isEmpty(s)) return defaultEmptyOK; + if (isEmpty(s)) { + return defaultEmptyOK; + } String normalizedPhone = stripCharsInBag(s, phoneNumberDelimiters); return (isInteger(normalizedPhone) && normalizedPhone.length() == digitsInUSPhoneNumber); @@ -621,7 +699,9 @@ public final class UtilValidate { * */ @Deprecated public static boolean isUSPhoneAreaCode(String s) { - if (isEmpty(s)) return defaultEmptyOK; + if (isEmpty(s)) { + return defaultEmptyOK; + } String normalizedPhone = stripCharsInBag(s, phoneNumberDelimiters); return (isInteger(normalizedPhone) && normalizedPhone.length() == digitsInUSPhoneAreaCode); @@ -632,7 +712,9 @@ public final class UtilValidate { * */ @Deprecated public static boolean isUSPhoneMainNumber(String s) { - if (isEmpty(s)) return defaultEmptyOK; + if (isEmpty(s)) { + return defaultEmptyOK; + } String normalizedPhone = stripCharsInBag(s, phoneNumberDelimiters); return (isInteger(normalizedPhone) && normalizedPhone.length() == digitsInUSPhoneMainNumber); @@ -645,7 +727,9 @@ public final class UtilValidate { */ @Deprecated public static boolean isInternationalPhoneNumber(String s) { - if (isEmpty(s)) return defaultEmptyOK; + if (isEmpty(s)) { + return defaultEmptyOK; + } String normalizedPhone = stripCharsInBag(s, phoneNumberDelimiters); @@ -654,7 +738,9 @@ public final class UtilValidate { /** isZIPCode returns true if string s is a valid U.S. ZIP code. Must be 5 or 9 digits only. */ public static boolean isZipCode(String s) { - if (isEmpty(s)) return defaultEmptyOK; + if (isEmpty(s)) { + return defaultEmptyOK; + } String normalizedZip = stripCharsInBag(s, ZipCodeDelimiters); @@ -665,12 +751,16 @@ public final class UtilValidate { public static boolean isContiguousZipCode(String s) { boolean retval = false; if (isZipCode(s)) { - if (isEmpty(s)) retval = defaultEmptyOK; - else { + if (isEmpty(s)) { + retval = defaultEmptyOK; + } else { String normalizedZip = s.substring(0,5); int iZip = Integer.parseInt(normalizedZip); - if ((iZip >= 96701 && iZip <= 96898) || (iZip >= 99501 && iZip <= 99950)) retval = false; - else retval = true; + if ((iZip >= 96701 && iZip <= 96898) || (iZip >= 99501 && iZip <= 99950)) { + retval = false; + } else { + retval = true; + } } } return retval; @@ -678,26 +768,34 @@ public final class UtilValidate { /** Return true if s is a valid U.S. Postal Code (abbreviation for state). */ public static boolean isStateCode(String s) { - if (isEmpty(s)) return defaultEmptyOK; + if (isEmpty(s)) { + return defaultEmptyOK; + } return ((USStateCodes.indexOf(s) != -1) && (s.indexOf(USStateCodeDelimiter) == -1)); } /** Return true if s is a valid contiguous U.S. Postal Code (abbreviation for state). */ public static boolean isContiguousStateCode(String s) { - if (isEmpty(s)) return defaultEmptyOK; + if (isEmpty(s)) { + return defaultEmptyOK; + } return ((ContiguousUSStateCodes.indexOf(s) != -1) && (s.indexOf(USStateCodeDelimiter) == -1)); } public static boolean isEmail(String s) { - if (isEmpty(s)) return defaultEmptyOK; + if (isEmpty(s)) { + return defaultEmptyOK; + } return EmailValidator.getInstance().isValid(s); } - - /** + + /** * Checks a String for a valid Email-List seperated by ",". */ public static boolean isEmailList(String s) { - if (isEmpty(s)) return defaultEmptyOK; + if (isEmpty(s)) { + return defaultEmptyOK; + } String[] emails = s.split(","); for (String email : emails) { if (!EmailValidator.getInstance().isValid(email)) { @@ -712,9 +810,12 @@ public final class UtilValidate { * @return true if s contains :// */ public static boolean isUrl(String s) { - if (isEmpty(s)) return defaultEmptyOK; - if (s.indexOf("://") != -1) + if (isEmpty(s)) { + return defaultEmptyOK; + } + if (s.indexOf("://") != -1) { return true; + } return false; } @@ -725,9 +826,13 @@ public final class UtilValidate { * to use 4-digit year numbers everywhere. */ public static boolean isYear(String s) { - if (isEmpty(s)) return defaultEmptyOK; + if (isEmpty(s)) { + return defaultEmptyOK; + } - if (!isNonnegativeInteger(s)) return false; + if (!isNonnegativeInteger(s)) { + return false; + } return ((s.length() == 2) || (s.length() == 4)); } @@ -735,10 +840,14 @@ public final class UtilValidate { * within the range of integer arguments a and b, inclusive. */ public static boolean isIntegerInRange(String s, int a, int b) { - if (isEmpty(s)) return defaultEmptyOK; + if (isEmpty(s)) { + return defaultEmptyOK; + } // Catch non-integer strings to avoid creating a NaN below, // which isn't available on JavaScript 1.0 for Windows. - if (!isSignedInteger(s)) return false; + if (!isSignedInteger(s)) { + return false; + } // Now, explicitly change the type to integer via parseInt // so that the comparison code below will work both on // JavaScript 1.2(which typechecks in equality comparisons) @@ -750,13 +859,17 @@ public final class UtilValidate { /** isMonth returns true if string s is a valid month number between 1 and 12. */ public static boolean isMonth(String s) { - if (isEmpty(s)) return defaultEmptyOK; + if (isEmpty(s)) { + return defaultEmptyOK; + } return isIntegerInRange(s, 1, 12); } /** isDay returns true if string s is a valid day number between 1 and 31. */ public static boolean isDay(String s) { - if (isEmpty(s)) return defaultEmptyOK; + if (isEmpty(s)) { + return defaultEmptyOK; + } return isIntegerInRange(s, 1, 31); } @@ -769,40 +882,54 @@ public final class UtilValidate { /** isHour returns true if string s is a valid number between 0 and 23. */ public static boolean isHour(String s) { - if (isEmpty(s)) return defaultEmptyOK; + if (isEmpty(s)) { + return defaultEmptyOK; + } return isIntegerInRange(s, 0, 23); } /** isMinute returns true if string s is a valid number between 0 and 59. */ public static boolean isMinute(String s) { - if (isEmpty(s)) return defaultEmptyOK; + if (isEmpty(s)) { + return defaultEmptyOK; + } return isIntegerInRange(s, 0, 59); } /** isSecond returns true if string s is a valid number between 0 and 59. */ public static boolean isSecond(String s) { - if (isEmpty(s)) return defaultEmptyOK; + if (isEmpty(s)) { + return defaultEmptyOK; + } return isIntegerInRange(s, 0, 59); } /** isDate returns true if string arguments year, month, and day form a valid date. */ public static boolean isDate(String year, String month, String day) { // catch invalid years(not 2- or 4-digit) and invalid months and days. - if (!(isYear(year) && isMonth(month) && isDay(day))) return false; + if (!(isYear(year) && isMonth(month) && isDay(day))) { + return false; + } int intYear = Integer.parseInt(year); int intMonth = Integer.parseInt(month); int intDay = Integer.parseInt(day); // catch invalid days, except for February - if (intDay > daysInMonth[intMonth - 1]) return false; - if ((intMonth == 2) && (intDay > daysInFebruary(intYear))) return false; + if (intDay > daysInMonth[intMonth - 1]) { + return false; + } + if ((intMonth == 2) && (intDay > daysInFebruary(intYear))) { + return false; + } return true; } /** isDate returns true if string argument date forms a valid date. */ public static boolean isDate(String date) { - if (isEmpty(date)) return defaultEmptyOK; + if (isEmpty(date)) { + return defaultEmptyOK; + } String month; String day; String year; @@ -810,7 +937,9 @@ public final class UtilValidate { int dateSlash1 = date.indexOf("/"); int dateSlash2 = date.lastIndexOf("/"); - if (dateSlash1 <= 0 || dateSlash1 == dateSlash2) return false; + if (dateSlash1 <= 0 || dateSlash1 == dateSlash2) { + return false; + } month = date.substring(0, dateSlash1); day = date.substring(dateSlash1 + 1, dateSlash2); year = date.substring(dateSlash2 + 1); @@ -820,11 +949,15 @@ public final class UtilValidate { /** isDate returns true if string argument date forms a valid date and is after today. */ public static boolean isDateAfterToday(String date) { - if (isEmpty(date)) return defaultEmptyOK; + if (isEmpty(date)) { + return defaultEmptyOK; + } int dateSlash1 = date.indexOf("/"); int dateSlash2 = date.lastIndexOf("/"); - if (dateSlash1 <= 0) return false; + if (dateSlash1 <= 0) { + return false; + } java.util.Date passed = null; if (dateSlash1 == dateSlash2) { @@ -832,7 +965,9 @@ public final class UtilValidate { String month = date.substring(0, dateSlash1); String day = "28"; String year = date.substring(dateSlash1 + 1); - if (!isDate(year, month, day)) return false; + if (!isDate(year, month, day)) { + return false; + } try { int monthInt = Integer.parseInt(month); @@ -848,25 +983,31 @@ public final class UtilValidate { String month = date.substring(0, dateSlash1); String day = date.substring(dateSlash1 + 1, dateSlash2); String year = date.substring(dateSlash2 + 1); - if (!isDate(year, month, day)) return false; + if (!isDate(year, month, day)) { + return false; + } passed = UtilDateTime.toDate(month, day, year, "0", "0", "0"); } java.util.Date now = UtilDateTime.nowDate(); if (passed != null) { return passed.after(now); - } else { - return false; } + return false; } /** isDate returns true if string argument date forms a valid date and is before today. */ public static boolean isDateBeforeToday(String date) { - if (isEmpty(date)) return defaultEmptyOK; + if (isEmpty(date)) { + return defaultEmptyOK; + } int dateSlash1 = date.indexOf("/"); int dateSlash2 = date.lastIndexOf("/"); - if (dateSlash1 <= 0) return defaultEmptyOK; // In this case an issue number has been provided (requires a javascript check in template!) + if (dateSlash1 <= 0) + { + return defaultEmptyOK; // In this case an issue number has been provided (requires a javascript check in template!) + } java.util.Date passed = null; if (dateSlash1 == dateSlash2) { @@ -874,7 +1015,9 @@ public final class UtilValidate { String month = date.substring(0, dateSlash1); String day = "28"; String year = date.substring(dateSlash1 + 1); - if (!isDate(year, month, day)) return false; + if (!isDate(year, month, day)) { + return false; + } try { int monthInt = Integer.parseInt(month); @@ -890,47 +1033,48 @@ public final class UtilValidate { String month = date.substring(0, dateSlash1); String day = date.substring(dateSlash1 + 1, dateSlash2); String year = date.substring(dateSlash2 + 1); - if (!isDate(year, month, day)) return false; + if (!isDate(year, month, day)) { + return false; + } passed = UtilDateTime.toDate(month, day, year, "0", "0", "0"); } java.util.Date now = UtilDateTime.nowDate(); if (passed != null) { return passed.before(now); - } else { - return false; } + return false; } public static boolean isDateBeforeNow(Timestamp date) { Timestamp now = UtilDateTime.nowTimestamp(); if (date != null) { return date.before(now); - } else { - return false; } + return false; } public static boolean isDateAfterNow(Timestamp date) { Timestamp now = UtilDateTime.nowTimestamp(); if (date != null) { return date.after(now); - } else { - return false; } + return false; } /** isTime returns true if string arguments hour, minute, and second form a valid time. */ public static boolean isTime(String hour, String minute, String second) { // catch invalid years(not 2- or 4-digit) and invalid months and days. - if (isHour(hour) && isMinute(minute) && isSecond(second)) + if (isHour(hour) && isMinute(minute) && isSecond(second)) { return true; - else - return false; + } + return false; } /** isTime returns true if string argument time forms a valid time. */ public static boolean isTime(String time) { - if (isEmpty(time)) return defaultEmptyOK; + if (isEmpty(time)) { + return defaultEmptyOK; + } String hour; String minute; @@ -939,7 +1083,9 @@ public final class UtilValidate { int timeColon1 = time.indexOf(":"); int timeColon2 = time.lastIndexOf(":"); - if (timeColon1 <= 0) return false; + if (timeColon1 <= 0) { + return false; + } hour = time.substring(0, timeColon1); if (timeColon1 == timeColon2) { minute = time.substring(timeColon1 + 1); @@ -957,7 +1103,9 @@ public final class UtilValidate { * @return true, if the number passed simple checks */ public static boolean isValueLinkCard(String stPassed) { - if (isEmpty(stPassed)) return defaultEmptyOK; + if (isEmpty(stPassed)) { + return defaultEmptyOK; + } String st = stripCharsInBag(stPassed, creditCardDelimiters); if (st.length() == 16 && (st.startsWith("7") || st.startsWith("6"))) { return true; @@ -971,7 +1119,9 @@ public final class UtilValidate { * @return tru, if the number passed simple checks */ public static boolean isOFBGiftCard(String stPassed) { - if (isEmpty(stPassed)) return defaultEmptyOK; + if (isEmpty(stPassed)) { + return defaultEmptyOK; + } String st = stripCharsInBag(stPassed, creditCardDelimiters); if (st.length() == 15 && sumIsMod10(getLuhnSum(st))) { return true; @@ -1029,13 +1179,19 @@ public final class UtilValidate { * @return true, if the credit card number passes the Luhn Mod-10 test, false otherwise */ public static boolean isCreditCard(String stPassed) { - if (isEmpty(stPassed)) return defaultEmptyOK; + if (isEmpty(stPassed)) { + return defaultEmptyOK; + } String st = stripCharsInBag(stPassed, creditCardDelimiters); - - if (!isInteger(st)) return false; - + + if (!isInteger(st)) { + return false; + } + // encoding only works on cars with less the 19 digits - if (st.length() > 19) return false; + if (st.length() > 19) { + return false; + } return sumIsMod10(getLuhnSum(st)); } @@ -1045,8 +1201,9 @@ public final class UtilValidate { * @return true, if the credit card number is a valid VISA number, false otherwise */ public static boolean isVisa(String cc) { - if (((cc.length() == 16) || (cc.length() == 13)) && ("4".equals(cc.substring(0, 1)))) + if (((cc.length() == 16) || (cc.length() == 13)) && ("4".equals(cc.substring(0, 1)))) { return isCreditCard(cc); + } return false; } @@ -1059,8 +1216,9 @@ public final class UtilValidate { int firstdig = Integer.parseInt(cc.substring(0, 1)); int seconddig = Integer.parseInt(cc.substring(1, 2)); - if ((cc.length() == 16) && (firstdig == 5) && ((seconddig >= 1) && (seconddig <= 5))) + if ((cc.length() == 16) && (firstdig == 5) && ((seconddig >= 1) && (seconddig <= 5))) { return isCreditCard(cc); + } return false; } @@ -1073,8 +1231,9 @@ public final class UtilValidate { int firstdig = Integer.parseInt(cc.substring(0, 1)); int seconddig = Integer.parseInt(cc.substring(1, 2)); - if ((cc.length() == 15) && (firstdig == 3) && ((seconddig == 4) || (seconddig == 7))) + if ((cc.length() == 15) && (firstdig == 3) && ((seconddig == 4) || (seconddig == 7))) { return isCreditCard(cc); + } return false; } @@ -1087,8 +1246,9 @@ public final class UtilValidate { int firstdig = Integer.parseInt(cc.substring(0, 1)); int seconddig = Integer.parseInt(cc.substring(1, 2)); - if ((cc.length() == 14) && (firstdig == 3) && ((seconddig == 0) || (seconddig == 6) || (seconddig == 8))) + if ((cc.length() == 14) && (firstdig == 3) && ((seconddig == 0) || (seconddig == 6) || (seconddig == 8))) { return isCreditCard(cc); + } return false; } @@ -1107,8 +1267,9 @@ public final class UtilValidate { public static boolean isDiscover(String cc) { String first4digs = cc.substring(0, 4); - if ((cc.length() == 16) && ("6011".equals(first4digs))) + if ((cc.length() == 16) && ("6011".equals(first4digs))) { return isCreditCard(cc); + } return false; } @@ -1119,8 +1280,9 @@ public final class UtilValidate { public static boolean isEnRoute(String cc) { String first4digs = cc.substring(0, 4); - if ((cc.length() == 15) && ("2014".equals(first4digs) || "2149".equals(first4digs))) + if ((cc.length() == 15) && ("2014".equals(first4digs) || "2149".equals(first4digs))) { return isCreditCard(cc); + } return false; } @@ -1137,8 +1299,9 @@ public final class UtilValidate { "3112".equals(first4digs) || "3158".equals(first4digs) || "3337".equals(first4digs) || - "3528".equals(first4digs))) + "3528".equals(first4digs))) { return isCreditCard(cc); + } return false; } @@ -1158,8 +1321,9 @@ public final class UtilValidate { "564182".equals(first6digs) || "633110".equals(first6digs) || "6333".equals(first4digs) || - "6759".equals(first4digs))) + "6759".equals(first4digs))) { return isCreditCard(cc); + } return false; } @@ -1171,8 +1335,9 @@ public final class UtilValidate { String first4digs = cc.substring(0, 4); String first2digs = cc.substring(0, 2); if (((cc.length() == 16) || (cc.length() == 18) || (cc.length() == 19)) && - ("63".equals(first2digs) || "6767".equals(first4digs))) + ("63".equals(first2digs) || "6767".equals(first4digs))) { return isCreditCard(cc); + } return false; } @@ -1190,8 +1355,9 @@ public final class UtilValidate { "4913".equals(first4digs) || "4508".equals(first4digs) || "4844".equals(first4digs) || - "4027".equals(first4digs))) + "4027".equals(first4digs))) { return isCreditCard(cc); + } return false; } @@ -1201,14 +1367,19 @@ public final class UtilValidate { * @return true, if the credit card number is any valid credit card number for any of the accepted card types, false otherwise */ public static boolean isAnyCard(String ccPassed) { - if (isEmpty(ccPassed)) return defaultEmptyOK; + if (isEmpty(ccPassed)) { + return defaultEmptyOK; + } String cc = stripCharsInBag(ccPassed, creditCardDelimiters); - if (!isCreditCard(cc)) return false; + if (!isCreditCard(cc)) { + return false; + } if (isMasterCard(cc) || isVisa(cc) || isAmericanExpress(cc) || isDinersClub(cc) || - isDiscover(cc) || isEnRoute(cc) || isJCB(cc) || isSolo(cc)|| isSwitch (cc)|| isVisaElectron(cc)) + isDiscover(cc) || isEnRoute(cc) || isJCB(cc) || isSolo(cc)|| isSwitch (cc)|| isVisaElectron(cc)) { return true; + } return false; } @@ -1217,21 +1388,45 @@ public final class UtilValidate { * @return true, if the credit card number is any valid credit card number for any of the accepted card types, false otherwise */ public static String getCardType(String ccPassed) { - if (isEmpty(ccPassed)) return "Unknown"; + if (isEmpty(ccPassed)) { + return "Unknown"; + } String cc = stripCharsInBag(ccPassed, creditCardDelimiters); - if (!isCreditCard(cc)) return "Unknown"; + if (!isCreditCard(cc)) { + return "Unknown"; + } - if (isMasterCard(cc)) return "CCT_MASTERCARD"; - if (isVisa(cc)) return "CCT_VISA"; - if (isAmericanExpress(cc)) return "CCT_AMERICANEXPRESS"; - if (isDinersClub(cc)) return "CCT_DINERSCLUB"; - if (isDiscover(cc)) return "CCT_DISCOVER"; - if (isEnRoute(cc)) return "CCT_ENROUTE"; - if (isJCB(cc)) return "CCT_JCB"; - if (isSolo(cc)) return "CCT_SOLO"; - if (isSwitch (cc)) return "CCT_SWITCH"; - if (isVisaElectron(cc)) return "CCT_VISAELECTRON"; + if (isMasterCard(cc)) { + return "CCT_MASTERCARD"; + } + if (isVisa(cc)) { + return "CCT_VISA"; + } + if (isAmericanExpress(cc)) { + return "CCT_AMERICANEXPRESS"; + } + if (isDinersClub(cc)) { + return "CCT_DINERSCLUB"; + } + if (isDiscover(cc)) { + return "CCT_DISCOVER"; + } + if (isEnRoute(cc)) { + return "CCT_ENROUTE"; + } + if (isJCB(cc)) { + return "CCT_JCB"; + } + if (isSolo(cc)) { + return "CCT_SOLO"; + } + if (isSwitch (cc)) { + return "CCT_SWITCH"; + } + if (isVisaElectron(cc)) { + return "CCT_VISAELECTRON"; + } return "Unknown"; } @@ -1241,28 +1436,56 @@ public final class UtilValidate { * @return true, if the credit card number is valid for the particular credit card type given in "cardType", false otherwise */ public static boolean isCardMatch(String cardType, String cardNumberPassed) { - if (isEmpty(cardType)) return defaultEmptyOK; - if (isEmpty(cardNumberPassed)) return defaultEmptyOK; + if (isEmpty(cardType)) { + return defaultEmptyOK; + } + if (isEmpty(cardNumberPassed)) { + return defaultEmptyOK; + } String cardNumber = stripCharsInBag(cardNumberPassed, creditCardDelimiters); - if (("CCT_VISA".equalsIgnoreCase(cardType)) && (isVisa(cardNumber))) return true; - if (("CCT_MASTERCARD".equalsIgnoreCase(cardType)) && (isMasterCard(cardNumber))) return true; - if ((("CCT_AMERICANEXPRESS".equalsIgnoreCase(cardType)) || ("CCT_AMEX".equalsIgnoreCase(cardType))) && (isAmericanExpress(cardNumber))) return true; - if (("CCT_DISCOVER".equalsIgnoreCase(cardType)) && (isDiscover(cardNumber))) return true; - if (("CCT_JCB".equalsIgnoreCase(cardType)) && (isJCB(cardNumber))) return true; - if ((("CCT_DINERSCLUB".equalsIgnoreCase(cardType)) || ("CCT_DINERS".equalsIgnoreCase(cardType))) && (isDinersClub(cardNumber))) return true; - if (("CCT_CARTEBLANCHE".equalsIgnoreCase(cardType)) && (isCarteBlanche(cardNumber))) return true; - if (("CCT_ENROUTE".equalsIgnoreCase(cardType)) && (isEnRoute(cardNumber))) return true; - if (("CCT_SOLO".equalsIgnoreCase(cardType)) && (isSolo(cardNumber))) return true; - if (("CCT_SWITCH".equalsIgnoreCase(cardType)) && (isSwitch (cardNumber))) return true; - if (("CCT_VISAELECTRON".equalsIgnoreCase(cardType)) && (isVisaElectron(cardNumber))) return true; + if (("CCT_VISA".equalsIgnoreCase(cardType)) && (isVisa(cardNumber))) { + return true; + } + if (("CCT_MASTERCARD".equalsIgnoreCase(cardType)) && (isMasterCard(cardNumber))) { + return true; + } + if ((("CCT_AMERICANEXPRESS".equalsIgnoreCase(cardType)) || ("CCT_AMEX".equalsIgnoreCase(cardType))) && (isAmericanExpress(cardNumber))) { + return true; + } + if (("CCT_DISCOVER".equalsIgnoreCase(cardType)) && (isDiscover(cardNumber))) { + return true; + } + if (("CCT_JCB".equalsIgnoreCase(cardType)) && (isJCB(cardNumber))) { + return true; + } + if ((("CCT_DINERSCLUB".equalsIgnoreCase(cardType)) || ("CCT_DINERS".equalsIgnoreCase(cardType))) && (isDinersClub(cardNumber))) { + return true; + } + if (("CCT_CARTEBLANCHE".equalsIgnoreCase(cardType)) && (isCarteBlanche(cardNumber))) { + return true; + } + if (("CCT_ENROUTE".equalsIgnoreCase(cardType)) && (isEnRoute(cardNumber))) { + return true; + } + if (("CCT_SOLO".equalsIgnoreCase(cardType)) && (isSolo(cardNumber))) { + return true; + } + if (("CCT_SWITCH".equalsIgnoreCase(cardType)) && (isSwitch (cardNumber))) { + return true; + } + if (("CCT_VISAELECTRON".equalsIgnoreCase(cardType)) && (isVisaElectron(cardNumber))) { + return true; + } return false; } /** isNotPoBox returns true if address argument does not contain anything that looks like a a PO Box. */ public static boolean isNotPoBox(String s) { - if (isEmpty(s)) return defaultEmptyOK; + if (isEmpty(s)) { + return defaultEmptyOK; + } // strings to check from Greg's program // "P.O. B" @@ -1275,24 +1498,56 @@ public final class UtilValidate { // "P0 B" String sl = s.toLowerCase(Locale.getDefault()); - if (sl.indexOf("p.o. b") != -1) return false; - if (sl.indexOf("p.o.b") != -1) return false; - if (sl.indexOf("p.o b") != -1) return false; - if (sl.indexOf("p o b") != -1) return false; - if (sl.indexOf("po b") != -1) return false; - if (sl.indexOf("pobox") != -1) return false; - if (sl.indexOf("po#") != -1) return false; - if (sl.indexOf("po #") != -1) return false; + if (sl.indexOf("p.o. b") != -1) { + return false; + } + if (sl.indexOf("p.o.b") != -1) { + return false; + } + if (sl.indexOf("p.o b") != -1) { + return false; + } + if (sl.indexOf("p o b") != -1) { + return false; + } + if (sl.indexOf("po b") != -1) { + return false; + } + if (sl.indexOf("pobox") != -1) { + return false; + } + if (sl.indexOf("po#") != -1) { + return false; + } + if (sl.indexOf("po #") != -1) { + return false; + } // now with 0's for them sneaky folks - if (sl.indexOf("p.0. b") != -1) return false; - if (sl.indexOf("p.0.b") != -1) return false; - if (sl.indexOf("p.0 b") != -1) return false; - if (sl.indexOf("p 0 b") != -1) return false; - if (sl.indexOf("p0 b") != -1) return false; - if (sl.indexOf("p0box") != -1) return false; - if (sl.indexOf("p0#") != -1) return false; - if (sl.indexOf("p0 #") != -1) return false; + if (sl.indexOf("p.0. b") != -1) { + return false; + } + if (sl.indexOf("p.0.b") != -1) { + return false; + } + if (sl.indexOf("p.0 b") != -1) { + return false; + } + if (sl.indexOf("p 0 b") != -1) { + return false; + } + if (sl.indexOf("p0 b") != -1) { + return false; + } + if (sl.indexOf("p0box") != -1) { + return false; + } + if (sl.indexOf("p0#") != -1) { + return false; + } + if (sl.indexOf("p0 #") != -1) { + return false; + } return true; } @@ -1336,7 +1591,9 @@ public final class UtilValidate { } } int check = 10 - ((evensum + 3 * oddsum) % 10); - if (check >= 10) check = 0; + if (check >= 10) { + check = 0; + } return Character.forDigit(check, 10); } |
Administrator
|
Le 17/12/2017 à 17:57, [hidden email] a écrit :
> - //Debug.logInfo("Found Map value that is not Serializable: " + mapEntry.getKey() + "=" + mapEntry.getValue(), module); I wonder if we should not rather put back the comment uncommented out. This can be interesting sometimes and should not happen too often. Jacques |
Free forum by Nabble | Edit this page |