cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r596798 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne: BaseContext.java CayenneContext.java ObjectContext.java access/DataContext.java query/NamedQuery.java
Date Tue, 20 Nov 2007 19:43:13 GMT
Author: aadamchik
Date: Tue Nov 20 11:43:12 2007
New Revision: 596798

URL: http://svn.apache.org/viewvc?rev=596798&view=rev
Log:
java5 : generics

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/BaseContext.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/CayenneContext.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/ObjectContext.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/NamedQuery.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/BaseContext.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/BaseContext.java?rev=596798&r1=596797&r2=596798&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/BaseContext.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/BaseContext.java
Tue Nov 20 11:43:12 2007
@@ -45,7 +45,7 @@
 
     public abstract void deleteObject(Object object) throws DeleteDenyException;
 
-    public abstract Collection deletedObjects();
+    public abstract Collection<?> deletedObjects();
 
     public DataChannel getChannel() {
         return channel;
@@ -57,17 +57,17 @@
 
     public abstract Persistent localObject(ObjectId id, Object prototype);
 
-    public abstract Collection modifiedObjects();
+    public abstract Collection<?> modifiedObjects();
 
     public abstract <T> T newObject(Class<T> persistentClass);
 
     public abstract void registerNewObject(Object object);
 
-    public abstract Collection newObjects();
+    public abstract Collection<?> newObjects();
 
     public abstract QueryResponse performGenericQuery(Query query);
 
-    public abstract List performQuery(Query query);
+    public abstract List<?> performQuery(Query query);
 
     /**
      * @deprecated since 3.0 this method is replaced by
@@ -81,7 +81,7 @@
         if (object.getPersistenceState() == PersistenceState.HOLLOW) {
 
             ObjectId oid = object.getObjectId();
-            List objects = performQuery(new ObjectIdQuery(oid, false, ObjectIdQuery.CACHE));
+            List<?> objects = performQuery(new ObjectIdQuery(oid, false, ObjectIdQuery.CACHE));
 
             if (objects.size() == 0) {
                 throw new FaultFailureException(
@@ -132,5 +132,5 @@
 
     public abstract void rollbackChangesLocally();
 
-    public abstract Collection uncommittedObjects();
+    public abstract Collection<?> uncommittedObjects();
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/CayenneContext.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/CayenneContext.java?rev=596798&r1=596797&r2=596798&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/CayenneContext.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/CayenneContext.java
Tue Nov 20 11:43:12 2007
@@ -337,9 +337,9 @@
     /**
      * Runs a query, returning result as list.
      */
-    public List performQuery(Query query) {
-        List result = onQuery(this, query).firstList();
-        return result != null ? result : new ArrayList(1);
+    public List<?> performQuery(Query query) {
+        List<?> result = onQuery(this, query).firstList();
+        return result != null ? result : new ArrayList<Object>(1);
     }
 
     public QueryResponse performGenericQuery(Query query) {
@@ -448,25 +448,25 @@
         }
     }
 
-    public Collection uncommittedObjects() {
+    public Collection<?> uncommittedObjects() {
         synchronized (graphManager) {
             return graphManager.dirtyNodes();
         }
     }
 
-    public Collection deletedObjects() {
+    public Collection<?> deletedObjects() {
         synchronized (graphManager) {
             return graphManager.dirtyNodes(PersistenceState.DELETED);
         }
     }
 
-    public Collection modifiedObjects() {
+    public Collection<?> modifiedObjects() {
         synchronized (graphManager) {
             return graphManager.dirtyNodes(PersistenceState.MODIFIED);
         }
     }
 
-    public Collection newObjects() {
+    public Collection<?> newObjects() {
         synchronized (graphManager) {
             return graphManager.dirtyNodes(PersistenceState.NEW);
         }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/ObjectContext.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/ObjectContext.java?rev=596798&r1=596797&r2=596798&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/ObjectContext.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/ObjectContext.java
Tue Nov 20 11:43:12 2007
@@ -156,7 +156,7 @@
     /**
      * Executes a selecting query, returning a list of persistent objects or data rows.
      */
-    List performQuery(Query query);
+    List<?> performQuery(Query query);
 
     /**
      * Executes any kind of query providing the result in a form of QueryResponse.

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java?rev=596798&r1=596797&r2=596798&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataContext.java
Tue Nov 20 11:43:12 2007
@@ -465,7 +465,7 @@
      * Returns a list of objects that are registered with this DataContext and have a
      * state PersistenceState.NEW
      */
-    public Collection newObjects() {
+    public Collection<?> newObjects() {
         return getObjectStore().objectsInState(PersistenceState.NEW);
     }
 
@@ -473,7 +473,7 @@
      * Returns a list of objects that are registered with this DataContext and have a
      * state PersistenceState.DELETED
      */
-    public Collection deletedObjects() {
+    public Collection<?> deletedObjects() {
         return getObjectStore().objectsInState(PersistenceState.DELETED);
     }
 
@@ -481,7 +481,7 @@
      * Returns a list of objects that are registered with this DataContext and have a
      * state PersistenceState.MODIFIED
      */
-    public Collection modifiedObjects() {
+    public Collection<?> modifiedObjects() {
         return getObjectStore().objectsInState(PersistenceState.MODIFIED);
     }
 
@@ -490,7 +490,7 @@
      * 
      * @since 1.2
      */
-    public Collection uncommittedObjects() {
+    public Collection<?> uncommittedObjects() {
 
         int len = getObjectStore().registeredObjectsCount();
         if (len == 0) {
@@ -498,7 +498,7 @@
         }
 
         // guess target collection size
-        Collection objects = new ArrayList(len > 100 ? len / 2 : len);
+        Collection<Object> objects = new ArrayList<Object>(len > 100 ? len
/ 2 : len);
 
         Iterator it = getObjectStore().getObjectIterator();
         while (it.hasNext()) {
@@ -1303,14 +1303,14 @@
      * @return A list of DataObjects or a DataRows, depending on the value returned by
      *         {@link QueryMetadata#isFetchingDataRows()}.
      */
-    public List performQuery(Query query) {
+    public List<?> performQuery(Query query) {
         query = nonNullDelegate().willPerformQuery(this, query);
         if (query == null) {
-            return new ArrayList(1);
+            return new ArrayList<Object>(1);
         }
 
-        List result = onQuery(this, query).firstList();
-        return result != null ? result : new ArrayList(1);
+        List<?> result = onQuery(this, query).firstList();
+        return result != null ? result : new ArrayList<Object>(1);
     }
 
     /**
@@ -1350,7 +1350,7 @@
      * 
      * @since 1.1
      */
-    public int[] performNonSelectingQuery(String queryName, Map parameters) {
+    public int[] performNonSelectingQuery(String queryName, Map<String, ?> parameters)
{
         return performNonSelectingQuery(new NamedQuery(queryName, parameters));
     }
 
@@ -1366,7 +1366,7 @@
      *            is required in case a query uses caching.
      * @since 1.1
      */
-    public List performQuery(String queryName, boolean expireCachedLists) {
+    public List<?> performQuery(String queryName, boolean expireCachedLists) {
         return performQuery(queryName, Collections.EMPTY_MAP, expireCachedLists);
     }
 
@@ -1383,7 +1383,7 @@
      *            is required in case a query uses caching.
      * @since 1.1
      */
-    public List performQuery(String queryName, Map parameters, boolean expireCachedLists)
{
+    public List<?> performQuery(String queryName, Map parameters, boolean expireCachedLists)
{
         NamedQuery query = new NamedQuery(queryName, parameters);
         query.setForceNoCache(expireCachedLists);
         return performQuery(query);

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/NamedQuery.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/NamedQuery.java?rev=596798&r1=596797&r2=596798&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/NamedQuery.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/NamedQuery.java
Tue Nov 20 11:43:12 2007
@@ -22,7 +22,6 @@
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
 
 import org.apache.cayenne.CayenneRuntimeException;
@@ -42,7 +41,7 @@
  */
 public class NamedQuery extends IndirectQuery {
 
-    protected Map parameters;
+    protected Map<String, ?> parameters;
 
     protected boolean forceNoCache;
 
@@ -55,12 +54,12 @@
         this(name, null);
     }
 
-    public NamedQuery(String name, Map parameters) {
+    public NamedQuery(String name, Map<String, ?> parameters) {
         this.name = name;
 
         // copy parameters map (among other things to make hessian serilaization work).
         if (parameters != null && !parameters.isEmpty()) {
-            this.parameters = new HashMap(parameters);
+            this.parameters = new HashMap<String, Object>(parameters);
         }
     }
 
@@ -132,17 +131,14 @@
      * initial map with ObjectIds. This is needed so that a query could work uniformly on
      * the server and client sides.
      */
-    Map normalizedParameters() {
+    Map<String, ?> normalizedParameters() {
         if (parameters == null || parameters.isEmpty()) {
             return Collections.EMPTY_MAP;
         }
 
-        Map substitutes = new HashMap(parameters);
-
-        Iterator it = parameters.entrySet().iterator();
-        while (it.hasNext()) {
-            Map.Entry entry = (Map.Entry) it.next();
+        Map<String, Object> substitutes = new HashMap<String, Object>(parameters);
 
+        for (Map.Entry<String, ?> entry : parameters.entrySet()) {
             Object value = entry.getValue();
 
             if (value instanceof Persistent) {
@@ -232,10 +228,9 @@
         }
 
         EqualsBuilder builder = new EqualsBuilder();
-        Iterator entries = parameters.entrySet().iterator();
-        while (entries.hasNext()) {
-            Map.Entry entry = (Map.Entry) entries.next();
-            Object entryKey = entry.getKey();
+
+        for (Map.Entry<String, ?> entry : parameters.entrySet()) {
+            String entryKey = entry.getKey();
             Object entryValue = entry.getValue();
 
             if (entryValue == null) {



Mime
View raw message