Author: doogie
Date: Wed Oct 17 13:44:11 2007 New Revision: 585683 URL: http://svn.apache.org/viewvc?rev=585683&view=rev Log: More java 1.5 markup added for another set of base classes. Closes https://issues.apache.org/jira/browse/OFBIZ-1341 Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/location/FlexibleLocation.java ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/MultiTrustManager.java ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/ObjectType.java ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilDateTime.java ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilName.java ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilNumber.java ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilObject.java ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/LifoSet.java Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/location/FlexibleLocation.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/location/FlexibleLocation.java?rev=585683&r1=585682&r2=585683&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/location/FlexibleLocation.java (original) +++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/location/FlexibleLocation.java Wed Oct 17 13:44:11 2007 @@ -33,9 +33,9 @@ public class FlexibleLocation { - protected static Map locationResolvers = FastMap.newInstance(); + protected static Map<String, LocationResolver> locationResolvers = FastMap.newInstance(); - protected static Map defaultResolvers = FastMap.newInstance(); + protected static Map<String, String> defaultResolvers = FastMap.newInstance(); protected static String standardUrlResolverName = StandardUrlLocationResolver.class.getName(); protected static String classpathResolverName = ClasspathLocationResolver.class.getName(); @@ -78,15 +78,15 @@ } String locationType = getLocationType(location); - LocationResolver resolver = (LocationResolver) locationResolvers.get(locationType); + LocationResolver resolver = locationResolvers.get(locationType); if (resolver == null) { synchronized (FlexibleLocation.class) { - resolver = (LocationResolver) locationResolvers.get(locationType); + resolver = locationResolvers.get(locationType); if (resolver == null) { String locationResolverName = UtilProperties.getPropertyValue("locationresolvers", locationType); if (locationResolverName == null || locationResolverName.length() == 0) { // try one of the defaults - locationResolverName = (String) defaultResolvers.get(locationType); + locationResolverName = defaultResolvers.get(locationType); } if (locationResolverName == null || locationResolverName.length() == 0) { Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/MultiTrustManager.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/MultiTrustManager.java?rev=585683&r1=585682&r2=585683&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/MultiTrustManager.java (original) +++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/MultiTrustManager.java Wed Oct 17 13:44:11 2007 @@ -38,7 +38,7 @@ public static final String module = MultiTrustManager.class.getName(); - protected List keystores; + protected List<KeyStore> keystores; public MultiTrustManager(KeyStore ks) { this(); @@ -72,29 +72,27 @@ } public X509Certificate[] getAcceptedIssuers() { - List certs = FastList.newInstance(); - Iterator i = keystores.iterator(); - while (i.hasNext()) { - KeyStore k = (KeyStore) i.next(); + List<X509Certificate> issuers = FastList.newInstance(); + for (KeyStore store: keystores) { try { - Enumeration e = k.aliases(); + Enumeration<String> e = store.aliases(); while (e.hasMoreElements()) { - String alias = (String) e.nextElement(); - Certificate[] cert = k.getCertificateChain(alias); - if (cert != null) { - for (int x = 0; x < cert.length; x++) { - if (cert[x] instanceof X509Certificate) { + String alias = e.nextElement(); + Certificate[] chain = store.getCertificateChain(alias); + if (chain != null) { + for (Certificate cert: chain) { + if (cert instanceof X509Certificate) { if (Debug.verboseOn()) - Debug.log("Read certificate (chain) : " + ((X509Certificate) cert[x]).getSubjectX500Principal().getName(), module); - certs.add(cert[x]); + Debug.log("Read certificate (chain) : " + ((X509Certificate) cert).getSubjectX500Principal().getName(), module); + issuers.add((X509Certificate) cert); } } } else { - Certificate c = k.getCertificate(alias); - if (c != null && c instanceof X509Certificate) { + Certificate cert = store.getCertificate(alias); + if (cert != null && cert instanceof X509Certificate) { if (Debug.verboseOn()) - Debug.log("Read certificate : " + ((X509Certificate) c).getSubjectX500Principal().getName(), module); - certs.add(c); + Debug.log("Read certificate : " + ((X509Certificate) cert).getSubjectX500Principal().getName(), module); + issuers.add((X509Certificate) cert); } } } @@ -103,20 +101,20 @@ } } - return (X509Certificate[]) certs.toArray(new X509Certificate[certs.size()]); + return issuers.toArray(new X509Certificate[issuers.size()]); } protected boolean isTrusted(X509Certificate[] cert) { if (cert != null) { - X509Certificate[] certs = this.getAcceptedIssuers(); - if (certs != null) { - for (int i = 0; i < certs.length; i++) { - for (int x = 0; x < cert.length; x++) { + X509Certificate[] issuers = this.getAcceptedIssuers(); + if (issuers != null) { + for (X509Certificate issuer: issuers) { + for (X509Certificate c: cert) { if (Debug.verboseOn()) - Debug.log("--- Checking cert: " + certs[i].getSubjectX500Principal() + " vs " + cert[x].getSubjectX500Principal(), module); - if (certs[i].equals(cert[x])) { + Debug.log("--- Checking cert: " + issuer.getSubjectX500Principal() + " vs " + c.getSubjectX500Principal(), module); + if (issuer.equals(c)) { if (Debug.verboseOn()) - Debug.log("--- Found trusted cert: " + certs[i].getSerialNumber().toString(16) + " : " + certs[i].getSubjectX500Principal(), module); + Debug.log("--- Found trusted cert: " + issuer.getSerialNumber().toString(16) + " : " + issuer.getSubjectX500Principal(), module); return true; } } Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/ObjectType.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/ObjectType.java?rev=585683&r1=585682&r2=585683&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/ObjectType.java (original) +++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/ObjectType.java Wed Oct 17 13:44:11 2007 @@ -41,7 +41,7 @@ public static final Object NULL = new NullObject(); - protected static Map classCache = FastMap.newInstance(); + protected static Map<String, Class<?>> classCache = FastMap.newInstance(); public static final String LANG_PACKAGE = "java.lang."; // We will test both the raw value and this + raw value public static final String SQL_PACKAGE = "java.sql."; // We will test both the raw value and this + raw value @@ -52,9 +52,9 @@ * @return The requested class * @throws ClassNotFoundException */ - public static Class loadClass(String className) throws ClassNotFoundException { + public static Class<?> loadClass(String className) throws ClassNotFoundException { // small block to speed things up by putting using preloaded classes for common objects, this turns out to help quite a bit... - Class theClass = (Class) CachedClassLoader.globalClassNameClassMap.get(className); + Class<?> theClass = CachedClassLoader.globalClassNameClassMap.get(className); if (theClass != null) return theClass; @@ -68,9 +68,9 @@ * @return The requested class * @throws ClassNotFoundException */ - public static Class loadClass(String className, ClassLoader loader) throws ClassNotFoundException { + public static Class<?> loadClass(String className, ClassLoader loader) throws ClassNotFoundException { // small block to speed things up by putting using preloaded classes for common objects, this turns out to help quite a bit... - Class theClass = (Class) CachedClassLoader.globalClassNameClassMap.get(className); + Class<?> theClass = CachedClassLoader.globalClassNameClassMap.get(className); if (theClass != null) return theClass; @@ -79,10 +79,10 @@ try { theClass = loader.loadClass(className); } catch (Exception e) { - theClass = (Class) classCache.get(className); + theClass = classCache.get(className); if (theClass == null) { synchronized (ObjectType.class) { - theClass = (Class) classCache.get(className); + theClass = classCache.get(className); if (theClass == null) { theClass = Class.forName(className); if (theClass != null) { @@ -107,7 +107,7 @@ */ public static Object getInstance(String className) throws ClassNotFoundException, InstantiationException, IllegalAccessException { - Class c = loadClass(className); + Class<?> c = loadClass(className); Object o = c.newInstance(); if (Debug.verboseOn()) Debug.logVerbose("Instantiated object: " + o.toString(), module); @@ -121,8 +121,8 @@ * @return boolean indicating whether interfaceName is an interface of the obj * @throws ClassNotFoundException */ - public static boolean interfaceOf(Class objectClass, String interfaceName) throws ClassNotFoundException { - Class interfaceClass = loadClass(interfaceName); + public static boolean interfaceOf(Class<?> objectClass, String interfaceName) throws ClassNotFoundException { + Class<?> interfaceClass = loadClass(interfaceName); return interfaceOf(objectClass, interfaceClass); } @@ -133,8 +133,8 @@ * @param interfaceObject to test against * @return boolean indicating whether interfaceObject is an interface of the obj */ - public static boolean interfaceOf(Class objectClass, Object interfaceObject) { - Class interfaceClass = interfaceObject.getClass(); + public static boolean interfaceOf(Class<?> objectClass, Object interfaceObject) { + Class<?> interfaceClass = interfaceObject.getClass(); return interfaceOf(objectClass, interfaceClass); } @@ -150,11 +150,11 @@ */ public static Object getInstance(String className, Object[] parameters) throws ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException { - Class[] sig = new Class[parameters.length]; + Class<?>[] sig = new Class<?>[parameters.length]; for (int i = 0; i < sig.length; i++) { sig[i] = parameters[i].getClass(); } - Class c = loadClass(className); + Class<?> c = loadClass(className); Constructor con = c.getConstructor(sig); Object o = con.newInstance(parameters); @@ -170,7 +170,7 @@ * @throws ClassNotFoundException */ public static boolean interfaceOf(Object obj, String interfaceName) throws ClassNotFoundException { - Class interfaceClass = loadClass(interfaceName); + Class<?> interfaceClass = loadClass(interfaceName); return interfaceOf(obj, interfaceClass); } @@ -182,7 +182,7 @@ * @return boolean indicating whether interfaceObject is an interface of the obj */ public static boolean interfaceOf(Object obj, Object interfaceObject) { - Class interfaceClass = interfaceObject.getClass(); + Class<?> interfaceClass = interfaceObject.getClass(); return interfaceOf(obj, interfaceClass); } @@ -193,8 +193,8 @@ * @param interfaceClass Class to test against * @return boolean indicating whether interfaceClass is an interface of the obj */ - public static boolean interfaceOf(Object obj, Class interfaceClass) { - Class objectClass = obj.getClass(); + public static boolean interfaceOf(Object obj, Class<?> interfaceClass) { + Class<?> objectClass = obj.getClass(); return interfaceOf(objectClass, interfaceClass); } @@ -205,12 +205,12 @@ * @param interfaceClass Class to test against * @return boolean indicating whether interfaceClass is an interface of the obj */ - public static boolean interfaceOf(Class objectClass, Class interfaceClass) { + public static boolean interfaceOf(Class<?> objectClass, Class<?> interfaceClass) { while (objectClass != null) { - Class[] ifaces = objectClass.getInterfaces(); + Class<?>[] ifaces = objectClass.getInterfaces(); - for (int i = 0; i < ifaces.length; i++) { - if (ifaces[i] == interfaceClass) return true; + for (Class<?> iface: ifaces) { + if (iface == interfaceClass) return true; } objectClass = objectClass.getSuperclass(); } @@ -224,8 +224,8 @@ * @return * @throws ClassNotFoundException */ - public static boolean isOrSubOf(Class objectClass, String parentName) throws ClassNotFoundException { - Class parentClass = loadClass(parentName); + public static boolean isOrSubOf(Class<?> objectClass, String parentName) throws ClassNotFoundException { + Class<?> parentClass = loadClass(parentName); return isOrSubOf(objectClass, parentClass); } @@ -236,8 +236,8 @@ * @param parentObject Object to test against * @return */ - public static boolean isOrSubOf(Class objectClass, Object parentObject) { - Class parentClass = parentObject.getClass(); + public static boolean isOrSubOf(Class<?> objectClass, Object parentObject) { + Class<?> parentClass = parentObject.getClass(); return isOrSubOf(objectClass, parentClass); } @@ -250,7 +250,7 @@ * @throws ClassNotFoundException */ public static boolean isOrSubOf(Object obj, String parentName) throws ClassNotFoundException { - Class parentClass = loadClass(parentName); + Class<?> parentClass = loadClass(parentName); return isOrSubOf(obj, parentClass); } @@ -262,7 +262,7 @@ * @return */ public static boolean isOrSubOf(Object obj, Object parentObject) { - Class parentClass = parentObject.getClass(); + Class<?> parentClass = parentObject.getClass(); return isOrSubOf(obj, parentClass); } @@ -273,8 +273,8 @@ * @param parentClass Class to test against * @return */ - public static boolean isOrSubOf(Object obj, Class parentClass) { - Class objectClass = obj.getClass(); + public static boolean isOrSubOf(Object obj, Class<?> parentClass) { + Class<?> objectClass = obj.getClass(); return isOrSubOf(objectClass, parentClass); } @@ -285,7 +285,7 @@ * @param parentClass Class to test against * @return */ - public static boolean isOrSubOf(Class objectClass, Class parentClass) { + public static boolean isOrSubOf(Class<?> objectClass, Class<?> parentClass) { //Debug.logInfo("Checking isOrSubOf for [" + objectClass.getName() + "] and [" + objectClass.getName() + "]", module); while (objectClass != null) { if (objectClass == parentClass) return true; @@ -300,8 +300,8 @@ * @param typeObject Object to test against * @return */ - public static boolean instanceOf(Class objectClass, Object typeObject) { - Class typeClass = typeObject.getClass(); + public static boolean instanceOf(Class<?> objectClass, Object typeObject) { + Class<?> typeClass = typeObject.getClass(); return instanceOf(objectClass, typeClass); } @@ -312,7 +312,7 @@ * @param typeName name to test against * @return */ - public static boolean instanceOf(Class objectClass, String typeName) { + public static boolean instanceOf(Class<?> objectClass, String typeName) { return instanceOf(objectClass, typeName, null); } @@ -323,7 +323,7 @@ * @return */ public static boolean instanceOf(Object obj, Object typeObject) { - Class typeClass = typeObject.getClass(); + Class<?> typeClass = typeObject.getClass(); return instanceOf(obj, typeClass); } @@ -345,8 +345,8 @@ * @param loader * @return */ - public static boolean instanceOf(Class objectClass, String typeName, ClassLoader loader) { - Class infoClass = loadInfoClass(typeName, loader); + public static boolean instanceOf(Class<?> objectClass, String typeName, ClassLoader loader) { + Class<?> infoClass = loadInfoClass(typeName, loader); if (infoClass == null) throw new IllegalArgumentException("Illegal type found in info map (could not load class for specified type)"); @@ -362,7 +362,7 @@ * @return */ public static boolean instanceOf(Object obj, String typeName, ClassLoader loader) { - Class infoClass = loadInfoClass(typeName, loader); + Class<?> infoClass = loadInfoClass(typeName, loader); if (infoClass == null) { throw new IllegalArgumentException("Illegal type found in info map (could not load class for specified type)"); @@ -371,7 +371,7 @@ return instanceOf(obj, infoClass); } - public static Class loadInfoClass(String typeName, ClassLoader loader) { + public static Class<?> loadInfoClass(String typeName, ClassLoader loader) { //Class infoClass = null; try { return ObjectType.loadClass(typeName, loader); @@ -405,9 +405,9 @@ * @param typeClass Class to test against * @return */ - public static boolean instanceOf(Object obj, Class typeClass) { + public static boolean instanceOf(Object obj, Class<?> typeClass) { if (obj == null) return true; - Class objectClass = obj.getClass(); + Class<?> objectClass = obj.getClass(); return instanceOf(objectClass, typeClass); } @@ -417,7 +417,7 @@ * @param typeClass Class to test against * @return */ - public static boolean instanceOf(Class objectClass, Class typeClass) { + public static boolean instanceOf(Class<?> objectClass, Class<?> typeClass) { if (typeClass.isInterface()) { return interfaceOf(objectClass, typeClass); } else { @@ -460,7 +460,7 @@ String fromType = null; if ((type.equals("List") || type.equals("java.util.List")) && obj.getClass().isArray()) { - List newObj = FastList.newInstance(); + List<Object> newObj = FastList.newInstance(); int len = Array.getLength(obj); for (int i = 0; i < len; i++) { newObj.add(Array.get(obj, i)); @@ -591,7 +591,7 @@ if (str.startsWith("[") && str.endsWith("]")) { return StringUtil.toList(str); } else { - List tempList = FastList.newInstance(); + List<String> tempList = FastList.newInstance(); tempList.add(str); return tempList; } @@ -599,7 +599,7 @@ if (str.startsWith("[") && str.endsWith("]")) { return StringUtil.toSet(str); } else { - Set tempSet = FastSet.newInstance(); + Set<String> tempSet = FastSet.newInstance(); tempSet.add(str); return tempSet; } @@ -627,11 +627,11 @@ } else if ("Integer".equals(type) || "java.lang.Integer".equals(type)) { return Integer.valueOf((int) Math.round(dbl.doubleValue())); } else if ("List".equals(type) || "java.util.List".equals(type)) { - List tempList = FastList.newInstance(); + List<Double> tempList = FastList.newInstance(); tempList.add(dbl); return tempList; } else if ("Set".equals(type) || "java.util.Set".equals(type)) { - Set tempSet = FastSet.newInstance(); + Set<Double> tempSet = FastSet.newInstance(); tempSet.add(dbl); return tempSet; } else { @@ -655,11 +655,11 @@ } else if ("Integer".equals(type)) { return Integer.valueOf((int) Math.round(flt.doubleValue())); } else if ("List".equals(type) || "java.util.List".equals(type)) { - List tempList = FastList.newInstance(); + List<Float> tempList = FastList.newInstance(); tempList.add(flt); return tempList; } else if ("Set".equals(type) || "java.util.Set".equals(type)) { - Set tempSet = FastSet.newInstance(); + Set<Float> tempSet = FastSet.newInstance(); tempSet.add(flt); return tempSet; } else { @@ -683,11 +683,11 @@ } else if ("Integer".equals(type) || "java.lang.Integer".equals(type)) { return Integer.valueOf(lng.intValue()); } else if ("List".equals(type) || "java.util.List".equals(type)) { - List tempList = FastList.newInstance(); + List<Long> tempList = FastList.newInstance(); tempList.add(lng); return tempList; } else if ("Set".equals(type) || "java.util.Set".equals(type)) { - Set tempSet = FastSet.newInstance(); + Set<Long> tempSet = FastSet.newInstance(); tempSet.add(lng); return tempSet; } else { @@ -710,11 +710,11 @@ } else if ("Integer".equals(type) || "java.lang.Integer".equals(type)) { return obj; } else if ("List".equals(type) || "java.util.List".equals(type)) { - List tempList = FastList.newInstance(); + List<Integer> tempList = FastList.newInstance(); tempList.add(intgr); return tempList; } else if ("Set".equals(type) || "java.util.Set".equals(type)) { - Set tempSet = FastSet.newInstance(); + Set<Integer> tempSet = FastSet.newInstance(); tempSet.add(intgr); return tempSet; } else { @@ -737,11 +737,11 @@ } else if ("Integer".equals(type) || "java.lang.Integer".equals(type)) { return Integer.valueOf(bigDec.intValue()); } else if ("List".equals(type) || "java.util.List".equals(type)) { - List tempList = FastList.newInstance(); + List<BigDecimal> tempList = FastList.newInstance(); tempList.add(bigDec); return tempList; } else if ("Set".equals(type) || "java.util.Set".equals(type)) { - Set tempSet = FastSet.newInstance(); + Set<BigDecimal> tempSet = FastSet.newInstance(); tempSet.add(bigDec); return tempSet; } else { @@ -765,11 +765,11 @@ } else if ("Timestamp".equals(type) || "java.sql.Timestamp".equals(type)) { return new java.sql.Timestamp(dte.getTime()); } else if ("List".equals(type) || "java.util.List".equals(type)) { - List tempList = FastList.newInstance(); + List<java.sql.Date> tempList = FastList.newInstance(); tempList.add(dte); return tempList; } else if ("Set".equals(type) || "java.util.Set".equals(type)) { - Set tempSet = FastSet.newInstance(); + Set<java.sql.Date> tempSet = FastSet.newInstance(); tempSet.add(dte); return tempSet; } else { @@ -794,11 +794,11 @@ } else if ("Timestamp".equals(type) || "java.sql.Timestamp".equals(type)) { return new java.sql.Timestamp(tme.getTime()); } else if ("List".equals(type) || "java.util.List".equals(type)) { - List tempList = FastList.newInstance(); + List<java.sql.Time> tempList = FastList.newInstance(); tempList.add(tme); return tempList; } else if ("Set".equals(type) || "java.util.Set".equals(type)) { - Set tempSet = FastSet.newInstance(); + Set<java.sql.Time> tempSet = FastSet.newInstance(); tempSet.add(tme); return tempSet; } else { @@ -823,11 +823,11 @@ } else if ("Timestamp".equals(type) || "java.sql.Timestamp".equals(type)) { return obj; } else if ("List".equals(type) || "java.util.List".equals(type)) { - List tempList = FastList.newInstance(); + List<java.sql.Timestamp> tempList = FastList.newInstance(); tempList.add(tme); return tempList; } else if ("Set".equals(type) || "java.util.Set".equals(type)) { - Set tempSet = FastSet.newInstance(); + Set<java.sql.Timestamp> tempSet = FastSet.newInstance(); tempSet.add(tme); return tempSet; } else { @@ -847,11 +847,11 @@ return Integer.valueOf(0); } } else if ("List".equals(type) || "java.util.List".equals(type)) { - List tempList = FastList.newInstance(); + List<Boolean> tempList = FastList.newInstance(); tempList.add(bol); return tempList; } else if ("Set".equals(type) || "java.util.Set".equals(type)) { - Set tempSet = FastSet.newInstance(); + Set<Boolean> tempSet = FastSet.newInstance(); tempSet.add(bol); return tempSet; } else { @@ -886,11 +886,11 @@ } else if ("String".equals(type) || "java.lang.String".equals(type)) { return obj.toString(); } else if ("List".equals(type) || "java.util.List".equals(type)) { - List tempList = FastList.newInstance(); + List<Object> tempList = FastList.newInstance(); tempList.add(obj); return tempList; } else if ("Set".equals(type) || "java.util.Set".equals(type)) { - Set tempSet = FastSet.newInstance(); + Set<Object> tempSet = FastSet.newInstance(); tempSet.add(obj); return tempSet; } else { @@ -904,12 +904,12 @@ } else if ("String".equals(type) || "java.lang.String".equals(type)) { return map.toString(); } else if ("List".equals(type) || "java.util.List".equals(type)) { - List tempList = FastList.newInstance(); - tempList.add(obj); + List<Map> tempList = FastList.newInstance(); + tempList.add(map); return tempList; } else if ("Set".equals(type) || "java.util.Set".equals(type)) { - Set tempSet = FastSet.newInstance(); - tempSet.add(obj); + Set<Map> tempSet = FastSet.newInstance(); + tempSet.add(map); return tempSet; } else { throw new GeneralException("Conversion from " + fromType + " to " + type + " not currently supported"); @@ -945,14 +945,14 @@ } public static Boolean doRealCompare(Object value1, Object value2, String operator, String type, String format, - List messages, Locale locale, ClassLoader loader, boolean value2InlineConstant) { + List<Object> messages, Locale locale, ClassLoader loader, boolean value2InlineConstant) { boolean verboseOn = Debug.verboseOn(); if (verboseOn) Debug.logVerbose("Comparing value1: \"" + value1 + "\" " + operator + " value2:\"" + value2 + "\"", module); try { if (!"PlainString".equals(type)) { - Class clz = ObjectType.loadClass(type, loader); + Class<?> clz = ObjectType.loadClass(type, loader); type = clz.getName(); } } catch (ClassNotFoundException e) { Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilDateTime.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilDateTime.java?rev=585683&r1=585682&r2=585683&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilDateTime.java (original) +++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilDateTime.java Wed Oct 17 13:44:11 2007 @@ -108,30 +108,30 @@ } public static String formatInterval(double interval, int count, Locale locale) { - ArrayList parts = new ArrayList(timevals.length); - for (int i = 0; i < timevals.length; i++) { - int value = Integer.parseInt(timevals[i][0]); + ArrayList<Double> parts = new ArrayList<Double>(timevals.length); + for (String[] timeval: timevals) { + int value = Integer.valueOf(timeval[0]); double remainder = interval % value; interval = interval / value; - parts.add(new Double(remainder)); + parts.add(remainder); } - Map uiDateTimeMap = UtilProperties.getResourceBundleMap("DateTimeLabels", locale); + Map<String, Object> uiDateTimeMap = UtilProperties.getResourceBundleMap("DateTimeLabels", locale); StringBuilder sb = new StringBuilder(); for (int i = parts.size() - 1; i >= 0 && count > 0; i--) { if (sb.length() > 0) sb.append(", "); - Double D = (Double) parts.get(i); + Double D = parts.get(i); double d = D.doubleValue(); if (d < 1) continue; count--; sb.append(count == 0 ? df.format(d) : Integer.toString(D.intValue())); sb.append(' '); - String label; + Object label; if (D.intValue() == 1) { - label = (String) uiDateTimeMap.get(timevals[i][1] + ".singular"); + label = uiDateTimeMap.get(timevals[i][1] + ".singular"); } else { - label = (String) uiDateTimeMap.get(timevals[i][1] + ".plural"); + label = uiDateTimeMap.get(timevals[i][1] + ".plural"); } sb.append(label); } @@ -883,11 +883,11 @@ * @param locale * @return List of day name Strings */ - public static List getDayNames(Locale locale) { + public static List<String> getDayNames(Locale locale) { Calendar tempCal = Calendar.getInstance(locale); tempCal.set(Calendar.DAY_OF_WEEK, tempCal.getFirstDayOfWeek()); SimpleDateFormat dateFormat = new SimpleDateFormat("EEEE", locale); - List resultList = new ArrayList(); + List<String> resultList = new ArrayList<String>(); for (int i = 0; i < 7; i++) { resultList.add(dateFormat.format(tempCal.getTime())); tempCal.roll(Calendar.DAY_OF_WEEK, 1); @@ -981,24 +981,24 @@ return dateFormat.format(stamp); } - protected static List availableTimeZoneList = null; + protected static List<TimeZone> availableTimeZoneList = null; /** Returns a List of available TimeZone objects. * @see java.util.TimeZone */ - public static List availableTimeZones() { + public static List<TimeZone> availableTimeZones() { if (availableTimeZoneList == null) { synchronized(UtilDateTime.class) { if (availableTimeZoneList == null) { - availableTimeZoneList = new LinkedList(); - List idList = null; + availableTimeZoneList = new LinkedList<TimeZone>(); + List<String> idList = null; String tzString = UtilProperties.getPropertyValue("general", "timeZones.available"); if (tzString != null && tzString.length() > 0) { idList = StringUtil.split(tzString, ","); } else { idList = Arrays.asList(TimeZone.getAvailableIDs()); } - for (Iterator i = idList.iterator(); i.hasNext();) { - TimeZone curTz = TimeZone.getTimeZone((String)i.next()); + for (String id: idList) { + TimeZone curTz = TimeZone.getTimeZone(id); availableTimeZoneList.add(curTz); } } Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilName.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilName.java?rev=585683&r1=585682&r2=585683&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilName.java (original) +++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilName.java Wed Oct 17 13:44:11 2007 @@ -50,18 +50,15 @@ // check the name for empty elements String[] splitStr = name.split(" "); - List goodElements = new ArrayList(); - for (int i = 0; i < splitStr.length; i++) { - if (splitStr[i] != null && splitStr[i].length() > 0 && !splitStr[i].matches("\\W+")) { - goodElements.add(splitStr[i]); + List<String> goodElements = new ArrayList<String>(); + for (String item: splitStr) { + if (item != null && item.length() > 0 && !item.matches("\\W+")) { + goodElements.add(item); } } // fill in the name array - this.name = new String[goodElements.size()]; - for (int i = 0; i < this.name.length; i++) { - this.name[i] = (String) goodElements.get(i); - } + this.name = goodElements.toArray(new String[goodElements.size()]); } public UtilName(String name) { @@ -103,11 +100,11 @@ return name[index[0]]; } else { StringBuilder nameBuf = new StringBuilder(); - for (int i = 0; i < index.length; i++) { + for (int i: index) { if (nameBuf.length() > 0) { nameBuf.append(" "); } - nameBuf.append(name[index[i]]); + nameBuf.append(name[i]); } return nameBuf.toString(); } @@ -115,8 +112,8 @@ return null; } - public Map getNameMap() { - Map nameMap = new HashMap(); + public Map<String, String> getNameMap() { + Map<String, String> nameMap = new HashMap<String, String>(); nameMap.put("personalTitle", this.getPrefix()); nameMap.put("firstName", this.getFirstName()); nameMap.put("middleName", this.getMiddleName()); @@ -128,11 +125,11 @@ protected String indexString(int[] index) { StringBuilder str = new StringBuilder(); if (index != null) { - for (int i = 0; i < index.length; i++) { + for (int i: index) { if (str.length() != 0) { str.append(", "); } - str.append(index[i]); + str.append(i); } } @@ -235,36 +232,34 @@ } protected boolean checkValue(String field, String[] values) { - for (int i = 0; i < values.length; i++) { - if (values[i].equals(field)) { + for (String value: values) { + if (value.equals(field)) { return true; } } return false; } - public static Map parseName(String name, boolean middleIsInitial) { + public static Map<String, String> parseName(String name, boolean middleIsInitial) { return (new UtilName(name, middleIsInitial)).getNameMap(); } - public static Map parseName(String name) { + public static Map<String, String> parseName(String name) { return parseName(name, false); } public static void main(String[] args) throws Exception { StringBuilder name = new StringBuilder(); - for (int i = 0; i < args.length; i++) { + for (String arg: args) { if (name.length() != 0) { name.append(" "); } - name.append(args[i]); + name.append(arg); } - Map nameMap = parseName(name.toString(), true); - Iterator i = nameMap.keySet().iterator(); - while (i.hasNext()) { - String f = (String) i.next(); - System.out.println(f + " - " + nameMap.get(f)); + Map<String, String> nameMap = parseName(name.toString(), true); + for (Map.Entry<String, String> entry: nameMap.entrySet()) { + System.out.println(entry.getKey() + " - " + entry.getValue()); } } } Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilNumber.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilNumber.java?rev=585683&r1=585682&r2=585683&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilNumber.java (original) +++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilNumber.java Wed Oct 17 13:44:11 2007 @@ -153,9 +153,9 @@ + " 100: <00<;\n"; // hash map to store ICU4J rule sets keyed to Locale - public static HashMap rbnfRuleSets; + public static HashMap<Locale, String> rbnfRuleSets; static { - rbnfRuleSets = new HashMap(); + rbnfRuleSets = new HashMap<Locale, String>(); rbnfRuleSets.put(Locale.US, ruleSet_en_US); } Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilObject.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilObject.java?rev=585683&r1=585682&r2=585683&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilObject.java (original) +++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilObject.java Wed Oct 17 13:44:11 2007 @@ -162,7 +162,7 @@ } } - public static int compareToHelper(Comparable o1, Object o2) { + public static <T> int compareToHelper(Comparable<T> o1, T o2) { if (o1 == o2) { // handles same-reference, or null return 0; Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/LifoSet.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/LifoSet.java?rev=585683&r1=585682&r2=585683&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/LifoSet.java (original) +++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/LifoSet.java Wed Oct 17 13:44:11 2007 @@ -28,10 +28,10 @@ * LifoSet - Set interface wrapper around a LinkedList * */ -public class LifoSet extends AbstractSet implements Serializable { +public class LifoSet<V> extends AbstractSet<V> implements Serializable { // This set's back LinkedList - private LinkedList backedList = new LinkedList(); + private LinkedList<V> backedList = new LinkedList<V>(); private int maxCapacity = 10; /** @@ -70,7 +70,7 @@ /** * @see java.util.Collection#add(java.lang.Object) */ - public boolean add(Object obj) { + public boolean add(V obj) { int index = backedList.indexOf(obj); if (index == -1) { @@ -87,7 +87,7 @@ /** * @see java.util.Collection#iterator() */ - public Iterator iterator() { + public Iterator<V> iterator() { return backedList.iterator(); } @@ -110,7 +110,7 @@ * * @param item The item to be pushed onto this stack */ - public void push(Object item) { + public void push(V item) { this.add(item); } @@ -120,7 +120,7 @@ * @return The object at the top of this stack * @throws EmptyStackException If this stack is empty */ - public Object pop() throws EmptyStackException { + public V pop() throws EmptyStackException { if (this.size() > 0) { return backedList.removeFirst(); } @@ -133,7 +133,7 @@ * @return The object at the top of this stack * @throws EmptyStackException If this stack is empty */ - public Object peek() throws EmptyStackException { + public V peek() throws EmptyStackException { if (this.size() > 0) { return backedList.getFirst(); } |
Free forum by Nabble | Edit this page |