You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by do...@apache.org on 2007/10/17 22:41:02 UTC

svn commit: r585681 - in /ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util: ./ template/

Author: doogie
Date: Wed Oct 17 13:41:01 2007
New Revision: 585681

URL: http://svn.apache.org/viewvc?rev=585681&view=rev
Log:
Java 1.5 feature usage; generics, enhanced-for, etc.  Closes
https://issues.apache.org/jira/browse/OFBIZ-1331

Modified:
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/AliasKeyManager.java
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/BshUtil.java
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/CachedClassLoader.java
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/Debug.java
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/GeneralException.java
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/HttpClient.java
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/HttpRequestFileUpload.java
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/JNDIContextFactory.java
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/KeyStoreUtil.java
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/MessageString.java
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/OfbizBshBsfEngine.java
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/StringUtil.java
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/template/XslTransform.java

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/AliasKeyManager.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/AliasKeyManager.java?rev=585681&r1=585680&r2=585681&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/AliasKeyManager.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/AliasKeyManager.java Wed Oct 17 13:41:01 2007
@@ -43,13 +43,13 @@
     }
 
     // this is where the customization comes in
-    public String chooseClientAlias(String[] keyType, Principal[] issuers, Socket socket) {
-        for (int i = 0; i < keyType.length; i++) {
-            String[] aliases = keyManager.getClientAliases(keyType[i], null); // ignoring the issuers 
+    public String chooseClientAlias(String[] keyTypes, Principal[] issuers, Socket socket) {
+        for (String keyType: keyTypes) {
+            String[] aliases = keyManager.getClientAliases(keyType, null); // ignoring the issuers 
             if (aliases != null && aliases.length > 0) {
-                for (int x = 0; x < aliases.length; x++) {
-                    if (this.alias.equals(aliases[x])) {
-                        if (Debug.verboseOn()) Debug.logVerbose("chooseClientAlias for keyType [" + keyType[i] + "] got alias " + this.alias, module);
+                for (String alias: aliases) {
+                    if (this.alias.equals(alias)) {
+                        if (Debug.verboseOn()) Debug.logVerbose("chooseClientAlias for keyType [" + keyType + "] got alias " + this.alias, module);
                         //Debug.logInfo(new Exception(), "Location where chooseClientAlias is called", module);
                         return this.alias;
                     }
@@ -64,13 +64,18 @@
         return keyManager.chooseServerAlias(keyType, issuers, socket);
     }
 
+    // these just pass through the keyManager
+    public String chooseServerAlias(String keyType, Socket socket, Principal... issuers) {
+        return keyManager.chooseServerAlias(keyType, issuers, socket);
+    }
+
     public X509Certificate[] getCertificateChain(String alias) {
         X509Certificate[] certArray = keyManager.getCertificateChain(alias);
         if (Debug.verboseOn()) Debug.logVerbose("getCertificateChain for alias [" + alias + "] got " + certArray.length + " results", module);
         return certArray;
     }
 
-    public String[] getClientAliases(String keyType, Principal[] issuers) {
+    public String[] getClientAliases(String keyType, Principal... issuers) {
         return keyManager.getClientAliases(keyType, issuers);
     }
 
@@ -81,7 +86,7 @@
         return pk;
     }
 
-    public String[] getServerAliases(String keyType, Principal[] issuers) {
+    public String[] getServerAliases(String keyType, Principal... issuers) {
         return keyManager.getServerAliases(keyType, issuers);
     }
 }

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/BshUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/BshUtil.java?rev=585681&r1=585680&r2=585681&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/BshUtil.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/BshUtil.java Wed Oct 17 13:41:01 2007
@@ -46,8 +46,8 @@
 
     public static final String module = BshUtil.class.getName();
 
-    protected static Map masterClassManagers = new HashMap();
-    public static UtilCache parsedScripts = new UtilCache("script.BshLocationParsedCache", 0, 0, false);
+    protected static Map<ClassLoader, BshClassManager> masterClassManagers = new HashMap<ClassLoader, BshClassManager>();
+    public static UtilCache<String, Interpreter.ParsedScript> parsedScripts = new UtilCache<String, Interpreter.ParsedScript>("script.BshLocationParsedCache", 0, 0, false);
     
     /**
      * Evaluate a BSH condition or expression
@@ -56,7 +56,7 @@
      * @return Object The result of the evaluation 
      * @throws EvalError
      */
-    public static final Object eval(String expression, Map context) throws EvalError {
+    public static final Object eval(String expression, Map<String, Object> context) throws EvalError {
         Object o = null;
         if (expression == null || expression.equals("")) {
             Debug.logError("BSH Evaluation error. Empty expression", module);
@@ -78,8 +78,8 @@
             // read back the context info
             NameSpace ns = bsh.getNameSpace();
             String[] varNames = ns.getVariableNames();
-            for (int x = 0; x < varNames.length; x++) {
-                context.put(varNames[x], bsh.get(varNames[x]));
+            for (String varName: varNames) {
+                context.put(varName, bsh.get(varName));
             }
         } catch (EvalError e) {
             Debug.logError(e, "BSH Evaluation error.", module);
@@ -88,16 +88,12 @@
         return o;
     }
     
-    public static Interpreter makeInterpreter(Map context) throws EvalError {
+    public static Interpreter makeInterpreter(Map<String, ? extends Object> context) throws EvalError {
         Interpreter bsh = getMasterInterpreter(null);
         // Set the context for the condition
         if (context != null) {
-            Set keySet = context.keySet();
-            Iterator i = keySet.iterator();
-            while (i.hasNext()) {
-                Object key = i.next();
-                Object value = context.get(key);
-                bsh.set((String) key, value);
+            for (Map.Entry<String, ? extends Object> entry: context.entrySet()) {
+                bsh.set(entry.getKey(), entry.getValue());
             }
             
             // include the context itself in for easier access in the scripts
@@ -113,10 +109,10 @@
         }
 
         //find the "master" BshClassManager for this classpath
-        BshClassManager master = (BshClassManager) BshUtil.masterClassManagers.get(classLoader);
+        BshClassManager master = BshUtil.masterClassManagers.get(classLoader);
         if (master == null) {
             synchronized (OfbizBshBsfEngine.class) {
-                master = (BshClassManager) BshUtil.masterClassManagers.get(classLoader);
+                master = BshUtil.masterClassManagers.get(classLoader);
                 if (master == null) {
                     master = BshClassManager.createClassManager();
                     master.setClassLoader(classLoader);
@@ -136,15 +132,15 @@
         }
     }
     
-    public static Object runBshAtLocation(String location, Map context) throws GeneralException {
+    public static Object runBshAtLocation(String location, Map<String, ? extends Object> context) throws GeneralException {
         try {
             Interpreter interpreter = makeInterpreter(context);
             
             Interpreter.ParsedScript script = null;
-            script = (Interpreter.ParsedScript) parsedScripts.get(location);
+            script = parsedScripts.get(location);
             if (script == null) {
                 synchronized (OfbizBshBsfEngine.class) {
-                    script = (Interpreter.ParsedScript) parsedScripts.get(location);
+                    script = parsedScripts.get(location);
                     if (script == null) {
                         URL scriptUrl = FlexibleLocation.resolveLocation(location);
                         if (scriptUrl == null) {

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/CachedClassLoader.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/CachedClassLoader.java?rev=585681&r1=585680&r2=585681&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/CachedClassLoader.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/CachedClassLoader.java Wed Oct 17 13:41:01 2007
@@ -34,17 +34,17 @@
     
     private String contextName;
 
-    public static Map globalClassNameClassMap = new HashMap();
-    public static HashSet globalBadClassNameSet = new HashSet();
+    public static Map<String, Class<?>> globalClassNameClassMap = new HashMap<String, Class<?>>();
+    public static HashSet<String> globalBadClassNameSet = new HashSet<String>();
 
-    public Map localClassNameClassMap = new HashMap();
-    public HashSet localBadClassNameSet = new HashSet();
+    public Map<String, Class<?>> localClassNameClassMap = new HashMap<String, Class<?>>();
+    public HashSet<String> localBadClassNameSet = new HashSet<String>();
 
-    public static Map globalResourceMap = new HashMap();
-    public static HashSet globalBadResourceNameSet = new HashSet();
+    public static Map<String, URL> globalResourceMap = new HashMap<String, URL>();
+    public static HashSet<String> globalBadResourceNameSet = new HashSet<String>();
 
-    public Map localResourceMap = new HashMap();
-    public HashSet localBadResourceNameSet = new HashSet();
+    public Map<String, URL> localResourceMap = new HashMap<String, URL>();
+    public HashSet<String> localBadResourceNameSet = new HashSet<String>();
 
     static {
         // setup some commonly used classes...
@@ -150,16 +150,16 @@
         return "org.ofbiz.base.util.CachedClassLoader(" + contextName + ") / " + getParent().toString();
     }
     
-    public Class loadClass(String name) throws ClassNotFoundException {
+    public Class<?> loadClass(String name) throws ClassNotFoundException {
         return loadClass(name, false);
     }
     
-    protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException {
+    protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
         //check glocal common classes, ie for all instances
-        Class theClass = (Class) globalClassNameClassMap.get(name);
+        Class<?> theClass = globalClassNameClassMap.get(name);
         
         //check local classes, ie for this instance
-        if (theClass == null) theClass = (Class) localClassNameClassMap.get(name);
+        if (theClass == null) theClass = localClassNameClassMap.get(name);
 
         //make sure it is not a known bad class name
         if (theClass == null) {
@@ -173,7 +173,7 @@
             if (Debug.verboseOn()) Debug.logVerbose("Cached loader cache miss for class name: [" + name + "]", module);
             
             synchronized (this) {
-                theClass = (Class) localClassNameClassMap.get(name);
+                theClass = localClassNameClassMap.get(name);
                 if (theClass == null) {
                     try {
                         theClass = super.loadClass(name, resolve);
@@ -200,10 +200,10 @@
     
     public URL getResource(String name) {
         //check glocal common resources, ie for all instances
-        URL theResource = (URL) globalResourceMap.get(name);
+        URL theResource = globalResourceMap.get(name);
         
         //check local resources, ie for this instance
-        if (theResource == null) theResource = (URL) localResourceMap.get(name);
+        if (theResource == null) theResource = localResourceMap.get(name);
 
         //make sure it is not a known bad resource name
         if (theResource == null) {
@@ -218,7 +218,7 @@
             //Debug.logInfo("Cached loader cache miss for resource name: [" + name + "]", module);
             
             synchronized (this) {
-                theResource = (URL) localResourceMap.get(name);
+                theResource = localResourceMap.get(name);
                 if (theResource == null) {
                     theResource = super.getResource(name);
                     if (theResource == null) {

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/Debug.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/Debug.java?rev=585681&r1=585680&r2=585681&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/Debug.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/Debug.java Wed Oct 17 13:41:01 2007
@@ -60,7 +60,7 @@
     public static final String[] levelProps = {"", "print.verbose", "print.timing", "print.info", "print.important", "print.warning", "print.error", "print.fatal", "print.notify"};
     public static final Level[] levelObjs = {Level.INFO, Level.DEBUG, Level.DEBUG, Level.INFO, Level.INFO, Level.WARN, Level.ERROR, Level.FATAL, NotifyLevel.NOTIFY};
 
-    protected static Map levelStringMap = new HashMap();
+    protected static Map<String, Integer> levelStringMap = new HashMap<String, Integer>();
     
     protected static PrintStream printStream = System.out;
     protected static PrintWriter printWriter = new PrintWriter(printStream);
@@ -130,7 +130,7 @@
     /** Gets an Integer representing the level number from a String representing the level name; will return null if not found */
     public static Integer getLevelFromString(String levelName) {
         if (levelName == null) return null;
-        return (Integer) levelStringMap.get(levelName.toLowerCase());
+        return levelStringMap.get(levelName.toLowerCase());
     }
     
     /** Gets an int representing the level number from a String representing the level name; if level not found defaults to Debug.INFO */

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/GeneralException.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/GeneralException.java?rev=585681&r1=585680&r2=585681&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/GeneralException.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/GeneralException.java Wed Oct 17 13:41:01 2007
@@ -29,7 +29,7 @@
 public class GeneralException extends Exception {
 
     Throwable nested = null;
-    List messages = null;
+    List<String> messages = null;
 
     /**
      * Creates new <code>GeneralException</code> without detail message.
@@ -70,7 +70,7 @@
      * @param msg the detail message.
      * @param messages error message list.
      */
-    public GeneralException(String msg, List messages) {
+    public GeneralException(String msg, List<String> messages) {
         super(msg);        
         this.messages = messages;
     }
@@ -81,7 +81,7 @@
      * @param messages error message list.
      * @param nested the nexted exception
      */
-    public GeneralException(String msg, List messages, Throwable nested) {
+    public GeneralException(String msg, List<String> messages, Throwable nested) {
         super(msg);
         this.nested = nested;
         this.messages = messages;
@@ -92,13 +92,13 @@
      * @param messages error message list.
      * @param nested the nested exception.
      */
-    public GeneralException(List messages, Throwable nested) {
+    public GeneralException(List<String> messages, Throwable nested) {
         super();
         this.nested = nested;
         this.messages = messages;
     }
 
-    public GeneralException(List messages) {
+    public GeneralException(List<String> messages) {
         super();
         this.messages = messages;
     }
@@ -116,7 +116,7 @@
         }
     }
 
-    public List getMessageList() {
+    public List<String> getMessageList() {
         return this.messages;
     }
 

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/HttpClient.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/HttpClient.java?rev=585681&r1=585680&r2=585681&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/HttpClient.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/HttpClient.java Wed Oct 17 13:41:01 2007
@@ -55,8 +55,8 @@
     private String basicAuthUsername = null;
     private String basicAuthPassword = null;
 
-    private Map parameters = null;
-    private Map headers = null;
+    private Map<String, Object> parameters = null;
+    private Map<String, String> headers = null;
     
     private URL requestUrl = null;
     private URLConnection con = null;
@@ -75,26 +75,26 @@
     }
 
     /** Creates a new HttpClient object. */
-    public HttpClient(String url, Map parameters) {
+    public HttpClient(String url, Map<String, Object> parameters) {
         this.url = url;
         this.parameters = parameters;      
     }
 
     /** Creates a new HttpClient object. */
-    public HttpClient(URL url, Map parameters) {
+    public HttpClient(URL url, Map<String, Object> parameters) {
         this.url = url.toExternalForm();
         this.parameters = parameters;
     }
 
     /** Creates a new HttpClient object. */
-    public HttpClient(String url, Map parameters, Map headers) {
+    public HttpClient(String url, Map<String, Object> parameters, Map<String, String> headers) {
         this.url = url;
         this.parameters = parameters;
         this.headers = headers;
     }
 
     /** Creates a new HttpClient object. */
-    public HttpClient(URL url, Map parameters, Map headers) {
+    public HttpClient(URL url, Map<String, Object> parameters, Map<String, String> headers) {
         this.url = url.toExternalForm();
         this.parameters = parameters;
         this.headers = headers;
@@ -136,36 +136,36 @@
     }
 
     /** Set the parameters for this request. */
-    public void setParameters(Map parameters) {
+    public void setParameters(Map<String, Object> parameters) {
         this.parameters = parameters;
     }
 
     /** Set an individual parameter for this request. */
     public void setParameter(String name, String value) {
         if (parameters == null)
-            parameters = new HashMap();
+            parameters = new HashMap<String, Object>();
         parameters.put(name, value);
     }
 
     /** Set the headers for this request. */
-    public void setHeaders(Map headers) {
+    public void setHeaders(Map<String, String> headers) {
         this.headers = headers;
     }
 
     /** Set an individual header for this request. */
     public void setHeader(String name, String value) {
         if (headers == null)
-            headers = new HashMap();
+            headers = new HashMap<String, String>();
         headers.put(name, value);
     }
 
     /** Return a Map of headers. */
-    public Map getHeaders() {
+    public Map<String, String> getHeaders() {
         return headers;
     }
 
     /** Return a Map of parameters. */
-    public Map getParameters() {
+    public Map<String, Object> getParameters() {
         return parameters;
     }
 
@@ -452,12 +452,9 @@
             }
             
             if (headers != null && headers.size() > 0) {
-                Set headerSet = headers.keySet();
-                Iterator i = headerSet.iterator();
-
-                while (i.hasNext()) {
-                    String headerName = (String) i.next();
-                    String headerValue = (String) headers.get(headerName);
+                for (Map.Entry<String, String> entry: headers.entrySet()) {
+                    String headerName = entry.getKey();
+                    String headerValue = entry.getValue();
                     con.setRequestProperty(headerName, headerValue);
                     if (Debug.verboseOn() || debug) Debug.log("Header - " + headerName + ": " + headerValue, module);
                 }

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/HttpRequestFileUpload.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/HttpRequestFileUpload.java?rev=585681&r1=585680&r2=585681&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/HttpRequestFileUpload.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/HttpRequestFileUpload.java Wed Oct 17 13:41:01 2007
@@ -46,7 +46,7 @@
     private String filename;
     private String contentType;
     private String overrideFilename = null;
-    private Map fields;
+    private Map<String, String> fields;
 
     public String getOverrideFilename() {
         return overrideFilename;
@@ -75,7 +75,7 @@
     public String getFieldValue(String fieldName) {
         if (fields == null || fieldName == null)
             return null;
-        return (String) fields.get(fieldName);
+        return fields.get(fieldName);
     }
 
     private void setFilename(String s) {

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/JNDIContextFactory.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/JNDIContextFactory.java?rev=585681&r1=585680&r2=585681&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/JNDIContextFactory.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/JNDIContextFactory.java Wed Oct 17 13:41:01 2007
@@ -34,18 +34,18 @@
 public class JNDIContextFactory {
     
     public static final String module = JNDIContextFactory.class.getName();
-    static UtilCache contexts = new UtilCache("entity.JNDIContexts", 0, 0);
+    static UtilCache<String, InitialContext> contexts = new UtilCache<String, InitialContext>("entity.JNDIContexts", 0, 0);
 
     /** 
      * Return the initial context according to the entityengine.xml parameters that correspond to the given prefix
      * @return the JNDI initial context
      */
     public static InitialContext getInitialContext(String jndiServerName) throws GenericConfigException {
-        InitialContext ic = (InitialContext) contexts.get(jndiServerName);
+        InitialContext ic = contexts.get(jndiServerName);
 
         if (ic == null) {
             synchronized (JNDIContextFactory.class) {
-                ic = (InitialContext) contexts.get(jndiServerName);
+                ic = contexts.get(jndiServerName);
 
                 if (ic == null) {
                     JNDIConfigUtil.JndiServerInfo jndiServerInfo = JNDIConfigUtil.getJndiServerInfo(jndiServerName);
@@ -58,7 +58,7 @@
                         if (UtilValidate.isEmpty(jndiServerInfo.contextProviderUrl)) {
                             ic = new InitialContext();
                         } else {
-                            Hashtable h = new Hashtable();
+                            Hashtable<String, Object> h = new Hashtable<String, Object>();
 
                             h.put(Context.INITIAL_CONTEXT_FACTORY, jndiServerInfo.initialContextFactory);
                             h.put(Context.PROVIDER_URL, jndiServerInfo.contextProviderUrl);

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/KeyStoreUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/KeyStoreUtil.java?rev=585681&r1=585680&r2=585681&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/KeyStoreUtil.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/KeyStoreUtil.java Wed Oct 17 13:41:01 2007
@@ -104,22 +104,22 @@
         return (X509Certificate) cf.generateCertificate(bais);
     }
 
-    public static Map getCertX500Map(java.security.cert.X509Certificate cert) {
+    public static Map<String, String> getCertX500Map(java.security.cert.X509Certificate cert) {
         return getX500Map(cert.getSubjectX500Principal());
     }
 
-    public static Map getCertX500Map(javax.security.cert.X509Certificate cert) {
+    public static Map<String, String> getCertX500Map(javax.security.cert.X509Certificate cert) {
         return getX500Map(cert.getSubjectDN());
     }
 
-    public static Map getX500Map(Principal x500) {
-        Map x500Map = FastMap.newInstance();
+    public static Map<String, String> getX500Map(Principal x500) {
+        Map<String, String> x500Map = FastMap.newInstance();
         
         String name = x500.getName().replaceAll("\\\\,", "&com;");
         String[] x500Opts = name.split("\\,");
-        for (int x = 0; x < x500Opts.length; x++) {
-            if (x500Opts[x].indexOf("=") > -1) {
-                String[] nv = x500Opts[x].split("\\=", 2);                
+        for (String opt: x500Opts) {
+            if (opt.indexOf("=") > -1) {
+                String[] nv = opt.split("\\=", 2);                
                 x500Map.put(nv[0].replaceAll("&com;", ","), nv[1].replaceAll("&com;", ","));
             }
         }

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/MessageString.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/MessageString.java?rev=585681&r1=585680&r2=585681&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/MessageString.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/MessageString.java Wed Oct 17 13:41:01 2007
@@ -44,30 +44,28 @@
     protected String propertyName;
     protected boolean isError = true;
     
-    public static List getMessagesForField(String fieldName, boolean convertToStrings, List messageStringList) {
+    public static List<Object> getMessagesForField(String fieldName, boolean convertToStrings, List<Object> messageStringList) {
         if (fieldName == null) {
-            return Collections.EMPTY_LIST;
+            return Collections.emptyList();
         }
-        Set fieldSet = new TreeSet();
+        Set<String> fieldSet = new TreeSet<String>();
         fieldSet.add(fieldName);
         return getMessagesForField(fieldSet, convertToStrings, messageStringList);
     }
-    public static List getMessagesForField(String fieldName1, String fieldName2, String fieldName3, String fieldName4, boolean convertToStrings, List messageStringList) {
-        Set fieldSet = new TreeSet();
+    public static List<Object> getMessagesForField(String fieldName1, String fieldName2, String fieldName3, String fieldName4, boolean convertToStrings, List<Object> messageStringList) {
+        Set<String> fieldSet = new TreeSet<String>();
         if (fieldName1 != null && fieldName1.length() > 0) fieldSet.add(fieldName1);
         if (fieldName2 != null && fieldName2.length() > 0) fieldSet.add(fieldName2);
         if (fieldName3 != null && fieldName3.length() > 0) fieldSet.add(fieldName3);
         if (fieldName4 != null && fieldName4.length() > 0) fieldSet.add(fieldName4);
         return getMessagesForField(fieldSet, convertToStrings, messageStringList);
     }
-    public static List getMessagesForField(Set fieldNameSet, boolean convertToStrings, List messageStringList) {
+    public static List<Object> getMessagesForField(Set<String> fieldNameSet, boolean convertToStrings, List<Object> messageStringList) {
         if (messageStringList == null || fieldNameSet == null || fieldNameSet.size() == 0) {
-            return Collections.EMPTY_LIST;
+            return Collections.emptyList();
         }
-        List outList = new ArrayList(messageStringList.size());
-        Iterator messageStringIter = messageStringList.iterator();
-        while (messageStringIter.hasNext()) {
-            Object messageStringCur = messageStringIter.next();
+        List<Object> outList = new ArrayList<Object>(messageStringList.size());
+        for (Object messageStringCur: messageStringList) {
             if (messageStringCur instanceof MessageString) {
                 MessageString messageString = (MessageString) messageStringCur;
                 if (messageString.isForField(fieldNameSet)) {
@@ -144,7 +142,7 @@
     public void setFieldName(String fieldName) {
         this.fieldName = fieldName;
     }
-    public boolean isForField(Set fieldNameSet) {
+    public boolean isForField(Set<String> fieldNameSet) {
         if (fieldNameSet == null) {
             return true;
         }

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/OfbizBshBsfEngine.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/OfbizBshBsfEngine.java?rev=585681&r1=585680&r2=585681&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/OfbizBshBsfEngine.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/OfbizBshBsfEngine.java Wed Oct 17 13:41:01 2007
@@ -61,7 +61,7 @@
     protected Interpreter interpreter;
     protected boolean installedApplyMethod;
     
-    public static UtilCache parsedScripts = new UtilCache("script.BshBsfParsedCache", 0, 0, false);
+    public static UtilCache<String, Interpreter.ParsedScript> parsedScripts = new UtilCache<String, Interpreter.ParsedScript>("script.BshBsfParsedCache", 0, 0, false);
     
     public void initialize(BSFManager mgr, String lang, Vector declaredBeans) throws BSFException {
         super.initialize(mgr, lang, declaredBeans);
@@ -171,10 +171,10 @@
             Interpreter.ParsedScript script = null;
             
             if (source != null && source.length() > 0) {
-                script = (Interpreter.ParsedScript) parsedScripts.get(source);
+                script = parsedScripts.get(source);
                 if (script == null) {
                     synchronized (OfbizBshBsfEngine.class) {
-                        script = (Interpreter.ParsedScript) parsedScripts.get(source);
+                        script = parsedScripts.get(source);
                         if (script == null) {
                             script = interpreter.parseScript(source, new StringReader((String) expr));
                             Debug.logVerbose("Caching BSH script at: " + source, module);

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/StringUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/StringUtil.java?rev=585681&r1=585680&r2=585681&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/StringUtil.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/StringUtil.java Wed Oct 17 13:41:01 2007
@@ -82,14 +82,14 @@
      * @param delim the delimiter character(s) to use. (null value will join with no delimiter)
      * @return a String of all values in the list seperated by the delimiter
      */
-    public static String join(List list, String delim) {
+    public static String join(List<String> list, String delim) {
         if (list == null || list.size() < 1)
             return null;
         StringBuilder buf = new StringBuilder();
-        Iterator i = list.iterator();
+        Iterator<String> i = list.iterator();
 
         while (i.hasNext()) {
-            buf.append((String) i.next());
+            buf.append(i.next());
             if (i.hasNext())
                 buf.append(delim);
         }
@@ -102,8 +102,8 @@
      * @param delim the delimiter character(s) to join on (null will split on whitespace)
      * @return a list of Strings
      */
-    public static List split(String str, String delim) {
-        List splitList = null;
+    public static List<String> split(String str, String delim) {
+        List<String> splitList = null;
         StringTokenizer st = null;
 
         if (str == null)
@@ -127,15 +127,11 @@
      * Encloses each of a List of Strings in quotes.
      * @param list List of String(s) to quote.
      */
-    public static List quoteStrList(List list) {
-        List tmpList = list;
+    public static List<String> quoteStrList(List<String> list) {
+        List<String> tmpList = list;
 
         list = FastList.newInstance();
-        Iterator i = tmpList.iterator();
-
-        while (i.hasNext()) {
-            String str = (String) i.next();
-
+        for (String str: tmpList) {
             str = "'" + str + "''";
             list.add(str);
         }
@@ -148,21 +144,19 @@
      * @param trim Trim whitespace off fields
      * @return a Map of name/value pairs
      */
-    public static Map strToMap(String str, boolean trim) {
+    public static Map<String, String> strToMap(String str, boolean trim) {
         if (str == null) return null;
-        Map decodedMap = FastMap.newInstance();
-        List elements = split(str, "|");
-        Iterator i = elements.iterator();
+        Map<String, String> decodedMap = FastMap.newInstance();
+        List<String> elements = split(str, "|");
 
-        while (i.hasNext()) {
-            String s = (String) i.next();
-            List e = split(s, "=");
+        for (String s: elements) {
+            List<String> e = split(s, "=");
 
             if (e.size() != 2) {
                 continue;
             }
-            String name = (String) e.get(0);
-            String value = (String) e.get(1);
+            String name = e.get(0);
+            String value = e.get(1);
             if (trim) {
                 if (name != null) {
                     name = name.trim();
@@ -186,7 +180,7 @@
      * @param str The string to decode and format
      * @return a Map of name/value pairs
      */
-    public static Map strToMap(String str) {
+    public static Map<String, String> strToMap(String str) {
         return strToMap(str, false);
     }
 
@@ -195,16 +189,14 @@
      * @param map The Map of name/value pairs
      * @return String The encoded String
      */
-    public static String mapToStr(Map map) {
+    public static String mapToStr(Map<? extends Object, ? extends Object> map) {
         if (map == null) return null;
         StringBuilder buf = new StringBuilder();
-        Set keySet = map.keySet();
-        Iterator i = keySet.iterator();
         boolean first = true;
 
-        while (i.hasNext()) {
-            Object key = i.next();
-            Object value = map.get(key);
+        for (Map.Entry<? extends Object, ? extends Object> entry: map.entrySet()) {
+            Object key = entry.getKey();
+            Object value = entry.getValue();
 
             if (!(key instanceof String) || !(value instanceof String))
                 continue;
@@ -239,13 +231,13 @@
      * @param s String value of a Map ({n1=v1, n2=v2})
      * @return new Map
      */
-    public static Map toMap(String s) {
-        Map newMap = FastMap.newInstance();
+    public static Map<String, String> toMap(String s) {
+        Map<String, String> newMap = FastMap.newInstance();
         if (s.startsWith("{") && s.endsWith("}")) {
             s = s.substring(1, s.length() - 1);
-            String[] entry = s.split("\\,\\s");
-            for (int i = 0; i < entry.length; i++) {
-                String[] nv = entry[i].split("\\=");
+            String[] entries = s.split("\\,\\s");
+            for (String entry: entries) {
+                String[] nv = entry.split("\\=");
                 newMap.put(nv[0], nv[1]);
             }
         } else {
@@ -261,13 +253,13 @@
      * @param s String value of a Map ({n1=v1, n2=v2})
      * @return new List
      */
-    public static List toList(String s) {
-        List newList = FastList.newInstance();
+    public static List<String> toList(String s) {
+        List<String> newList = FastList.newInstance();
         if (s.startsWith("[") && s.endsWith("]")) {
             s = s.substring(1, s.length() - 1);
-            String[] entry = s.split("\\,\\s");
-            for (int i = 0; i < entry.length; i++) {
-                newList.add(entry[i]);
+            String[] entries = s.split("\\,\\s");
+            for (String entry: entries) {
+                newList.add(entry);
             }
         } else {
             throw new IllegalArgumentException("String is not from List.toString()");
@@ -282,13 +274,13 @@
      * @param s String value of a Map ({n1=v1, n2=v2})
      * @return new List
      */
-    public static Set toSet(String s) {
-        Set newSet = FastSet.newInstance();
+    public static Set<String> toSet(String s) {
+        Set<String> newSet = FastSet.newInstance();
         if (s.startsWith("[") && s.endsWith("]")) {
             s = s.substring(1, s.length() - 1);
-            String[] entry = s.split("\\,\\s");
-            for (int i = 0; i < entry.length; i++) {
-                newSet.add(entry[i]);
+            String[] entries = s.split("\\,\\s");
+            for (String entry: entries) {
+                newSet.add(entry);
             }
         } else {
             throw new IllegalArgumentException("String is not from Set.toString()");
@@ -304,11 +296,11 @@
      * @return Map of combined lists
      * @throws IllegalArgumentException When either List is null or the sizes do not equal
      */
-    public static Map createMap(List keys, List values) {
+    public static <K, V> Map<K, V> createMap(List<K> keys, List<V> values) {
         if (keys == null || values == null || keys.size() != values.size()) {
             throw new IllegalArgumentException("Keys and Values cannot be null and must be the same size");
         }
-        Map newMap = FastMap.newInstance();
+        Map<K, V> newMap = FastMap.newInstance();
         for (int i = 0; i < keys.size(); i++) {
             newMap.put(keys.get(i), values.get(i));
         }
@@ -337,9 +329,9 @@
 
     public static String toHexString(byte[] bytes) {
         StringBuilder buf = new StringBuilder(bytes.length * 2);
-        for (int i = 0; i < bytes.length; i++) {
-            buf.append(hexChar[(bytes[i] & 0xf0) >>> 4]);
-            buf.append(hexChar[bytes[i] & 0x0f]);
+        for (byte b: bytes) {
+            buf.append(hexChar[(b & 0xf0) >>> 4]);
+            buf.append(hexChar[b & 0x0f]);
         }
         return buf.toString();
 

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/template/XslTransform.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/template/XslTransform.java?rev=585681&r1=585680&r2=585681&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/template/XslTransform.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/template/XslTransform.java Wed Oct 17 13:41:01 2007
@@ -19,8 +19,6 @@
 package org.ofbiz.base.util.template;
 
 import java.util.Map;
-import java.util.Set;
-import java.util.Iterator;
 import java.io.StringReader;
 import java.net.URL;
 import java.net.URLConnection;
@@ -59,16 +57,16 @@
 public final class XslTransform {
 
     public static final String module = XslTransform.class.getName();
-    public static UtilCache xslTemplatesCache = new UtilCache("XsltTemplates", 0, 0);
+    public static UtilCache<String, Templates> xslTemplatesCache = new UtilCache<String, Templates>("XsltTemplates", 0, 0);
 
-    public static Document transform(Map context, Map params) 
+    public static Document transform(Map<String, Object> context, Map<String, Object> params) 
         throws GeneralException, IOException, TransformerConfigurationException, TransformerException {
         Document outputDocument = null;
         TransformerFactory tFactory = TransformerFactory.newInstance();
         Templates translet = null;
         String templateName = (String)context.get("templateName");
         if (UtilValidate.isNotEmpty(templateName)) {
-            translet = (Templates) xslTemplatesCache.get(templateName);
+            translet = xslTemplatesCache.get(templateName);
         }
 
         if (translet == null ) {
@@ -84,10 +82,7 @@
         if (translet != null ) {
             Transformer transformer = translet.newTransformer();
         	if (params != null) {
-               Set entrySet = params.entrySet(); 
-               Iterator iter = entrySet.iterator();
-               while (iter.hasNext()) {
-               	    Map.Entry entry = (Map.Entry)iter.next(); 
+                for (Map.Entry<String, Object> entry: params.entrySet()) {
                	    String key = (String)entry.getKey();
                     Object val = entry.getValue();
                     transformer.setParameter(key, val);