mirror of https://github.com/apache/openjpa.git
Code cleanup
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@708213 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e1bd3c4dcb
commit
b9476a8ae8
|
@ -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 <code><config&rt;</code> tag, which uses
|
||||
|
|
|
@ -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<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;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ public class BooleanValue extends Value {
|
|||
setAliasListComprehensive(true);
|
||||
}
|
||||
|
||||
public Class getValueType() {
|
||||
public Class<Boolean> getValueType() {
|
||||
return boolean.class;
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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<Value> _vals = new ArrayList<Value>();
|
||||
|
||||
// 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<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 @@ public class ConfigurationImpl
|
|||
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 @@ public class ConfigurationImpl
|
|||
_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 @@ public class ConfigurationImpl
|
|||
|
||||
// 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 @@ 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<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 @@ 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());
|
||||
|
|
|
@ -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<String> 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<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 @@ 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<String> 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<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 @@ public class Configurations {
|
|||
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 @@ 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ public class DoubleValue extends Value {
|
|||
super(prop);
|
||||
}
|
||||
|
||||
public Class getValueType() {
|
||||
public Class<Double> getValueType() {
|
||||
return double.class;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ public class FileValue extends Value {
|
|||
super(prop);
|
||||
}
|
||||
|
||||
public Class getValueType() {
|
||||
public Class<File> getValueType() {
|
||||
return File.class;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ public class IntValue extends Value {
|
|||
super(prop);
|
||||
}
|
||||
|
||||
public Class getValueType() {
|
||||
public Class<Integer> getValueType() {
|
||||
return int.class;
|
||||
}
|
||||
|
||||
|
|
|
@ -79,14 +79,14 @@ public class ObjectValue extends Value {
|
|||
* 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 @@ 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<String> plugins = new ArrayList<String>();
|
||||
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<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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Object> getValueType() {
|
||||
return Object.class;
|
||||
}
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ public interface ProductDerivation {
|
|||
*
|
||||
* @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 @@ public interface ProductDerivation {
|
|||
*
|
||||
* @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
|
||||
|
|
|
@ -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<ProductDerivation> derivations =
|
||||
new ArrayList<ProductDerivation>(_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<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 @@ public class ProductDerivations {
|
|||
*
|
||||
* @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 @@ public class ProductDerivations {
|
|||
* 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;
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ public class StringListValue extends Value {
|
|||
return _values;
|
||||
}
|
||||
|
||||
public Class getValueType() {
|
||||
public Class<String []> getValueType() {
|
||||
return String[].class;
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ public class StringListValue extends Value {
|
|||
set((String[]) obj);
|
||||
}
|
||||
|
||||
protected List getAliasList() {
|
||||
protected List<String> getAliasList() {
|
||||
return Arrays.asList(getAliases());
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ public class StringValue extends Value {
|
|||
super(prop);
|
||||
}
|
||||
|
||||
public Class getValueType() {
|
||||
public Class<String> getValueType() {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
|
|
|
@ -256,11 +256,11 @@ public class Options extends TypedProperties {
|
|||
* @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();
|
||||
|
|
|
@ -114,15 +114,14 @@ public class StringDistance {
|
|||
* @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;
|
||||
|
|
|
@ -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<String> 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<String> locs =
|
||||
Configurations.getFullyQualifiedAnchorsInPropertiesLocation(opts);
|
||||
assertNotNull(locs);
|
||||
// approximate so that if someone adds more units, this doesn't break
|
||||
|
|
Loading…
Reference in New Issue