openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mik...@apache.org
Subject svn commit: r708213 - in /openjpa/trunk: openjpa-lib/src/main/java/org/apache/openjpa/lib/ant/ openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ openjpa-lib/src/main/java/org/apache/openjpa/lib/util/ openjpa-persistence-jdbc/src/test/java/org/apac...
Date Mon, 27 Oct 2008 15:07:01 GMT
Author: mikedd
Date: Mon Oct 27 08:07:00 2008
New Revision: 708213

URL: http://svn.apache.org/viewvc?rev=708213&view=rev
Log:
Code cleanup

Modified:
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/ant/AbstractTask.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/AbstractProductDerivation.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/BooleanValue.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/BootstrapException.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ConfigurationImpl.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configurations.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/DoubleValue.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/FileValue.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/IntValue.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ObjectValue.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/PluginListValue.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/PluginValue.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ProductDerivation.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ProductDerivations.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/StringListValue.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/StringValue.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/Options.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/StringDistance.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/lib/conf/TestAnchorParsing.java

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/ant/AbstractTask.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/ant/AbstractTask.java?rev=708213&r1=708212&r2=708213&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/ant/AbstractTask.java (original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/ant/AbstractTask.java Mon
Oct 27 08:07:00 2008
@@ -21,21 +21,20 @@
 import java.io.File;
 import java.security.AccessController;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 
-import org.apache.tools.ant.AntClassLoader;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.DirectoryScanner;
-import org.apache.tools.ant.taskdefs.MatchingTask;
-import org.apache.tools.ant.types.FileSet;
-import org.apache.tools.ant.types.Path;
 import org.apache.openjpa.lib.conf.Configuration;
 import org.apache.openjpa.lib.conf.ConfigurationImpl;
 import org.apache.openjpa.lib.conf.ConfigurationProvider;
 import org.apache.openjpa.lib.conf.ProductDerivations;
 import org.apache.openjpa.lib.util.J2DoPrivHelper;
 import org.apache.openjpa.lib.util.Localizer;
+import org.apache.tools.ant.AntClassLoader;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.taskdefs.MatchingTask;
+import org.apache.tools.ant.types.FileSet;
+import org.apache.tools.ant.types.Path;
 
 /**
  * Ant tasks all have a nested <code>&lt;config&rt;</code> tag, which
uses

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/AbstractProductDerivation.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/AbstractProductDerivation.java?rev=708213&r1=708212&r2=708213&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/AbstractProductDerivation.java
(original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/AbstractProductDerivation.java
Mon Oct 27 08:07:00 2008
@@ -19,7 +19,6 @@
 package org.apache.openjpa.lib.conf;
 
 import java.io.File;
-import java.io.IOException;
 import java.util.List;
 
 /**
@@ -64,11 +63,11 @@
         return null;
     }
 
-    public List getAnchorsInFile(File file) throws Exception {
+    public List<String> getAnchorsInFile(File file) throws Exception {
         return null;
     }
 
-    public List getAnchorsInResource(String resource) throws Exception {
+    public List<String> getAnchorsInResource(String resource) throws Exception {
         return null;
     }
 

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/BooleanValue.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/BooleanValue.java?rev=708213&r1=708212&r2=708213&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/BooleanValue.java
(original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/BooleanValue.java
Mon Oct 27 08:07:00 2008
@@ -32,7 +32,7 @@
         setAliasListComprehensive(true);
     }
 
-    public Class getValueType() {
+    public Class<Boolean> getValueType() {
         return boolean.class;
     }
 

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/BootstrapException.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/BootstrapException.java?rev=708213&r1=708212&r2=708213&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/BootstrapException.java
(original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/BootstrapException.java
Mon Oct 27 08:07:00 2008
@@ -25,8 +25,8 @@
  *
  */
 public class BootstrapException extends RuntimeException {
-
-	private boolean _fatal = false;
+    private static final long serialVersionUID = -105657052724608083L;
+    private boolean _fatal = false;
 	
 	public BootstrapException() {
 		super();

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ConfigurationImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ConfigurationImpl.java?rev=708213&r1=708212&r2=708213&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ConfigurationImpl.java
(original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ConfigurationImpl.java
Mon Oct 27 08:07:00 2008
@@ -115,7 +115,7 @@
     private Map _props = null;
     private boolean _globals = false;
     private String _auto = null;
-    private final List _vals = new ArrayList();
+    private final List<Value> _vals = new ArrayList<Value>();
 
     // property listener helper
     private PropertyChangeSupport _changeSupport = null;
@@ -248,9 +248,7 @@
 
         // search backwards so that custom values added after construction
         // are found quickly, since this will be the std way of accessing them
-        Value val;
-        for (int i = _vals.size() - 1; i >= 0; i--) {
-            val = (Value) _vals.get(i);
+        for(Value val : _vals) { 
             if (val.getProperty().equals(property))
                 return val;
         }
@@ -266,12 +264,10 @@
     public void instantiateAll() {
         StringWriter errs = null;
         PrintWriter stack = null;
-        Value val;
         String getterName;
         Method getter;
         Object getterTarget;
-        for (int i = 0; i < _vals.size(); i++) {
-            val = (Value) _vals.get(i);
+        for(Value val : _vals) { 
             getterName = val.getInstantiatingGetter();
             if (getterName == null)
                 continue;
@@ -347,17 +343,17 @@
         preClose();
         
         ObjectValue val;
-        for (int i = 0; i < _vals.size(); i++) {
-            if (_vals.get(i) instanceof Closeable) {
-                try { ((Closeable) _vals.get(i)).close(); }
+        for(Value v : _vals) { 
+            if (v instanceof Closeable) {
+                try { ((Closeable)v).close(); }
                 catch (Exception e) {} 
                 continue;
             }
 
-            if (!(_vals.get(i) instanceof ObjectValue))
+            if (!(v  instanceof ObjectValue))
                 continue;
 
-            val = (ObjectValue) _vals.get(i);
+            val = (ObjectValue) v;
             if (val.get() instanceof Closeable) {
                 try {
                     ((Closeable) val.get()).close();
@@ -410,7 +406,7 @@
             return _mds;
 
         PropertyDescriptor[] pds = getPropertyDescriptors();
-        List descs = new ArrayList(); 
+        List<MethodDescriptor> descs = new ArrayList<MethodDescriptor>(); 
         for (int i = 0; i < pds.length; i++) {
             Method write = pds[i].getWriteMethod();
             Method read = pds[i].getReadMethod();
@@ -429,7 +425,8 @@
             return _pds;
 
         _pds = new PropertyDescriptor[_vals.size()];
-        List failures = null;
+        
+        List<String> failures = null;
         Value val;
         for (int i = 0; i < _vals.size(); i++) {
             val = (Value) _vals.get(i);
@@ -437,11 +434,11 @@
                 _pds[i] = getPropertyDescriptor(val);
             } catch (MissingResourceException mre) {
                 if (failures == null)
-                    failures = new ArrayList();
+                    failures = new ArrayList<String>();
                 failures.add(val.getProperty());
             } catch (IntrospectionException ie) {
                 if (failures == null)
-                    failures = new ArrayList();
+                    failures = new ArrayList<String>();
                 failures.add(val.getProperty());
             }
         }
@@ -506,8 +503,8 @@
 
         // collect allowed values from alias keys, listed values, and
         // interface implementors
-        Collection allowed = new TreeSet();
-        List aliases = Collections.EMPTY_LIST;
+        Collection<String> allowed = new TreeSet<String>();
+        List<String> aliases = Collections.emptyList();
         if (val.getAliases() != null) {
             aliases = Arrays.asList(val.getAliases());
             for (int i = 0; i < aliases.size(); i += 2)
@@ -519,7 +516,7 @@
             if (!aliases.contains(vals[i]))
                 allowed.add(vals[i]);
         try {
-            Class intf = Class.forName(findLocalized(prop
+            Class<?> intf = Class.forName(findLocalized(prop
                 + "-interface", true, val.getScope()), false,
                 getClass().getClassLoader());
             pd.setValue(ATTRIBUTE_INTERFACE, intf.getName());
@@ -539,7 +536,8 @@
     /**
      * Find the given localized string, or return null if not found.
      */
-    private String findLocalized(String key, boolean fatal, Class scope) {
+    @SuppressWarnings("unchecked")
+    private String findLocalized(String key, boolean fatal, Class<?> scope) {
         // find the localizer package that contains this key
         Localizer loc = null;
 
@@ -586,12 +584,10 @@
         // if no existing properties or the properties should contain entries
         // with default values, add values to properties
         if (_props == null || storeDefaults) {
-            Value val;
             String str;
-            for (int i = 0; i < _vals.size(); i++) {
+            for(Value val : _vals) { 
                 // if key in existing properties, we already know value is up
                 // to date
-                val = (Value) _vals.get(i);
                 if (_props != null && Configurations.containsProperty
                     (val.getProperty(), _props))
                     continue;
@@ -632,10 +628,8 @@
 
         Map remaining = new HashMap(map);
         boolean ser = true;
-        Value val;
         Object o;
-        for (int i = 0; i < _vals.size(); i++) {
-            val = (Value) _vals.get(i);
+        for(Value val : _vals) {
             o = get(map, val, true);
             if (o == null)
                 continue;
@@ -719,12 +713,13 @@
     /**
      * Return a comprehensive list of recognized map keys.
      */
-    private Collection newPropertyList() {
+    // TODO MDD checkme
+    private Collection<String> newPropertyList() {
         String[] prefixes = ProductDerivations.getConfigurationPrefixes();
-        List l = new ArrayList(_vals.size() * prefixes.length);
-        for (int i = 0; i < _vals.size(); i++) {
+        List<String> l = new ArrayList<String>(_vals.size() * prefixes.length);
+        for(Value v : _vals) { 
             for (int j = 0; j < prefixes.length; j++)
-                l.add(prefixes[j] + "." + ((Value) _vals.get(i)).getProperty());
+                l.add(prefixes[j] + "." + v.getProperty());
         }
         return l;
     }
@@ -804,9 +799,7 @@
         ConfigurationImpl conf = (ConfigurationImpl) other;
         if (_vals.size() != conf.getValues().length)
         	return false;
-        Iterator values = _vals.iterator();
-        while (values.hasNext()) {
-        	Value v = (Value)values.next();
+        for(Value v : _vals) { 
         	Value thatV = conf.getValue(v.getProperty());
         	if (!v.equals(thatV)) {
         		return false;
@@ -821,10 +814,8 @@
      * {@link Value#isDynamic() dynamic}.  
      */
     public int hashCode() {
-        Iterator values = _vals.iterator();
         int hash = 0;
-        while (values.hasNext()) {
-        	Value v = (Value)values.next();
+        for(Value v : _vals) { 
         	hash += v.hashCode();
         }
         return hash;
@@ -871,6 +862,7 @@
      * Implementation of the {@link Externalizable} interface to read from
      * the properties written by {@link #writeExternal}.
      */
+    @SuppressWarnings("unchecked")
     public void readExternal(ObjectInput in)
         throws IOException, ClassNotFoundException {
         fromProperties((Map) in.readObject());

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configurations.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configurations.java?rev=708213&r1=708212&r2=708213&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configurations.java
(original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configurations.java
Mon Oct 27 08:07:00 2008
@@ -21,7 +21,6 @@
 import java.io.File;
 import java.security.AccessController;
 import java.security.PrivilegedActionException;
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Iterator;
@@ -30,6 +29,8 @@
 import java.util.MissingResourceException;
 import java.util.Properties;
 import java.util.TreeSet;
+import java.util.concurrent.ConcurrentHashMap;
+
 import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
@@ -39,11 +40,12 @@
 import org.apache.openjpa.lib.log.Log;
 import org.apache.openjpa.lib.util.J2DoPrivHelper;
 import org.apache.openjpa.lib.util.Localizer;
+import org.apache.openjpa.lib.util.MultiClassLoader;
 import org.apache.openjpa.lib.util.Options;
 import org.apache.openjpa.lib.util.ParseException;
 import org.apache.openjpa.lib.util.StringDistance;
-import java.util.concurrent.ConcurrentHashMap;
 import org.apache.openjpa.lib.util.concurrent.ConcurrentReferenceHashMap;
+
 import serp.util.Strings;
 
 /**
@@ -293,7 +295,7 @@
      *
      * @since 1.1.0
      */
-    public static List getFullyQualifiedAnchorsInPropertiesLocation(
+    public static List<String> getFullyQualifiedAnchorsInPropertiesLocation(
         Options opts) {
         String props = opts.getProperty("properties", "p", null);
         if (props != null) {
@@ -386,12 +388,12 @@
             msg = "invalid-plugin-aliases";
             params = new Object[]{
                 val.getProperty(), alias, e.toString(),
-                new TreeSet(Arrays.asList(keys)), };
+                new TreeSet<String>(Arrays.asList(keys)), };
         } else {
             msg = "invalid-plugin-aliases-hint";
             params = new Object[]{
                 val.getProperty(), alias, e.toString(),
-                new TreeSet(Arrays.asList(keys)), closest, };
+                new TreeSet<String>(Arrays.asList(keys)), closest, };
         }
         return new ParseException(_loc.get(msg, params), e);
     }
@@ -484,7 +486,7 @@
 				first.indexOf('.') == -1) {
 				// if there's just one misspelling and this is not a
 				// path traversal, check for near misses.
-				Collection options = findOptionsFor(obj.getClass());
+				Collection<String> options = findOptionsFor(obj.getClass());
 				String close = StringDistance.getClosestLevenshteinDistance
 					(first, options, 0.75f);
 				if (close != null)
@@ -505,8 +507,8 @@
             configurable.endConfiguration();
     }
 
-    private static Collection findOptionsFor(Class cls) {
-        Collection c = Options.findOptionsFor(cls);
+    private static Collection<String> findOptionsFor(Class<?> cls) {
+        Collection<String> c = Options.findOptionsFor(cls);
         
         // remove Configurable.setConfiguration() and 
         // GenericConfigurable.setInto() from the set, if applicable.
@@ -679,7 +681,7 @@
         if (opts.containsKey("help") || opts.containsKey("-help")) {
             return false;
         }
-        List anchors =
+        List<String> anchors =
             Configurations.getFullyQualifiedAnchorsInPropertiesLocation(opts);
 
         // We use 'properties' below; get rid of 'p' to avoid conflicts. This
@@ -692,9 +694,9 @@
         if (anchors.size() == 0) {
             ret = launchRunnable(opts, runnable);
         } else {
-            for (Iterator iter = anchors.iterator(); iter.hasNext(); ) { 
+            for(String s : anchors ) { 
                 Options clonedOptions = (Options) opts.clone();
-                clonedOptions.setProperty("properties", iter.next().toString());
+                clonedOptions.setProperty("properties", s);
                 ret &= launchRunnable(clonedOptions, runnable);
             }
         }

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/DoubleValue.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/DoubleValue.java?rev=708213&r1=708212&r2=708213&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/DoubleValue.java (original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/DoubleValue.java Mon
Oct 27 08:07:00 2008
@@ -33,7 +33,7 @@
         super(prop);
     }
 
-    public Class getValueType() {
+    public Class<Double> getValueType() {
         return double.class;
     }
 

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/FileValue.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/FileValue.java?rev=708213&r1=708212&r2=708213&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/FileValue.java (original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/FileValue.java Mon
Oct 27 08:07:00 2008
@@ -37,7 +37,7 @@
         super(prop);
     }
 
-    public Class getValueType() {
+    public Class<File> getValueType() {
         return File.class;
     }
 

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/IntValue.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/IntValue.java?rev=708213&r1=708212&r2=708213&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/IntValue.java (original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/IntValue.java Mon
Oct 27 08:07:00 2008
@@ -33,7 +33,7 @@
         super(prop);
     }
 
-    public Class getValueType() {
+    public Class<Integer> getValueType() {
         return int.class;
     }
 

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ObjectValue.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ObjectValue.java?rev=708213&r1=708212&r2=708213&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ObjectValue.java (original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ObjectValue.java Mon
Oct 27 08:07:00 2008
@@ -79,14 +79,14 @@
      * Instantiate the object as an instance of the given class. Equivalent
      * to <code>instantiate(type, conf, true)</code>.
      */
-    public Object instantiate(Class type, Configuration conf) {
+    public Object instantiate(Class<?> type, Configuration conf) {
         return instantiate(type, conf, true);
     }
 
     /**
      * Instantiate the object as an instance of the given class.
      */
-    public Object instantiate(Class type, Configuration conf, boolean fatal) {
+    public Object instantiate(Class<?> type, Configuration conf, boolean fatal) {
         throw new UnsupportedOperationException();
     }
 
@@ -94,7 +94,7 @@
      * Allow subclasses to instantiate additional plugins. This method does
      * not perform configuration.
      */
-    public Object newInstance(String clsName, Class type, Configuration conf,
+    public Object newInstance(String clsName, Class<?> type, Configuration conf,
             boolean fatal) {
         ClassLoader cl = (ClassLoader) _classloaderCache.get(type);
         if (cl == null) {
@@ -109,7 +109,7 @@
         return Configurations.newInstance(clsName, this, conf, cl, fatal);
     }
 
-    public Class getValueType() {
+    public Class<?> getValueType() {
         return Object.class;
     }
 

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/PluginListValue.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/PluginListValue.java?rev=708213&r1=708212&r2=708213&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/PluginListValue.java
(original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/PluginListValue.java
Mon Oct 27 08:07:00 2008
@@ -81,7 +81,7 @@
     /**
      * Instantiate the plugins as instances of the given class.
      */
-    public Object instantiate(Class elemType, Configuration conf,
+    public Object instantiate(Class<?> elemType, Configuration conf,
         boolean fatal) {
         Object[] ret;
         if (_names.length == 0)
@@ -135,7 +135,7 @@
 
         // split up the string; each element might be a class name, or a
         // class name with properties settings
-        List plugins = new ArrayList();
+        List<String> plugins = new ArrayList<String>();
         StringBuffer plugin = new StringBuffer();
         boolean inParen = false;
         char c;
@@ -166,24 +166,23 @@
             plugins.add(plugin.toString());
 
         // parse each plugin element into its name and properties
-        List names = new ArrayList();
-        List props = new ArrayList();
+        List<String> names = new ArrayList<String>();
+        List<String> props = new ArrayList<String>();
         String clsName;
-        for (int i = 0; i < plugins.size(); i++) {
-            str = (String) plugins.get(i);
-            clsName = unalias(Configurations.getClassName(str));
+        for(String s : plugins) { 
+            clsName = unalias(Configurations.getClassName(s));
             if (clsName != null) {
                 names.add(clsName);
-                props.add(Configurations.getProperties(str));
+                props.add(Configurations.getProperties(s));
             }
         }
-        _names = (String[]) names.toArray(new String[names.size()]);
-        _props = (String[]) props.toArray(new String[props.size()]);
+        _names =  names.toArray(new String[names.size()]);
+        _props = props.toArray(new String[props.size()]);
         set(null, true);
         valueChanged();
     }
 
-    public Class getValueType() {
+    public Class<Object []> getValueType() {
         return Object[].class;
     }
 

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/PluginValue.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/PluginValue.java?rev=708213&r1=708212&r2=708213&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/PluginValue.java (original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/PluginValue.java Mon
Oct 27 08:07:00 2008
@@ -98,7 +98,7 @@
     /**
      * Instantiate the plugin as an instance of the given class.
      */
-    public Object instantiate(Class type, Configuration conf, boolean fatal) {
+    public Object instantiate(Class<?> type, Configuration conf, boolean fatal) {
         Object obj = newInstance(_name, type, conf, fatal);
         Configurations.configureInstance(obj, conf, _props,
             (fatal) ? getProperty() : null);
@@ -128,7 +128,7 @@
         valueChanged();
     }
 
-    public Class getValueType() {
+    public Class<Object> getValueType() {
         return Object.class;
     }
 

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ProductDerivation.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ProductDerivation.java?rev=708213&r1=708212&r2=708213&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ProductDerivation.java
(original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ProductDerivation.java
Mon Oct 27 08:07:00 2008
@@ -112,7 +112,7 @@
      *
      * @since 1.1.0
      */
-    public List getAnchorsInFile(File file) throws IOException, Exception;
+    public List<String> getAnchorsInFile(File file) throws IOException, Exception;
 
     /**
      * Return a List<String> of all the anchors defined in
@@ -124,7 +124,7 @@
      *
      * @since 1.1.0
      */
-    public List getAnchorsInResource(String resource) throws Exception;
+    public List<String> getAnchorsInResource(String resource) throws Exception;
     
     /**
      * Provides the instance with a callback to mutate the initial properties

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ProductDerivations.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ProductDerivations.java?rev=708213&r1=708212&r2=708213&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ProductDerivations.java
(original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ProductDerivations.java
Mon Oct 27 08:07:00 2008
@@ -56,7 +56,8 @@
             J2DoPrivHelper.getClassLoaderAction(ProductDerivation.class)); 
         _derivationNames = Services.getImplementors(ProductDerivation.class, l);
         _derivationErrors = new Throwable[_derivationNames.length];
-        List derivations = new ArrayList(_derivationNames.length);
+        List<ProductDerivation> derivations =
+            new ArrayList<ProductDerivation>(_derivationNames.length);
         for (int i = 0; i < _derivationNames.length; i++) {
             try {
                 ProductDerivation d = (ProductDerivation)
@@ -91,10 +92,10 @@
         }
 
         Collections.sort(derivations, new ProductDerivationComparator());
-        _derivations = (ProductDerivation[]) derivations.toArray
-            (new ProductDerivation[derivations.size()]);
+        _derivations =
+            derivations.toArray(new ProductDerivation[derivations.size()]);
 
-        List prefixes = new ArrayList(2);
+        List<String> prefixes = new ArrayList<String>(2);
         for (int i = 0; i < _derivations.length; i++) {
             if (_derivations[i].getConfigurationPrefix() != null
                 && !"openjpa".equals(_derivations[i].getConfigurationPrefix()))
@@ -376,9 +377,9 @@
      *
      * @since 1.1.0
      */
-    public static List getFullyQualifiedAnchorsInPropertiesLocation(
+    public static List<String> getFullyQualifiedAnchorsInPropertiesLocation(
         final String propertiesLocation) {
-        List fqAnchors = new ArrayList();
+        List<String> fqAnchors = new ArrayList<String>();
         StringBuffer errs = null;
         Throwable err = null;
         for (int i = _derivations.length - 1; i >= 0; i--) {
@@ -433,11 +434,11 @@
      * Compare {@link ProductDerivation}s.
      */
     private static class ProductDerivationComparator
-        implements Comparator {
+        implements Comparator<ProductDerivation> {
 
-        public int compare(Object o1, Object o2) {
-            int type1 = ((ProductDerivation) o1).getType();
-            int type2 = ((ProductDerivation) o2).getType();
+        public int compare(ProductDerivation o1, ProductDerivation o2) {
+            int type1 = o1.getType();
+            int type2 = o2.getType();
             if (type1 != type2)
                 return type1 - type2;
 

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/StringListValue.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/StringListValue.java?rev=708213&r1=708212&r2=708213&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/StringListValue.java
(original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/StringListValue.java
Mon Oct 27 08:07:00 2008
@@ -60,7 +60,7 @@
         return _values;
     }
 
-    public Class getValueType() {
+    public Class<String []> getValueType() {
         return String[].class;
     }
     
@@ -137,7 +137,7 @@
         set((String[]) obj);
     }
     
-    protected List getAliasList() {
+    protected List<String> getAliasList() {
         return Arrays.asList(getAliases());
     }
     

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/StringValue.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/StringValue.java?rev=708213&r1=708212&r2=708213&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/StringValue.java (original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/StringValue.java Mon
Oct 27 08:07:00 2008
@@ -33,7 +33,7 @@
         super(prop);
     }
 
-    public Class getValueType() {
+    public Class<String> getValueType() {
         return String.class;
     }
 

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/Options.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/Options.java?rev=708213&r1=708212&r2=708213&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/Options.java (original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/Options.java Mon Oct
27 08:07:00 2008
@@ -256,11 +256,11 @@
      * @return The available option names in <code>type</code>. The
      * names will have initial caps. They will be ordered alphabetically.
      */
-    public static Collection findOptionsFor(Class type) {
-        Collection names = new TreeSet();
+    public static Collection<String> findOptionsFor(Class<?> type) {
+        Collection<String> names = new TreeSet<String>();
         // look for a setter method matching the key
         Method[] meths = type.getMethods();
-        Class[] params;
+        Class<?>[] params;
         for (int i = 0; i < meths.length; i++) {
             if (meths[i].getName().startsWith("set")) {
                 params = meths[i].getParameterTypes();

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/StringDistance.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/StringDistance.java?rev=708213&r1=708212&r2=708213&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/StringDistance.java
(original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/StringDistance.java
Mon Oct 27 08:07:00 2008
@@ -114,15 +114,14 @@
      * @see #getLevenshteinDistance
      */
     public static String getClosestLevenshteinDistance(String str,
-        Collection candidates, int threshold) {
+        Collection<String> candidates, int threshold) {
         if (candidates == null || candidates.isEmpty())
             return null;
 
         String minString = null;
         int minValue = Integer.MAX_VALUE;
 
-        for (Iterator i = candidates.iterator(); i.hasNext();) {
-            String candidate = (String) i.next();
+        for(String candidate : candidates) { 
             int distance = getLevenshteinDistance(str, candidate);
             if (distance < minValue) {
                 minValue = distance;

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/lib/conf/TestAnchorParsing.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/lib/conf/TestAnchorParsing.java?rev=708213&r1=708212&r2=708213&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/lib/conf/TestAnchorParsing.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/lib/conf/TestAnchorParsing.java
Mon Oct 27 08:07:00 2008
@@ -35,7 +35,7 @@
         String fqLoc = "META-INF/persistence.xml#test";
         Options opts = new Options();
         opts.setProperty("p", fqLoc);
-        List locs =
+        List<String> locs =
             Configurations.getFullyQualifiedAnchorsInPropertiesLocation(opts);
         assertNotNull(locs);
         assertEquals(1, locs.size());
@@ -54,7 +54,7 @@
         Options opts = new Options();
         if (resource != null)
             opts.setProperty("p", resource);
-        List locs =
+        List<String> locs =
             Configurations.getFullyQualifiedAnchorsInPropertiesLocation(opts);
         assertNotNull(locs);
         // approximate so that if someone adds more units, this doesn't break



Mime
View raw message