openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r1236280 - in /openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/ openjpa-kernel/src/main/java/org/apache/openjpa/datacache/ openjpa-kernel/src/main/java/org/apache/openjpa/event/ openjpa-kernel/src/main/java/org...
Date Thu, 26 Jan 2012 16:36:38 GMT
Author: ppoddar
Date: Thu Jan 26 16:36:38 2012
New Revision: 1236280

URL: http://svn.apache.org/viewvc?rev=1236280&view=rev
Log:
OPENJPA:1050: Use generics

Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/StoreCollectionFieldStrategy.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/QueryKey.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/BeanLifecycleCallbacks.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ResultPacker.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/InterfaceImplGenerator.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/JavaTypes.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ApplicationIds.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/MultiClassLoader.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/Options.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/common/utils/BufferedLogFactory.java
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/Members.java

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/StoreCollectionFieldStrategy.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/StoreCollectionFieldStrategy.java?rev=1236280&r1=1236279&r2=1236280&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/StoreCollectionFieldStrategy.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/StoreCollectionFieldStrategy.java
Thu Jan 26 16:36:38 2012
@@ -131,7 +131,7 @@ public abstract class StoreCollectionFie
      * By default, assumes the structure is a collection.
      */
     protected void add(JDBCStore store, Object coll, Object obj) {
-        ((Collection) coll).add(obj);
+        ((Collection<Object>) coll).add(obj);
     }
 
     /**

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/QueryKey.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/QueryKey.java?rev=1236280&r1=1236279&r2=1236280&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/QueryKey.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/QueryKey.java
Thu Jan 26 16:36:38 2012
@@ -62,21 +62,21 @@ public class QueryKey
     // initialize the set of unmodifiable classes. This allows us
     // to avoid cloning collections that are not modifiable,
     // provided that they do not contain mutable objects.
-    private static Collection s_unmod = new HashSet();
+    private static Collection<Class<?>> s_unmod = new HashSet<Class<?>>();
 
     static {
         // handle the set types; jdk uses different classes for collection,
         // set, and sorted set
-        TreeSet s = new TreeSet();
+        TreeSet<Object> s = new TreeSet<Object>();
         s_unmod.add(Collections.unmodifiableCollection(s).getClass());
         s_unmod.add(Collections.unmodifiableSet(s).getClass());
         s_unmod.add(Collections.unmodifiableSortedSet(s).getClass());
 
         // handle the list types; jdk uses different classes for standard
         // and random access lists
-        List l = new LinkedList();
+        List<Object> l = new LinkedList<Object>();
         s_unmod.add(Collections.unmodifiableList(l).getClass());
-        l = new ArrayList(0);
+        l = new ArrayList<Object>(0);
         s_unmod.add(Collections.unmodifiableList(l).getClass());
 
         // handle the constant types
@@ -88,10 +88,10 @@ public class QueryKey
     // because they are implicit in the filter
     private String _candidateClassName;
     private boolean _subclasses;
-    private Set _accessPathClassNames;
+    private Set<String> _accessPathClassNames;
     private Object _query;
     private boolean _ignoreChanges;
-    private Map _params;
+    private Map<Object,Object> _params;
     private long _rangeStart;
     private long _rangeEnd;
 
@@ -123,7 +123,7 @@ public class QueryKey
     /**
      * Return a key for the given query, or null if it is not cacheable.
      */
