diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/ant/AbstractTask.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/ant/AbstractTask.java index f34cb2b95..5c15eca53 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/ant/AbstractTask.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/ant/AbstractTask.java @@ -21,21 +21,20 @@ package org.apache.openjpa.lib.ant; 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 <config&rt; tag, which uses diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/AbstractProductDerivation.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/AbstractProductDerivation.java index 4700dbe2d..db67224c2 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/AbstractProductDerivation.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/AbstractProductDerivation.java @@ -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 @@ public abstract class AbstractProductDerivation return null; } - public List getAnchorsInFile(File file) throws Exception { + public List getAnchorsInFile(File file) throws Exception { return null; } - public List getAnchorsInResource(String resource) throws Exception { + public List getAnchorsInResource(String resource) throws Exception { return null; } diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/BooleanValue.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/BooleanValue.java index d9e4076cb..a2904803b 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/BooleanValue.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/BooleanValue.java @@ -32,7 +32,7 @@ public class BooleanValue extends Value { setAliasListComprehensive(true); } - public Class getValueType() { + public Class getValueType() { return boolean.class; } diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/BootstrapException.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/BootstrapException.java index b58b0cf2c..7240a6d5c 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/BootstrapException.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/BootstrapException.java @@ -25,8 +25,8 @@ package org.apache.openjpa.lib.conf; * */ public class BootstrapException extends RuntimeException { - - private boolean _fatal = false; + private static final long serialVersionUID = -105657052724608083L; + private boolean _fatal = false; public BootstrapException() { super(); diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ConfigurationImpl.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ConfigurationImpl.java index f987ab8cb..1688e6a8a 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ConfigurationImpl.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ConfigurationImpl.java @@ -115,7 +115,7 @@ public class ConfigurationImpl private Map _props = null; private boolean _globals = false; private String _auto = null; - private final List _vals = new ArrayList(); + private final List _vals = new ArrayList(); // property listener helper private PropertyChangeSupport _changeSupport = null; @@ -248,9 +248,7 @@ public class ConfigurationImpl // 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 class ConfigurationImpl 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 @@ public class ConfigurationImpl 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 @@ public class ConfigurationImpl return _mds; PropertyDescriptor[] pds = getPropertyDescriptors(); - List descs = new ArrayList(); + List descs = new ArrayList(); for (int i = 0; i < pds.length; i++) { Method write = pds[i].getWriteMethod(); Method read = pds[i].getReadMethod(); @@ -429,7 +425,8 @@ public class ConfigurationImpl return _pds; _pds = new PropertyDescriptor[_vals.size()]; - List failures = null; + + List failures = null; Value val; for (int i = 0; i < _vals.size(); i++) { val = (Value) _vals.get(i); @@ -437,11 +434,11 @@ public class ConfigurationImpl _pds[i] = getPropertyDescriptor(val); } catch (MissingResourceException mre) { if (failures == null) - failures = new ArrayList(); + failures = new ArrayList(); failures.add(val.getProperty()); } catch (IntrospectionException ie) { if (failures == null) - failures = new ArrayList(); + failures = new ArrayList(); failures.add(val.getProperty()); } } @@ -506,8 +503,8 @@ public class ConfigurationImpl // collect allowed values from alias keys, listed values, and // interface implementors - Collection allowed = new TreeSet(); - List aliases = Collections.EMPTY_LIST; + Collection allowed = new TreeSet(); + List 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 @@ public class ConfigurationImpl 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 @@ public class ConfigurationImpl /** * 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 @@ public class ConfigurationImpl // 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 @@ public class ConfigurationImpl 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 @@ public class ConfigurationImpl /** * Return a comprehensive list of recognized map keys. */ - private Collection newPropertyList() { + // TODO MDD checkme + private Collection newPropertyList() { String[] prefixes = ProductDerivations.getConfigurationPrefixes(); - List l = new ArrayList(_vals.size() * prefixes.length); - for (int i = 0; i < _vals.size(); i++) { + List l = new ArrayList(_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 @@ public class ConfigurationImpl 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 @@ public class ConfigurationImpl * {@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 @@ public class ConfigurationImpl * 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()); diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configurations.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configurations.java index 2732fcb72..41a2865c3 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configurations.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configurations.java @@ -21,7 +21,6 @@ package org.apache.openjpa.lib.conf; 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.Map; 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.commons.lang.exception.NestableRuntimeException; 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 @@ public class Configurations { * * @since 1.1.0 */ - public static List getFullyQualifiedAnchorsInPropertiesLocation( + public static List getFullyQualifiedAnchorsInPropertiesLocation( Options opts) { String props = opts.getProperty("properties", "p", null); if (props != null) { @@ -386,12 +388,12 @@ public class Configurations { msg = "invalid-plugin-aliases"; params = new Object[]{ val.getProperty(), alias, e.toString(), - new TreeSet(Arrays.asList(keys)), }; + new TreeSet(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(Arrays.asList(keys)), closest, }; } return new ParseException(_loc.get(msg, params), e); } @@ -484,7 +486,7 @@ public class Configurations { 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 options = findOptionsFor(obj.getClass()); String close = StringDistance.getClosestLevenshteinDistance (first, options, 0.75f); if (close != null) @@ -505,8 +507,8 @@ public class Configurations { configurable.endConfiguration(); } - private static Collection findOptionsFor(Class cls) { - Collection c = Options.findOptionsFor(cls); + private static Collection findOptionsFor(Class cls) { + Collection c = Options.findOptionsFor(cls); // remove Configurable.setConfiguration() and // GenericConfigurable.setInto() from the set, if applicable. @@ -679,7 +681,7 @@ public class Configurations { if (opts.containsKey("help") || opts.containsKey("-help")) { return false; } - List anchors = + List anchors = Configurations.getFullyQualifiedAnchorsInPropertiesLocation(opts); // We use 'properties' below; get rid of 'p' to avoid conflicts. This @@ -692,9 +694,9 @@ public class Configurations { 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); } } diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/DoubleValue.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/DoubleValue.java index 34e4c7711..a28399954 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/DoubleValue.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/DoubleValue.java @@ -33,7 +33,7 @@ public class DoubleValue extends Value { super(prop); } - public Class getValueType() { + public Class getValueType() { return double.class; } diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/FileValue.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/FileValue.java index 27f906f36..96bf7491e 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/FileValue.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/FileValue.java @@ -37,7 +37,7 @@ public class FileValue extends Value { super(prop); } - public Class getValueType() { + public Class getValueType() { return File.class; } diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/IntValue.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/IntValue.java index 0ea17b95e..1bfb28ed2 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/IntValue.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/IntValue.java @@ -33,7 +33,7 @@ public class IntValue extends Value { super(prop); } - public Class getValueType() { + public Class getValueType() { return int.class; } diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ObjectValue.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ObjectValue.java index bbe842f79..83ef7541b 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ObjectValue.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ObjectValue.java @@ -79,14 +79,14 @@ public class ObjectValue extends Value { * Instantiate the object as an instance of the given class. Equivalent * to instantiate(type, conf, true). */ - 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 @@ public class ObjectValue extends Value { * 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 @@ public class ObjectValue extends Value { return Configurations.newInstance(clsName, this, conf, cl, fatal); } - public Class getValueType() { + public Class getValueType() { return Object.class; } diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/PluginListValue.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/PluginListValue.java index 915e9986f..b73dc53fe 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/PluginListValue.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/PluginListValue.java @@ -81,7 +81,7 @@ public class PluginListValue extends ObjectValue { /** * 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 @@ public class PluginListValue extends ObjectValue { // split up the string; each element might be a class name, or a // class name with properties settings - List plugins = new ArrayList(); + List plugins = new ArrayList(); StringBuffer plugin = new StringBuffer(); boolean inParen = false; char c; @@ -166,24 +166,23 @@ public class PluginListValue extends ObjectValue { plugins.add(plugin.toString()); // parse each plugin element into its name and properties - List names = new ArrayList(); - List props = new ArrayList(); + List names = new ArrayList(); + List props = new ArrayList(); 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 getValueType() { return Object[].class; } diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/PluginValue.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/PluginValue.java index e9dd08fda..7c944ba68 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/PluginValue.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/PluginValue.java @@ -98,7 +98,7 @@ public class PluginValue extends ObjectValue { /** * 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 @@ public class PluginValue extends ObjectValue { valueChanged(); } - public Class getValueType() { + public Class getValueType() { return Object.class; } diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ProductDerivation.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ProductDerivation.java index 92ad60fba..f811cad53 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ProductDerivation.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ProductDerivation.java @@ -112,7 +112,7 @@ public interface ProductDerivation { * * @since 1.1.0 */ - public List getAnchorsInFile(File file) throws IOException, Exception; + public List getAnchorsInFile(File file) throws IOException, Exception; /** * Return a List of all the anchors defined in @@ -124,7 +124,7 @@ public interface ProductDerivation { * * @since 1.1.0 */ - public List getAnchorsInResource(String resource) throws Exception; + public List getAnchorsInResource(String resource) throws Exception; /** * Provides the instance with a callback to mutate the initial properties diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ProductDerivations.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ProductDerivations.java index ee219415f..3c9b46f16 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ProductDerivations.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ProductDerivations.java @@ -56,7 +56,8 @@ public class ProductDerivations { J2DoPrivHelper.getClassLoaderAction(ProductDerivation.class)); _derivationNames = Services.getImplementors(ProductDerivation.class, l); _derivationErrors = new Throwable[_derivationNames.length]; - List derivations = new ArrayList(_derivationNames.length); + List derivations = + new ArrayList(_derivationNames.length); for (int i = 0; i < _derivationNames.length; i++) { try { ProductDerivation d = (ProductDerivation) @@ -91,10 +92,10 @@ public class ProductDerivations { } 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 prefixes = new ArrayList(2); for (int i = 0; i < _derivations.length; i++) { if (_derivations[i].getConfigurationPrefix() != null && !"openjpa".equals(_derivations[i].getConfigurationPrefix())) @@ -376,9 +377,9 @@ public class ProductDerivations { * * @since 1.1.0 */ - public static List getFullyQualifiedAnchorsInPropertiesLocation( + public static List getFullyQualifiedAnchorsInPropertiesLocation( final String propertiesLocation) { - List fqAnchors = new ArrayList(); + List fqAnchors = new ArrayList(); StringBuffer errs = null; Throwable err = null; for (int i = _derivations.length - 1; i >= 0; i--) { @@ -433,11 +434,11 @@ public class ProductDerivations { * Compare {@link ProductDerivation}s. */ private static class ProductDerivationComparator - implements Comparator { + implements Comparator { - 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; diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/StringListValue.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/StringListValue.java index 4a51a12c1..d3f5365ee 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/StringListValue.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/StringListValue.java @@ -60,7 +60,7 @@ public class StringListValue extends Value { return _values; } - public Class getValueType() { + public Class getValueType() { return String[].class; } @@ -137,7 +137,7 @@ public class StringListValue extends Value { set((String[]) obj); } - protected List getAliasList() { + protected List getAliasList() { return Arrays.asList(getAliases()); } diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/StringValue.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/StringValue.java index 1331abeaf..a3e39b95d 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/StringValue.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/StringValue.java @@ -33,7 +33,7 @@ public class StringValue extends Value { super(prop); } - public Class getValueType() { + public Class getValueType() { return String.class; } diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/Options.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/Options.java index 722fbf786..c25a11cdd 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/Options.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/Options.java @@ -256,11 +256,11 @@ public class Options extends TypedProperties { * @return The available option names in type. The * names will have initial caps. They will be ordered alphabetically. */ - public static Collection findOptionsFor(Class type) { - Collection names = new TreeSet(); + public static Collection findOptionsFor(Class type) { + Collection names = new TreeSet(); // 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(); diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/StringDistance.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/StringDistance.java index 862f48420..5b5f4f97e 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/StringDistance.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/StringDistance.java @@ -114,15 +114,14 @@ public class StringDistance { * @see #getLevenshteinDistance */ public static String getClosestLevenshteinDistance(String str, - Collection candidates, int threshold) { + Collection 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; diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/lib/conf/TestAnchorParsing.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/lib/conf/TestAnchorParsing.java index 0b97ff2d8..c6c782ea0 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/lib/conf/TestAnchorParsing.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/lib/conf/TestAnchorParsing.java @@ -35,7 +35,7 @@ public class TestAnchorParsing extends TestCase { String fqLoc = "META-INF/persistence.xml#test"; Options opts = new Options(); opts.setProperty("p", fqLoc); - List locs = + List locs = Configurations.getFullyQualifiedAnchorsInPropertiesLocation(opts); assertNotNull(locs); assertEquals(1, locs.size()); @@ -54,7 +54,7 @@ public class TestAnchorParsing extends TestCase { Options opts = new Options(); if (resource != null) opts.setProperty("p", resource); - List locs = + List locs = Configurations.getFullyQualifiedAnchorsInPropertiesLocation(opts); assertNotNull(locs); // approximate so that if someone adds more units, this doesn't break