-    public static QueryKey newInstance(Query q, Map args) {
+    public static QueryKey newInstance(Query q, Map<Object,Object> args) {
         // compile to make sure info encoded in query string is available
         // via API calls (candidate class, result class, etc)
         q.compile();
@@ -135,7 +135,7 @@ public class QueryKey
      * Return a key for the given query, or null if it is not cacheable.
      */
     static QueryKey newInstance(QueryContext q, boolean packed, Object[] args,
-        Class candidate, boolean subs, long startIdx, long endIdx, Object parsed) {
+        Class<?> candidate, boolean subs, long startIdx, long endIdx, Object parsed)
{
         QueryKey key = createKey(q, packed, candidate, subs, startIdx, endIdx, parsed);
         if (key != null && setParams(key, q, args))
             return key;
@@ -145,11 +145,11 @@ public class QueryKey
     /**
      * Return a key for the given query, or null if it is not cacheable.
      */
-    static QueryKey newInstance(QueryContext q, boolean packed, Map args,
-        Class candidate, boolean subs, long startIdx, long endIdx, Object parsed) {
+    static QueryKey newInstance(QueryContext q, boolean packed, Map<Object,Object>
args,
+        Class<?> candidate, boolean subs, long startIdx, long endIdx, Object parsed)
{
         QueryKey key = createKey(q, packed, candidate, subs, startIdx, endIdx, parsed);
         if (key != null && (args == null || args.isEmpty() ||
-            setParams(key, q.getStoreContext(), new HashMap(args))))
+            setParams(key, q.getStoreContext(), new HashMap<Object,Object>(args))))
             return key;
         return null;
     }
@@ -160,7 +160,7 @@ public class QueryKey
      * class, query filter, etc.
      */
     private static QueryKey createKey(QueryContext q, boolean packed,
-        Class candidateClass, boolean subclasses, long startIdx, long endIdx, Object parsed)
{
+        Class<?> candidateClass, boolean subclasses, long startIdx, long endIdx, Object
parsed) {
         if (candidateClass == null)
             return null;
 
@@ -173,7 +173,7 @@ public class QueryKey
             return null;
 
         // can't cache non-serializable non-managed complex types
-        Class[] types = q.getProjectionTypes();
+        Class<?>[] types = q.getProjectionTypes();
         for (int i = 0; i < types.length; i++) {
             switch (JavaTypes.getTypeCode(types[i])) {
                 case JavaTypes.ARRAY:
@@ -194,7 +194,7 @@ public class QueryKey
         if (metas.length == 0)
             return null;
 
-        Set accessPathClassNames = new HashSet((int) (metas.length * 1.33 + 1));
+        Set<String> accessPathClassNames = new HashSet<String>((int) (metas.length
* 1.33 + 1));
         ClassMetaData meta;
         for (int i = 0; i < metas.length; i++) {
             // since the class change framework deals with least-derived types,
@@ -267,10 +267,10 @@ public class QueryKey
         // Create a map for the given parameters, and convert the
         // parameter list into a map, using the query's parameter
         // declaration to determine ordering etc.
-        Map types = q.getOrderedParameterTypes();
-        Map map = new HashMap((int) (types.size() * 1.33 + 1));
+        Map<Object,Class<?>> types = q.getOrderedParameterTypes();
+        Map<Object,Object> map = new HashMap<Object,Object>((int) (types.size()
* 1.33 + 1));
         int idx = 0;
-        for (Iterator iter = types.keySet().iterator(); iter.hasNext(); idx++)
+        for (Iterator<Object> iter = types.keySet().iterator(); iter.hasNext(); idx++)
             map.put(iter.next(), args[idx]);
         return setParams(key, q.getStoreContext(), map);
     }
@@ -280,14 +280,12 @@ public class QueryKey
      * will be cloned.
      */
     private static boolean setParams(QueryKey key, StoreContext ctx,
-        Map params) {
+        Map<Object,Object> params) {
         if (params == null || params.isEmpty())
             return true;
 
-        Map.Entry e;
         Object v;
-        for (Iterator iter = params.entrySet().iterator(); iter.hasNext();) {
-            e = (Map.Entry) iter.next();
+        for (Map.Entry<Object,Object> e : params.entrySet()) {
             v = e.getValue();
             if (ImplHelper.isManageable(v)) {
                 if (!ctx.isPersistent(v) || ctx.isNew(v) || ctx.isDeleted(v))
@@ -296,7 +294,7 @@ public class QueryKey
             }
 
             if (v instanceof Collection) {
-                Collection c = (Collection) v;
+                Collection<Object> c = (Collection<Object>) v;
                 boolean contentsAreDates = false;
                 if (c.iterator().hasNext()) {
                     // this assumes that the collection is homogeneous
@@ -319,18 +317,18 @@ public class QueryKey
                     // clone it for good measure.
                     if (contentsAreDates || !s_unmod.contains(c.getClass())) {
                         // copy the collection
-                        Collection copy;
+                        Collection<Object> copy;
                         if (c instanceof SortedSet)
-                            copy = new TreeSet();
+                            copy = new TreeSet<Object>();
                         else if (c instanceof Set)
-                            copy = new HashSet();
+                            copy = new HashSet<Object>();
                         else
-                            copy = new ArrayList(c.size());
+                            copy = new ArrayList<Object>(c.size());
 
                         if (contentsAreDates) {
                             // must go through by hand and do the
                             // copy, since Date is mutable.
-                            for (Iterator itr2 = c.iterator(); itr2.hasNext();)
+                            for (Iterator<Object> itr2 = c.iterator(); itr2.hasNext();)
                                 copy.add(((Date) itr2.next()).clone());
                         } else
                             copy.addAll(c);
@@ -373,7 +371,7 @@ public class QueryKey
      * <code>false</code>. Invalidation is possible if one or more of
      * the classes in this query key's access path has been changed.
      */
-    public boolean changeInvalidatesQuery(Collection changed) {
+    public boolean changeInvalidatesQuery(Collection<Class<?>> changed) {
         return intersects(_accessPathClassNames, changed);
     }
 
@@ -381,11 +379,9 @@ public class QueryKey
      * Whether the given set of least-derived class names intersects with
      * the given set of changed classes.
      */
-    private static boolean intersects(Collection names, Collection changed) {
-        Class cls;
-        Class sup;
-        for (Iterator iter = changed.iterator(); iter.hasNext();) {
-            cls = (Class) iter.next();
+    private static boolean intersects(Collection<String> names, Collection<Class<?>>
changed) {
+        Class<?> sup;
+        for (Class<?> cls : changed) {
             while ((sup = PCRegistry.getPersistentSuperclass(cls)) != null)
                 cls = sup;
             if (names.contains(cls.getName()))
@@ -462,10 +458,10 @@ public class QueryKey
         throws IOException, ClassNotFoundException {
         _candidateClassName = (String) in.readObject();
         _subclasses = in.readBoolean();
-        _accessPathClassNames = (Set) in.readObject();
+        _accessPathClassNames = (Set<String>) in.readObject();
         _query = (String) in.readObject();
         _ignoreChanges = in.readBoolean();
-        _params = (Map) in.readObject();
+        _params = (Map<Object,Object>) in.readObject();
         _rangeStart = in.readLong();
         _rangeEnd = in.readLong ();
 		_timeout = in.readInt ();

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/BeanLifecycleCallbacks.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/BeanLifecycleCallbacks.java?rev=1236280&r1=1236279&r2=1236280&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/BeanLifecycleCallbacks.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/BeanLifecycleCallbacks.java
Thu Jan 26 16:36:38 2012
@@ -45,10 +45,10 @@ public class BeanLifecycleCallbacks
     /**
      * Constructor. Make the callback on an instance of the given type.
      *
-     * @arg whether another argunent is expected such as AfterDetach
+     * @arg whether another argument is expected such as AfterDetach
      */
-    public BeanLifecycleCallbacks(Class cls, String method, boolean arg,
-        Class type) {
+    public BeanLifecycleCallbacks(Class<?> cls, String method, boolean arg,
+        Class<?> type) {
         this(cls, getMethod(cls, method, arg ? new Class[]{ Object.class,
             type } : new Class[]{ type }), arg);
     }
@@ -56,12 +56,12 @@ public class BeanLifecycleCallbacks
     /**
      * Constructor. Make the callback on an instance of the given type.
      */
-    public BeanLifecycleCallbacks(Class cls, Method method, boolean arg) {
+    public BeanLifecycleCallbacks(Class<?> cls, Method method, boolean arg) {
         super(method, arg);
         _listener = newListener(cls);
     }
     
-    private Object newListener(Class cls) {
+    private Object newListener(Class<?> cls) {
         try {
             return AccessController.doPrivileged(
                 J2DoPrivHelper.newInstanceAction(cls));
@@ -88,7 +88,7 @@ public class BeanLifecycleCallbacks
     public void readExternal(ObjectInput in)
         throws IOException, ClassNotFoundException {
         super.readExternal(in);
-        Class cls = (Class) in.readObject();
+        Class<?> cls = (Class<?>) in.readObject();
         _listener = newListener(cls);
     }
 

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ResultPacker.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ResultPacker.java?rev=1236280&r1=1236279&r2=1236280&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ResultPacker.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ResultPacker.java
Thu Jan 26 16:36:38 2012
@@ -53,7 +53,7 @@ public class ResultPacker {
 
     private static final Localizer _loc = Localizer.forPackage
         (ResultPacker.class);
-    private static final Set _stdTypes = new HashSet();
+    private static final Set<Class<?>> _stdTypes = new HashSet<Class<?>>();
 
     static {
         _stdTypes.add(Object[].class);
@@ -79,11 +79,11 @@ public class ResultPacker {
         _stdTypes.add(GregorianCalendar.class);
     }
 
-    private final Class _resultClass;
+    private final Class<?> _resultClass;
     private final String[] _aliases;
     private final Member[] _sets;
     private final Method _put;
-    private final Constructor _constructor;
+    private final Constructor<?> _constructor;
     
     /**
      * Protected constructor to bypass this implementation but allow extension.
@@ -99,7 +99,7 @@ public class ResultPacker {
     /**
      * Constructor for result class without a projection.
      */
-    public ResultPacker(Class candidate, String alias, Class resultClass) {
+    public ResultPacker(Class<?> candidate, String alias, Class<?> resultClass)
{
         this(candidate, null, new String[]{ alias }, resultClass);
     }
 
@@ -110,7 +110,7 @@ public class ResultPacker {
      * @param aliases the alias for each projection value
      * @param resultClass the class to pack into
      */
-    public ResultPacker(Class[] types, String[] aliases, Class resultClass) {
+    public ResultPacker(Class<?>[] types, String[] aliases, Class<?> resultClass)
{
         this(null, types, aliases, resultClass);
     }
 
@@ -186,9 +186,9 @@ public class ResultPacker {
     /**
      * Ensure that conversion is possible.
      */
-    private void assertConvertable(Class candidate, Class[] types,
-        Class resultClass) {
-        Class c = (types == null) ? candidate : types[0];
+    private void assertConvertable(Class<?> candidate, Class<?>[] types,
+        Class<?> resultClass) {
+        Class<?> c = (types == null) ? candidate : types[0];
         if ((types != null && types.length != 1) || (c != null
             && c != Object.class && !Filters.canConvert(c, resultClass, true)))
             throw new UserException(_loc.get("cant-convert-result",
@@ -208,7 +208,7 @@ public class ResultPacker {
         if (_resultClass == Object[].class)
             return new Object[]{ result };
         if (_resultClass == HashMap.class || _resultClass == Map.class) {
-            HashMap map = new HashMap(1, 1F);
+            HashMap<String,Object> map = new HashMap<String,Object>(1, 1F);
             map.put(_aliases[0], result);
             return map;
         }
@@ -249,7 +249,7 @@ public class ResultPacker {
         if (_resultClass == Object.class)
             return result[0];
         if (_resultClass == HashMap.class || _resultClass == Map.class) {
-            Map map = new HashMap(result.length);
+            Map<String,Object> map = new HashMap<String,Object>(result.length);
             for (int i = 0; i < _aliases.length; i++)
                 map.put(_aliases[i], result[i]);
             return map;
@@ -304,7 +304,7 @@ public class ResultPacker {
     /**
      * Return the set method for the given property.
      */
-    private static Member findSet(String alias, Class type, Field[] fields,
+    private static Member findSet(String alias, Class<?> type, Field[] fields,
         Method[] methods) {
         if (StringUtils.isEmpty(alias))
             return null;
@@ -336,7 +336,7 @@ public class ResultPacker {
         String setName = "set" + StringUtils.capitalize(alias);
         Method method = null;
         boolean eqName = false;
-        Class[] params;
+        Class<?>[] params;
         for (int i = 0; i < methods.length; i++) {
             if (!methods[i].getName().equalsIgnoreCase(setName))
                 continue;

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/InterfaceImplGenerator.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/InterfaceImplGenerator.java?rev=1236280&r1=1236279&r2=1236280&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/InterfaceImplGenerator.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/InterfaceImplGenerator.java
Thu Jan 26 16:36:38 2012
@@ -52,7 +52,7 @@ class InterfaceImplGenerator {
     private static final String POSTFIX = "openjpaimpl";
 
     private final MetaDataRepository _repos;
-    private final Map _impls = new WeakHashMap();
+    private final Map<Class<?>,Class<?>> _impls = new WeakHashMap<Class<?>,Class<?>>();
     private final Project _project = new Project();
  
     // distinct project / loader for enhanced version of class
@@ -69,11 +69,11 @@ class InterfaceImplGenerator {
      * Create a concrete implementation of the given type, possibly
      * returning a cached version of the class.
      */
-    public synchronized Class createImpl(ClassMetaData meta) {
-        Class iface = meta.getDescribedType();
+    public synchronized Class<?> createImpl(ClassMetaData meta) {
+        Class<?> iface = meta.getDescribedType();
 
         // check cache.
-        Class impl = (Class) _impls.get(iface);
+        Class<?> impl = _impls.get(iface);
         if (impl != null)
             return impl;
 
@@ -98,12 +98,12 @@ class InterfaceImplGenerator {
         }
 
         FieldMetaData[] fields = meta.getDeclaredFields();
-        Set methods = new HashSet();
+        Set<Method> methods = new HashSet<Method>();
         for (int i = 0; i < fields.length; i++) 
             addField(bc, iface, fields[i], methods);
         invalidateNonBeanMethods(bc, iface, methods);
 
-        // first load the base class as the enhancer requires the class
+        // first load the base Class<?> as the enhancer requires the class
         // to be available
         try {
             meta.setInterfaceImpl(Class.forName(bc.getName(), true, loader));
@@ -111,7 +111,7 @@ class InterfaceImplGenerator {
             throw new InternalException(_loc.get("interface-load", iface, 
                 loader), t).setFatal(true);
         }
-        // copy the BCClass into the enhancer project.
+        // copy the BCClass<?> into the enhancer project.
         bc = _enhProject.loadClass(new ByteArrayInputStream(bc.toByteArray()), 
             loader);
         PCEnhancer enhancer = new PCEnhancer(_repos, bc, meta);
@@ -121,7 +121,7 @@ class InterfaceImplGenerator {
             throw new InternalException(_loc.get("interface-badenhance", 
                 iface)).setFatal(true);
         try {
-            // load the class for real.
+            // load the Class<?> for real.
             impl = Class.forName(bc.getName(), true, enhLoader);
         } catch (Throwable t) {
             throw new InternalException(_loc.get("interface-load2", iface, 
@@ -136,10 +136,10 @@ class InterfaceImplGenerator {
      * Add bean getters and setters, also recording seen methods
      * into the given set.
      */
-    private void addField (BCClass bc, Class iface, FieldMetaData fmd, 
-        Set methods) {
+    private void addField (BCClass bc, Class<?> iface, FieldMetaData fmd, 
+        Set<Method> methods) {
         String name = fmd.getName();
-        Class type = fmd.getDeclaredType();
+        Class<?> type = fmd.getDeclaredType();
         BCField field = bc.declareField(name, type);
         field.setAccessFlags(Constants.ACCESS_PRIVATE);
 
@@ -172,13 +172,13 @@ class InterfaceImplGenerator {
     /**
      * Invalidate methods on the interface which are not managed.
      */
-    private void invalidateNonBeanMethods(BCClass bc, Class iface, 
-        Set methods) {
+    private void invalidateNonBeanMethods(BCClass bc, Class<?> iface, 
+        Set<Method> methods) {
         Method[] meths = (Method[]) AccessController.doPrivileged(
             J2DoPrivHelper.getDeclaredMethodsAction(iface)); 
         BCMethod meth;
         Code code;
-        Class type = _repos.getMetaDataFactory().getDefaults().
+        Class<?> type = _repos.getMetaDataFactory().getDefaults().
             getUnimplementedExceptionType();
         for (int i = 0; i < meths.length; i++) {
             if (methods.contains(meths[i]))
@@ -197,17 +197,17 @@ class InterfaceImplGenerator {
     }
 
     /**
-     * Return a unique class name.
+     * Return a unique Class<?> name.
      */
     protected final String getClassName(ClassMetaData meta) {
-        Class iface = meta.getDescribedType();
+        Class<?> iface = meta.getDescribedType();
         return iface.getName() + "$" + System.identityHashCode(iface) + POSTFIX;
     }
 
     /**
      * Convenience method to return the given method / arg.
      */
-    private static Method getMethodSafe(Class iface, String name, Class arg) {
+    private static Method getMethodSafe(Class<?> iface, String name, Class<?>
arg) {
         try {
             return AccessController.doPrivileged(
                 J2DoPrivHelper.getDeclaredMethodAction(
@@ -217,7 +217,7 @@ class InterfaceImplGenerator {
         }
     }
 
-    private static boolean isGetter(Class iface, FieldMetaData fmd) {
+    private static boolean isGetter(Class<?> iface, FieldMetaData fmd) {
         if (fmd.getType() != boolean.class && fmd.getType() != Boolean.class)
             return true;
         try {
@@ -229,13 +229,13 @@ class InterfaceImplGenerator {
         return true;
     }
 
-    boolean isImplType(Class cls) {
+    boolean isImplType(Class<?> cls) {
         return (cls.getName().endsWith(POSTFIX)
             && cls.getName().indexOf('$') != -1);
     }
 
-    public Class toManagedInterface(Class cls) {
-        Class[] ifaces = cls.getInterfaces();
+    public Class<?> toManagedInterface(Class<?> cls) {
+        Class<?>[] ifaces = cls.getInterfaces();
         for (int i = 0; i < ifaces.length; i++) {
             if (_impls.get(ifaces[i]) == cls)
                 return ifaces[i];

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/JavaTypes.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/JavaTypes.java?rev=1236280&r1=1236279&r2=1236280&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/JavaTypes.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/JavaTypes.java Thu
Jan 26 16:36:38 2012
@@ -440,22 +440,22 @@ public class JavaTypes {
      * Helper method to return the given array value as a collection.
      */
     @SuppressWarnings("unchecked")
-    public static List toList(Object val, Class<?> elem, boolean mutable) {
+    public static <T> List<T> toList(Object val, Class<T> elem, boolean
mutable) {
         if (val == null)
             return null;
 
-        List l;
+        List<T> l;
         if (!elem.isPrimitive()) {
             // if an object array, use built-in list function
-            l = Arrays.asList((Object[]) val);
+            l = Arrays.asList((T[]) val);
             if (mutable)
-                l = new ArrayList(l);
+                l = new ArrayList<T>(l);
         } else {
             // convert to list of wrapper objects
             int length = Array.getLength(val);
-            l = new ArrayList(length);
+            l = new ArrayList<T>(length);
             for (int i = 0; i < length; i++)
-                l.add(Array.get(val, i));
+                l.add((T)Array.get(val, i));
         }
         return l;
     }

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ApplicationIds.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ApplicationIds.java?rev=1236280&r1=1236279&r2=1236280&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ApplicationIds.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ApplicationIds.java
Thu Jan 26 16:36:38 2012
@@ -98,7 +98,7 @@ public class ApplicationIds {
         // default to reflection
         if (meta.isObjectIdTypeShared())
             oid = ((ObjectId) oid).getId();
-        Class oidType = oid.getClass();
+        Class<?> oidType = oid.getClass();
         for (int i = 0; i < fmds.length; i++) {
             if (AccessCode.isField(meta.getAccessType()))
                 pks[i] = Reflection.get(oid, Reflection.findField(oidType, 
@@ -227,7 +227,7 @@ public class ApplicationIds {
         }
 
         // default to reflection
-        Class oidType = meta.getObjectIdType();
+        Class<?> oidType = meta.getObjectIdType();
         if (Modifier.isAbstract(oidType.getModifiers()))
             throw new UserException(_loc.get("objectid-abstract", meta));
         Object copy = null;
@@ -267,7 +267,7 @@ public class ApplicationIds {
 
         if (meta.isOpenJPAIdentity()) {
             // use meta type instead of oid type in case it's a subclass
-            Class cls = meta.getDescribedType();
+            Class<?> cls = meta.getDescribedType();
             OpenJPAId koid = (OpenJPAId) oid;
             FieldMetaData pk = meta.getPrimaryKeyFields()[0];
             switch (pk.getObjectIdFieldTypeCode()) {
@@ -330,7 +330,7 @@ public class ApplicationIds {
         // oid instance
         if (!Modifier.isAbstract(meta.getDescribedType().getModifiers())
             && !hasPCPrimaryKeyFields(meta)) {
-            Class type = meta.getDescribedType();
+            Class<?> type = meta.getDescribedType();
             PersistenceCapable pc = PCRegistry.newInstance(type, null, oid, 
                  false);
             Object copy = pc.pcNewObjectIdInstance();
@@ -367,7 +367,7 @@ public class ApplicationIds {
         if (oid == null)
             return null;
 
-        Class oidType = oid.getClass();
+        Class<?> oidType = oid.getClass();
         Object copy = null;
         try {
             copy = AccessController.doPrivileged(
@@ -408,7 +408,7 @@ public class ApplicationIds {
             return ((OpenJPAId) oid).getIdObject();
 
         ClassMetaData meta = fmd.getDefiningMetaData();
-        Class oidType = oid.getClass();
+        Class<?> oidType = oid.getClass();
         if (AccessCode.isField(meta.getAccessType()))
             return Reflection.get(oid, Reflection.findField(oidType, 
                 fmd.getName(), true));
@@ -512,7 +512,7 @@ public class ApplicationIds {
         if (mappedByIdFieldName.length() != 0) {
             if (((ObjectId)id).getId() == null)
                 return false;        	
-            Class idClass = ((ObjectId)id).getId().getClass();
+            Class<?> idClass = ((ObjectId)id).getId().getClass();
             val = Reflection.get(key, 
                     Reflection.findField(idClass, mappedByIdFieldName, true)); 
         } else

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/MultiClassLoader.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/MultiClassLoader.java?rev=1236280&r1=1236279&r2=1236280&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/MultiClassLoader.java
(original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/MultiClassLoader.java
Thu Jan 26 16:36:38 2012
@@ -51,7 +51,7 @@ public class MultiClassLoader extends Cl
         AccessController.doPrivileged(
             J2DoPrivHelper.getSystemClassLoaderAction());
 
-    private List _loaders = new ArrayList(5);
+    private List<ClassLoader> _loaders = new ArrayList<ClassLoader>(5);
 
     /**
      * Constructor; initializes the loader with an empty list of delegates.
@@ -81,9 +81,9 @@ public class MultiClassLoader extends Cl
     public ClassLoader[] getClassLoaders() {
         ClassLoader[] loaders = new ClassLoader[size()];
         ClassLoader loader;
-        Iterator itr = _loaders.iterator();
+        Iterator<ClassLoader> itr = _loaders.iterator();
         for (int i = 0; i < loaders.length; i++) {
-            loader = (ClassLoader) itr.next();
+            loader = itr.next();
             if (loader == THREAD_LOADER)
                 loader = AccessController.doPrivileged(
                     J2DoPrivHelper.getContextClassLoaderAction());
@@ -146,7 +146,7 @@ public class MultiClassLoader extends Cl
 
         // use iterator so that the thread loader is not resolved
         boolean added = false;
-        for (Iterator itr = multi._loaders.iterator(); itr.hasNext();) {
+        for (Iterator<ClassLoader> itr = multi._loaders.iterator(); itr.hasNext();)
{
             if (addClassLoader(index, (ClassLoader) itr.next())) {
                 index++;
                 added = true;
@@ -166,7 +166,7 @@ public class MultiClassLoader extends Cl
 
         // use iterator so that the thread loader is not resolved
         boolean added = false;
-        for (Iterator itr = multi._loaders.iterator(); itr.hasNext();)
+        for (Iterator<ClassLoader> itr = multi._loaders.iterator(); itr.hasNext();)
             added = addClassLoader((ClassLoader) itr.next()) || added;
         return added;
     }
@@ -201,9 +201,9 @@ public class MultiClassLoader extends Cl
         return _loaders.isEmpty();
     }
 
-    protected Class findClass(String name) throws ClassNotFoundException {
+    protected Class<?> findClass(String name) throws ClassNotFoundException {
         ClassLoader loader;
-        for (Iterator itr = _loaders.iterator(); itr.hasNext();) {
+        for (Iterator<ClassLoader> itr = _loaders.iterator(); itr.hasNext();) {
             loader = (ClassLoader) itr.next();
             if (loader == THREAD_LOADER)
                 loader = AccessController.doPrivileged(
@@ -219,7 +219,7 @@ public class MultiClassLoader extends Cl
     protected URL findResource(String name) {
         ClassLoader loader;
         URL rsrc;
-        for (Iterator itr = _loaders.iterator(); itr.hasNext();) {
+        for (Iterator<ClassLoader> itr = _loaders.iterator(); itr.hasNext();) {
             loader = (ClassLoader) itr.next();
             if (loader == THREAD_LOADER)
                 loader = AccessController.doPrivileged(
@@ -236,13 +236,13 @@ public class MultiClassLoader extends Cl
         return null;
     }
 
-    protected Enumeration findResources(String name) throws IOException {
+    protected Enumeration<URL> findResources(String name) throws IOException {
         ClassLoader loader;
-        Enumeration rsrcs;
-        Object rsrc;
-        Vector all = new Vector();
-        for (Iterator itr = _loaders.iterator(); itr.hasNext();) {
-            loader = (ClassLoader) itr.next();
+        Enumeration<URL> rsrcs;
+        URL rsrc;
+        Vector<URL> all = new Vector<URL>();
+        for (Iterator<ClassLoader> itr = _loaders.iterator(); itr.hasNext();) {
+            loader = itr.next();
             if (loader == THREAD_LOADER)
                 loader = AccessController.doPrivileged(
                     J2DoPrivHelper.getContextClassLoaderAction());

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=1236280&r1=1236279&r2=1236280&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 Thu Jan
26 16:36:38 2012
@@ -177,7 +177,7 @@ public class Options extends TypedProper
         // set all defaults that have no explicit value
         Map.Entry entry = null;
         if (defaults != null) {
-            for (Iterator itr = defaults.entrySet().iterator(); itr.hasNext();) {
+            for (Iterator<?> itr = defaults.entrySet().iterator(); itr.hasNext();)
{
                 entry = (Map.Entry) itr.next();
                 if (!containsKey(entry.getKey()))
                     setInto(obj, entry);
@@ -187,7 +187,7 @@ public class Options extends TypedProper
         // set from main map
         Options invalidEntries = null;
         Map.Entry e;
-        for (Iterator itr = entrySet().iterator(); itr.hasNext();) {
+        for (Iterator<?> itr = entrySet().iterator(); itr.hasNext();) {
             e = (Map.Entry) itr.next();
             if (!setInto(obj, e)) {
                 if (invalidEntries == null)
@@ -310,7 +310,7 @@ public class Options extends TypedProper
         String get = "get" + base;
 
         // look for a setter/getter matching the key; look for methods first
-        Class type = match[0].getClass();
+        Class<? extends Object> type = match[0].getClass();
         Method[] meths = type.getMethods();
         Method setMeth = null;
         Method getMeth = null;
@@ -366,7 +366,7 @@ public class Options extends TypedProper
             // if no getter or current inner is null, try to create a new
             // inner instance and set it in object
             if (inner == null && setter != null) {
-                Class innerType = getType(setter)[0];
+                Class<?> innerType = getType(setter)[0];
                 try {
                     inner = AccessController.doPrivileged(
                         J2DoPrivHelper.newInstanceAction(innerType));
@@ -387,7 +387,7 @@ public class Options extends TypedProper
     /**
      * Return the types of the parameters needed to set the given member.
      */
-    private static Class[] getType(Object member) {
+    private static Class<?>[] getType(Object member) {
         if (member instanceof Method)
             return ((Method) member).getParameterTypes();
         return new Class[]{ ((Field) member).getType() };
@@ -463,7 +463,7 @@ public class Options extends TypedProper
     /**
      * Returns the default value for the given parameter type.
      */
-    private Object getDefaultValue(Class type) {
+    private Object getDefaultValue(Class<?> type) {
         for (int i = 0; i < _primWrappers.length; i++)
             if (_primWrappers[i][0] == type)
                 return _primWrappers[i][2];

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/common/utils/BufferedLogFactory.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/common/utils/BufferedLogFactory.java?rev=1236280&r1=1236279&r2=1236280&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/common/utils/BufferedLogFactory.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/common/utils/BufferedLogFactory.java
Thu Jan 26 16:36:38 2012
@@ -26,20 +26,20 @@ import org.apache.openjpa.lib.log.*;
  * Simple default log implementation to test whether certain messages
  * are logged or not.
  *
- * @author <a href="mailto:marc@solarmetric.com">Marc Prud'hommeaux</a>
+ * @author Marc Prud'hommeaux
  */
 public class BufferedLogFactory
     extends LogFactoryImpl {
 
     private int bufferSize = 10000;
-    private List buffer = new ArrayList();
-    private List disallowedMessages = new LinkedList();
+    private List<String> buffer = new ArrayList<String>();
+    private List<String> disallowedMessages = new LinkedList<String>();
 
     protected LogImpl newLogImpl() {
         return new BufferedLog();
     }
 
-    public List getBuffer() {
+    public List<String> getBuffer() {
         return Collections.unmodifiableList(buffer);
     }
 
@@ -59,7 +59,7 @@ public class BufferedLogFactory
         return disallowedMessages.remove(regexp);
     }
 
-    public List getDisallowedMessages() {
+    public List<String> getDisallowedMessages() {
         return Collections.unmodifiableList(disallowedMessages);
     }
 
@@ -91,8 +91,8 @@ public class BufferedLogFactory
                 buffer.iterator().remove();
 
             if (disallowedMessages.size() > 0) {
-                for (Iterator i = disallowedMessages.iterator(); i.hasNext();) {
-                    String regex = (String) i.next();
+                for (Iterator<String> i = disallowedMessages.iterator(); i.hasNext();)
{
+                    String regex = i.next();
                     AbstractTestCase.assertNotMatches(regex, message);
                 }
             }

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/Members.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/Members.java?rev=1236280&r1=1236279&r2=1236280&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/Members.java
(original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/Members.java
Thu Jan 26 16:36:38 2012
@@ -74,7 +74,7 @@ public class Members {
          *  Returns the managed type which declared this attribute.
          */
         public final ManagedType<X> getDeclaringType() {
-            return owner.model.managedType(fmd.getDeclaringType());
+            return (ManagedType<X>)owner.model.managedType(fmd.getDeclaringType());
         }
         
         /**



Mime
View raw message