cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amania...@apache.org
Subject svn commit: r599363 - /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/
Date Thu, 29 Nov 2007 10:06:08 GMT
Author: amaniatis
Date: Thu Nov 29 02:06:07 2007
New Revision: 599363

URL: http://svn.apache.org/viewvc?rev=599363&view=rev
Log:
Implement a bunch of generics and new-style for loops. This was several hundred warnings and the whole .map package is now clean except for the Ashwood class which is all Greek to me.
(Well, maybe some other language I don't know...)

I think the new for loops are much more readable. Comments welcome on my approach here...


Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/AshwoodEntitySorter.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DataMap.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbAttribute.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbEntity.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbJoin.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbRelationship.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/Embeddable.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/EmbeddedAttribute.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/Entity.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/EntityInheritanceTree.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/EntityListener.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/EntityResolver.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjAttribute.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjEntity.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjRelationship.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/Relationship.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/SQLTemplateBuilder.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/SelectQueryBuilder.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/AshwoodEntitySorter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/AshwoodEntitySorter.java?rev=599363&r1=599362&r2=599363&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/AshwoodEntitySorter.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/AshwoodEntitySorter.java Thu Nov 29 02:06:07 2007
@@ -62,7 +62,7 @@
     protected Digraph referentialDigraph;
     protected Digraph contractedReferentialDigraph;
     protected Map components;
-    protected Map reflexiveDbEntities;
+    protected Map<DbEntity, List> reflexiveDbEntities;
 
     protected TableComparator tableComparator;
     protected DbEntityComparator dbEntityComparator;
@@ -89,7 +89,7 @@
 
         Collection<Table> tables = new ArrayList<Table>(64);
         dbEntityToTableMap = new HashMap<DbEntity, Table>(64);
-        reflexiveDbEntities = new HashMap(32);
+        reflexiveDbEntities = new HashMap<DbEntity, List>(32);
 
         for (DataMap map : dataMaps) {
             for (DbEntity entity : map.getDbEntities()) {
@@ -168,7 +168,7 @@
                 .getEntityResolver();
         ClassDescriptor descriptor = resolver.getClassDescriptor(objEntity.getName());
 
-        List reflexiveRels = (List) reflexiveDbEntities.get(dbEntity);
+        List reflexiveRels = reflexiveDbEntities.get(dbEntity);
         String[] reflexiveRelNames = new String[reflexiveRels.size()];
         for (int i = 0; i < reflexiveRelNames.length; i++) {
             DbRelationship dbRel = (DbRelationship) reflexiveRels.get(i);
@@ -276,9 +276,9 @@
                         table.addForeignKey(fk);
 
                         if (newReflexive) {
-                            List reflexiveRels = (List) reflexiveDbEntities.get(entity);
+                            List<DbRelationship> reflexiveRels = reflexiveDbEntities.get(entity);
                             if (reflexiveRels == null) {
-                                reflexiveRels = new ArrayList(1);
+                                reflexiveRels = new ArrayList<DbRelationship>(1);
                                 reflexiveDbEntities.put(entity, reflexiveRels);
                             }
                             reflexiveRels.add(candidate);
@@ -295,7 +295,7 @@
             ObjRelationship toOneRel,
             String targetEntityName) {
 
-        DbRelationship finalRel = (DbRelationship) toOneRel.getDbRelationships().get(0);
+        DbRelationship finalRel = toOneRel.getDbRelationships().get(0);
         ObjectContext context = object.getObjectContext();
 
         // find committed snapshot - so we can't fetch from the context as it will return
@@ -339,7 +339,7 @@
     }
 
     protected Table getTable(DbEntity dbEntity) {
-        return (dbEntity != null) ? (Table) dbEntityToTableMap.get(dbEntity) : null;
+        return (dbEntity != null) ? dbEntityToTableMap.get(dbEntity) : null;
     }
 
     protected Table getTable(ObjEntity objEntity) {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DataMap.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DataMap.java?rev=599363&r1=599362&r2=599363&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DataMap.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DataMap.java Thu Nov 29 02:06:07 2007
@@ -195,18 +195,14 @@
         DataMap clientMap = new DataMap(getName());
 
         // create client entities for entities
-        Iterator entities = getObjEntities().iterator();
-        while (entities.hasNext()) {
-            ObjEntity entity = (ObjEntity) entities.next();
+        for (ObjEntity entity : getObjEntities()) {
             if (entity.isClientAllowed()) {
                 clientMap.addObjEntity(entity.getClientEntity());
             }
         }
 
         // create proxies for named queries
-        Iterator queries = getQueries().iterator();
-        while (queries.hasNext()) {
-            Query q = (Query) queries.next();
+        for (Query q : getQueries()) {
             NamedQuery proxy = new NamedQuery(q.getName());
             proxy.setName(q.getName());
 
@@ -276,10 +272,7 @@
         encoder.print(getProcedureMap());
 
         // DbEntities
-        Iterator dbEntities = getDbEntityMap().entrySet().iterator();
-        while (dbEntities.hasNext()) {
-            Map.Entry entry = (Map.Entry) dbEntities.next();
-            DbEntity dbe = (DbEntity) entry.getValue();
+        for (DbEntity dbe : getDbEntityMap().values()) {
             dbe.encodeAsXML(encoder);
         }
 
@@ -290,8 +283,7 @@
         encoder.print(getQueryMap());
 
         // write entity listeners
-        for (Iterator i = getDefaultEntityListeners().iterator(); i.hasNext();) {
-            EntityListener entityListener = (EntityListener) i.next();
+        for (EntityListener entityListener : getDefaultEntityListeners()) {
             entityListener.encodeAsXML(encoder);
         }
 
@@ -299,17 +291,11 @@
         encoder.println("</data-map>");
     }
 
-    // stores relationships of for the map of entities
-    private final void encodeDBRelationshipsAsXML(Map entityMap, XMLEncoder encoder) {
-        Iterator it = entityMap.entrySet().iterator();
-        while (it.hasNext()) {
-            Map.Entry entry = (Map.Entry) it.next();
-            Entity entity = (Entity) entry.getValue();
-
-            // filter out synthetic
-            Iterator relationships = entity.getRelationships().iterator();
-            while (relationships.hasNext()) {
-                Relationship relationship = (Relationship) relationships.next();
+    // stores relationships for the map of entities
+    private final void encodeDBRelationshipsAsXML(Map<String, DbEntity> entityMap, XMLEncoder encoder) {
+        for (Entity entity : entityMap.values()) {
+            for (Relationship relationship : entity.getRelationships()) {
+                // filter out synthetic
                 if (!relationship.isRuntime()) {
                     relationship.encodeAsXML(encoder);
                 }
@@ -317,17 +303,11 @@
         }
     }
 
-    // stores relationships of for the map of entities
-    private final void encodeOBJRelationshipsAsXML(Map entityMap, XMLEncoder encoder) {
-        Iterator it = entityMap.entrySet().iterator();
-        while (it.hasNext()) {
-            Map.Entry entry = (Map.Entry) it.next();
-            ObjEntity entity = (ObjEntity) entry.getValue();
-
-            // filter out synthetic
-            Iterator relationships = entity.getDeclaredRelationships().iterator();
-            while (relationships.hasNext()) {
-                Relationship relationship = (Relationship) relationships.next();
+    // stores relationships for the map of entities
+    private final void encodeOBJRelationshipsAsXML(Map<String, ObjEntity> entityMap, XMLEncoder encoder) {
+        for (ObjEntity entity : entityMap.values()) {
+            for (Relationship relationship : entity.getDeclaredRelationships()) {
+                // filter out synthetic
                 if (!relationship.isRuntime()) {
                     relationship.encodeAsXML(encoder);
                 }
@@ -346,6 +326,9 @@
         return name;
     }
 
+    /**
+     * Set the name of this DataMap.
+     */
     public void setName(String name) {
         this.name = name;
     }
@@ -359,23 +342,17 @@
      * </p>
      */
     public void mergeWithDataMap(DataMap map) {
-        Iterator dbs = new ArrayList(map.getDbEntities()).iterator();
-        while (dbs.hasNext()) {
-            DbEntity ent = (DbEntity) dbs.next();
+        for (DbEntity ent : new ArrayList<DbEntity>(map.getDbEntities())) {
             this.removeDbEntity(ent.getName());
             this.addDbEntity(ent);
         }
 
-        Iterator objs = new ArrayList(map.getObjEntities()).iterator();
-        while (objs.hasNext()) {
-            ObjEntity ent = (ObjEntity) objs.next();
+        for (ObjEntity ent : new ArrayList<ObjEntity>(map.getObjEntities())) {
             this.removeObjEntity(ent.getName());
             this.addObjEntity(ent);
         }
 
-        Iterator queries = new ArrayList(map.getQueries()).iterator();
-        while (queries.hasNext()) {
-            Query query = (Query) queries.next();
+        for (Query query : new ArrayList<Query>(map.getQueries())) {
             this.removeQuery(query.getName());
             this.addQuery(query);
         }
@@ -419,7 +396,7 @@
      * @since 1.1
      */
     public Query getQuery(String queryName) {
-        Query query = (Query) queryMap.get(queryName);
+        Query query = queryMap.get(queryName);
         if (query != null) {
             return query;
         }
@@ -654,9 +631,7 @@
      *             registered.
      */
     public void addDefaultEntityListener(EntityListener listener) {
-        Iterator it = defaultEntityListeners.iterator();
-        while (it.hasNext()) {
-            EntityListener next = (EntityListener) it.next();
+         for (EntityListener next : defaultEntityListeners) {
             if (listener.getClassName().equals(next.getClassName())) {
                 throw new IllegalArgumentException("Duplicate default listener for "
                         + next.getClassName());
@@ -672,9 +647,9 @@
      * @since 3.0
      */
     public void removeDefaultEntityListener(String className) {
-        Iterator it = defaultEntityListeners.iterator();
+        Iterator<EntityListener> it = defaultEntityListeners.iterator();
         while (it.hasNext()) {
-            EntityListener next = (EntityListener) it.next();
+            EntityListener next = it.next();
             if (className.equals(next.getClassName())) {
                 it.remove();
                 break;
@@ -686,9 +661,9 @@
      * @since 3.0
      */
     public EntityListener getDefaultEntityListener(String className) {
-        for (EntityListener next : defaultEntityListeners) {
-            if (className.equals(next.getClassName())) {
-                return next;
+        for (EntityListener listener : defaultEntityListeners) {
+            if (className.equals(listener.getClassName())) {
+                return listener;
             }
         }
 
@@ -798,16 +773,12 @@
      * @since 1.1
      */
     public void removeDbEntity(String dbEntityName, boolean clearDependencies) {
-        DbEntity dbEntityToDelete = (DbEntity) dbEntityMap.remove(dbEntityName);
+        DbEntity dbEntityToDelete = dbEntityMap.remove(dbEntityName);
 
         if (dbEntityToDelete != null && clearDependencies) {
-            Iterator dbEnts = this.getDbEntities().iterator();
-            while (dbEnts.hasNext()) {
-                DbEntity dbEnt = (DbEntity) dbEnts.next();
-                // take a copy since we're going to modifiy the entity
-                Iterator rels = new ArrayList(dbEnt.getRelationships()).iterator();
-                while (rels.hasNext()) {
-                    DbRelationship rel = (DbRelationship) rels.next();
+            for (DbEntity dbEnt : this.getDbEntities()) {
+                // take a copy since we're going to modify the entity
+                for (Relationship rel : new ArrayList<Relationship>(dbEnt.getRelationships())) {
                     if (dbEntityName.equals(rel.getTargetEntityName())) {
                         dbEnt.removeRelationship(rel.getName());
                     }
@@ -815,21 +786,15 @@
             }
 
             // Remove all obj relationships referencing removed DbRelationships.
-            Iterator objEnts = this.getObjEntities().iterator();
-            while (objEnts.hasNext()) {
-                ObjEntity objEnt = (ObjEntity) objEnts.next();
+            for (ObjEntity objEnt : this.getObjEntities()) {
                 if (objEnt.getDbEntity() == dbEntityToDelete) {
                     objEnt.clearDbMapping();
                 }
                 else {
-                    Iterator iter = objEnt.getRelationships().iterator();
-                    while (iter.hasNext()) {
-                        ObjRelationship rel = (ObjRelationship) iter.next();
-                        Iterator dbRels = rel.getDbRelationships().iterator();
-                        while (dbRels.hasNext()) {
-                            DbRelationship dbRel = (DbRelationship) dbRels.next();
+                    for (Relationship rel : objEnt.getRelationships()) {
+                        for (DbRelationship dbRel : ((ObjRelationship)rel).getDbRelationships()) {
                             if (dbRel.getTargetEntity() == dbEntityToDelete) {
-                                rel.clearDbRelationships();
+                                ((ObjRelationship)rel).clearDbRelationships();
                                 break;
                             }
                         }
@@ -853,21 +818,17 @@
      * @since 1.1
      */
     public void removeObjEntity(String objEntityName, boolean clearDependencies) {
-        ObjEntity entity = (ObjEntity) objEntityMap.remove(objEntityName);
+        ObjEntity entity = objEntityMap.remove(objEntityName);
 
         if (entity != null && clearDependencies) {
 
             // remove relationships that point to this entity
-            Iterator entities = getObjEntities().iterator();
-            while (entities.hasNext()) {
-                ObjEntity ent = (ObjEntity) entities.next();
-                // take a copy since we're going to modifiy the entity
-                Iterator rels = new ArrayList(ent.getRelationships()).iterator();
-                while (rels.hasNext()) {
-                    ObjRelationship rel = (ObjRelationship) rels.next();
-                    if (objEntityName.equals(rel.getTargetEntityName())
-                            || objEntityName.equals(rel.getTargetEntityName())) {
-                        ent.removeRelationship(rel.getName());
+            for (ObjEntity ent : getObjEntities()) {
+                // take a copy since we're going to modify the entity
+                for (Relationship relationship : new ArrayList<Relationship>(ent.getRelationships())) {
+                    if (objEntityName.equals(relationship.getTargetEntityName())
+                            || objEntityName.equals(relationship.getTargetEntityName())) {
+                        ent.removeRelationship(relationship.getName());
                     }
                 }
             }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbAttribute.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbAttribute.java?rev=599363&r1=599362&r2=599363&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbAttribute.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbAttribute.java Thu Nov 29 02:06:07 2007
@@ -19,8 +19,6 @@
 
 package org.apache.cayenne.map;
 
-import java.util.Iterator;
-
 import org.apache.cayenne.dba.TypesMapping;
 import org.apache.cayenne.map.event.AttributeEvent;
 import org.apache.cayenne.map.event.DbAttributeListener;
@@ -175,11 +173,8 @@
             return false;
         }
 
-        Iterator relationships = getEntity().getRelationships().iterator();
-        while (relationships.hasNext()) {
-            DbRelationship relationship = (DbRelationship) relationships.next();
-
-            for (DbJoin join : relationship.getJoins()) {
+        for (Relationship relationship : getEntity().getRelationships()) {
+            for (DbJoin join : ((DbRelationship)relationship).getJoins()) {
                 if (name.equals(join.getSourceName())) {
                     DbAttribute target = join.getTarget();
                     if (target != null && target.isPrimaryKey()) {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbEntity.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbEntity.java?rev=599363&r1=599362&r2=599363&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbEntity.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbEntity.java Thu Nov 29 02:06:07 2007
@@ -27,7 +27,6 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.commons.collections.Transformer;
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.ObjectId;
 import org.apache.cayenne.exp.Expression;
@@ -43,6 +42,7 @@
 import org.apache.cayenne.util.CayenneMapEntry;
 import org.apache.cayenne.util.Util;
 import org.apache.cayenne.util.XMLEncoder;
+import org.apache.commons.collections.Transformer;
 
 /**
  * A DbEntity is a mapping descriptor that defines a structure of a database table.
@@ -202,15 +202,15 @@
 
         DataMap map = getDataMap();
         if (map != null) {
-            Iterator ents = map.getDbEntities().iterator();
+            Iterator<DbEntity> ents = map.getDbEntities().iterator();
             while (ents.hasNext()) {
-                DbEntity ent = (DbEntity) ents.next();
-                Iterator it = ent.getRelationships().iterator();
+                DbEntity ent = ents.next();
+                Iterator<Relationship> it = ent.getRelationships().iterator();
                 while (it.hasNext()) {
                     DbRelationship rel = (DbRelationship) it.next();
-                    Iterator joins = rel.getJoins().iterator();
+                    Iterator<DbJoin> joins = rel.getJoins().iterator();
                     while (joins.hasNext()) {
-                        DbJoin join = (DbJoin) joins.next();
+                        DbJoin join = joins.next();
                         if (join.getSource() == attr || join.getTarget() == attr) {
                             joins.remove();
                         }
@@ -229,7 +229,7 @@
         this.dbAttributeRemoved(new AttributeEvent(this, null, this, MapEvent.REMOVE));
     }
 
-    public Iterator resolvePathComponents(Expression pathExp) throws ExpressionException {
+    public Iterator<Object> resolvePathComponents(Expression pathExp) throws ExpressionException {
         if (pathExp.getType() != Expression.DB_PATH) {
             throw new ExpressionException("Invalid expression type: '"
                     + pathExp.expName()
@@ -269,21 +269,16 @@
             DataMap map = getDataMap();
             if (map != null) {
                 // handle all of the relationship target names that need to be changed
-                Iterator ents = map.getDbEntities().iterator();
-                while (ents.hasNext()) {
-                    DbEntity dbe = (DbEntity) ents.next();
-                    Iterator rit = dbe.getRelationships().iterator();
-                    while (rit.hasNext()) {
-                        DbRelationship rel = (DbRelationship) rit.next();
+                for (DbEntity dbe : map.getDbEntities()) {
+                    for (Relationship relationship : dbe.getRelationships()) {
+                        DbRelationship rel = (DbRelationship) relationship;
                         if (rel.getTargetEntity() == this) {
                             rel.setTargetEntityName(newName);
                         }
                     }
                 }
                 // get all of the related object entities
-                ents = map.getMappedEntities(this).iterator();
-                while (ents.hasNext()) {
-                    ObjEntity oe = (ObjEntity) ents.next();
+                for (ObjEntity oe : map.getMappedEntities(this)) {
                     if (oe.getDbEntity() == this) {
                         oe.setDbEntityName(newName);
                     }
@@ -342,17 +337,12 @@
 
             DataMap map = getDataMap();
             if (map != null) {
-                Iterator ents = map.getDbEntities().iterator();
-                while (ents.hasNext()) {
-                    DbEntity ent = (DbEntity) ents.next();
+                for (DbEntity ent : map.getDbEntities()) {
 
                     // handle all of the dependent object entity attribute changes
-                    Iterator it = map.getMappedEntities(ent).iterator();
-                    while (it.hasNext()) {
-                        ObjEntity oe = (ObjEntity) it.next();
-                        Iterator ait = oe.getAttributes().iterator();
-                        while (ait.hasNext()) {
-                            ObjAttribute oa = (ObjAttribute) ait.next();
+                    for (ObjEntity oe : map.getMappedEntities(ent)) {
+                        for (Attribute attr : oe.getAttributes()) {
+                            ObjAttribute oa = (ObjAttribute) attr;
                             if (oa.getDbAttribute() == dbAttribute) {
                                 oa.setDbAttributeName(newName);
                             }
@@ -361,12 +351,8 @@
 
                     // handle all of the relationships / joins that use the changed
                     // attribute
-                    it = ent.getRelationships().iterator();
-                    while (it.hasNext()) {
-                        DbRelationship rel = (DbRelationship) it.next();
-                        Iterator joins = rel.getJoins().iterator();
-                        while (joins.hasNext()) {
-                            DbJoin join = (DbJoin) joins.next();
+                    for (Relationship rel : ent.getRelationships()) {
+                        for (DbJoin join : ((DbRelationship)rel).getJoins()) {
                             if (join.getSource() == dbAttribute) {
                                 join.setSourceName(newName);
                             }
@@ -458,12 +444,9 @@
             if (map != null) {
                 // finds all object entities with a db relationship path to the renamed
                 // relationship
-                Iterator ents = map.getObjEntities().iterator();
-                while (ents.hasNext()) {
-                    ObjEntity oe = (ObjEntity) ents.next();
-                    Iterator rit = oe.getRelationships().iterator();
-                    while (rit.hasNext()) {
-                        ObjRelationship or = (ObjRelationship) rit.next();
+                for (ObjEntity oe : map.getObjEntities()) {
+                    for (Relationship relationship : oe.getRelationships()) {
+                        ObjRelationship or = (ObjRelationship) relationship;
                         // rename the db relationship path with the new name
                         if (Util.nullSafeEquals(or.getDbRelationshipPath(), oldName)) {
                             or.setDbRelationshipPath(newName);
@@ -501,15 +484,13 @@
             return false;
         }
 
-        Map replacement = id.getReplacementIdMap();
-        Collection pk = getPrimaryKeys();
+        Map<String, Object> replacement = id.getReplacementIdMap();
+        Collection<DbAttribute> pk = getPrimaryKeys();
         if (pk.size() != replacement.size()) {
             return false;
         }
 
-        Iterator it = pk.iterator();
-        while (it.hasNext()) {
-            DbAttribute attribute = (DbAttribute) it.next();
+        for (DbAttribute attribute : pk) {
             if (!replacement.containsKey(attribute.getName())) {
                 return false;
             }
@@ -582,8 +563,8 @@
             // case (1)
             if (path.equals(relationshipPath)) {
 
-                LinkedList finalPath = new LinkedList();
-                Iterator it = resolvePathComponents(path);
+                LinkedList<String> finalPath = new LinkedList<String>();
+                Iterator<Object> it = resolvePathComponents(path);
 
                 // just do one step back and one step forward to create correct joins...
                 // find last rel...
@@ -609,11 +590,11 @@
             }
 
             // case (3)
-            Iterator pathIt = resolvePathComponents(path);
-            Iterator relationshipIt = resolvePathComponents(relationshipPath);
+            Iterator<Object> pathIt = resolvePathComponents(path);
+            Iterator<Object> relationshipIt = resolvePathComponents(relationshipPath);
 
             // for inserts from the both ends use LinkedList
-            LinkedList finalPath = new LinkedList();
+            LinkedList<String> finalPath = new LinkedList<String>();
 
             while (relationshipIt.hasNext() && pathIt.hasNext()) {
                 // relationship path components must be DbRelationships
@@ -625,7 +606,7 @@
                 if (nextDBR != next) {
                     // found split point
                     // consume the last iteration components,
-                    // then break out to finish the iterators independenly
+                    // then break out to finish the iterators independently
                     prependReversedPath(finalPath, nextDBR);
                     appendPath(finalPath, next);
                     break;
@@ -649,7 +630,7 @@
             return convertToPath(finalPath);
         }
 
-        private String convertToPath(List path) {
+        private String convertToPath(List<String> path) {
             StringBuffer converted = new StringBuffer();
             int len = path.size();
             for (int i = 0; i < len; i++) {
@@ -663,7 +644,7 @@
             return converted.toString();
         }
 
-        private void prependReversedPath(LinkedList finalPath, DbRelationship relationship) {
+        private void prependReversedPath(LinkedList<String> finalPath, DbRelationship relationship) {
             DbRelationship revNextDBR = relationship.getReverseRelationship();
 
             if (revNextDBR == null) {
@@ -678,7 +659,7 @@
             finalPath.addFirst(revNextDBR.getName());
         }
 
-        private void appendPath(LinkedList finalPath, CayenneMapEntry pathComponent) {
+        private void appendPath(LinkedList<String> finalPath, CayenneMapEntry pathComponent) {
             finalPath.addLast(pathComponent.getName());
         }
     }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbJoin.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbJoin.java?rev=599363&r1=599362&r2=599363&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbJoin.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbJoin.java Thu Nov 29 02:06:07 2007
@@ -19,10 +19,10 @@
 
 package org.apache.cayenne.map;
 
-import org.apache.commons.lang.builder.ToStringBuilder;
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.util.XMLEncoder;
 import org.apache.cayenne.util.XMLSerializable;
+import org.apache.commons.lang.builder.ToStringBuilder;
 
 /**
  * Defines a join between two attributes of a given relationship.

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbRelationship.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbRelationship.java?rev=599363&r1=599362&r2=599363&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbRelationship.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbRelationship.java Thu Nov 29 02:06:07 2007
@@ -23,18 +23,17 @@
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.collections.Transformer;
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.event.EventManager;
 import org.apache.cayenne.event.EventSubject;
 import org.apache.cayenne.map.event.RelationshipEvent;
 import org.apache.cayenne.util.Util;
 import org.apache.cayenne.util.XMLEncoder;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections.Transformer;
 
 /**
  * A DbRelationship is a descriptor of a database inter-table relationship based on one or
@@ -115,7 +114,7 @@
      * 
      * @since 1.1
      */
-    public Collection getTargetAttributes() {
+    public Collection<DbAttribute> getTargetAttributes() {
         if (joins.size() == 0) {
             return Collections.EMPTY_LIST;
         }
@@ -128,7 +127,7 @@
      * 
      * @since 1.1
      */
-    public Collection getSourceAttributes() {
+    public Collection<DbAttribute> getSourceAttributes() {
         if (joins.size() == 0) {
             return Collections.EMPTY_LIST;
         }
@@ -152,9 +151,7 @@
 
         reverse.setToMany(!toMany);
 
-        Iterator it = joins.iterator();
-        while (it.hasNext()) {
-            DbJoin join = (DbJoin) it.next();
+        for (DbJoin join : joins) {
             DbJoin reverseJoin = join.createReverseJoin();
             reverseJoin.setRelationship(reverse);
             reverse.addJoin(reverseJoin);
@@ -183,22 +180,17 @@
         }
 
         TestJoin testJoin = new TestJoin(this);
-        Iterator it = target.getRelationships().iterator();
-        while (it.hasNext()) {
-            DbRelationship rel = (DbRelationship) it.next();
+        for (Relationship rel : target.getRelationships()) {
             if (rel.getTargetEntity() != src)
                 continue;
 
-            List otherJoins = rel.getJoins();
+            List<DbJoin> otherJoins = ((DbRelationship)rel).getJoins();
             if (otherJoins.size() != joins.size()) {
                 continue;
             }
 
-            Iterator jit = otherJoins.iterator();
             boolean joinsMatch = true;
-            while (jit.hasNext()) {
-                DbJoin join = (DbJoin) jit.next();
-
+            for (DbJoin join : otherJoins) {
                 // flip join and try to find similar
                 testJoin.setSourceName(join.getTargetName());
                 testJoin.setTargetName(join.getSourceName());
@@ -209,7 +201,7 @@
             }
 
             if (joinsMatch) {
-                return rel;
+                return (DbRelationship) rel;
             }
         }
 
@@ -223,9 +215,7 @@
      * @since 1.1
      */
     public boolean isToPK() {
-        Iterator it = getJoins().iterator();
-        while (it.hasNext()) {
-            DbJoin join = (DbJoin) it.next();
+        for (DbJoin join : getJoins()) {
             if (join.getTarget() == null) {
                 return false;
             }
@@ -271,14 +261,12 @@
      * @since 1.1
      */
     public boolean isValidForDepPk() {
-        Iterator it = getJoins().iterator();
         // handle case with no joins
-        if (!it.hasNext()) {
+        if (getJoins().size() == 0) {
             return false;
         }
 
-        while (it.hasNext()) {
-            DbJoin join = (DbJoin) it.next();
+        for (DbJoin join : getJoins()) {
             DbAttribute target = join.getTarget();
             DbAttribute source = join.getSource();
 
@@ -318,7 +306,7 @@
         joins.clear();
     }
 
-    public void setJoins(Collection newJoins) {
+    public void setJoins(Collection<DbJoin> newJoins) {
         this.removeAllJoins();
 
         if (newJoins != null) {
@@ -347,7 +335,7 @@
 
         // optimize for the most common single column join
         if (numJoins == 1) {
-            DbJoin join = (DbJoin) joins.get(0);
+            DbJoin join = joins.get(0);
             Object val = srcSnapshot.get(join.getSourceName());
             if (val == null) {
                 foundNulls++;
@@ -361,7 +349,7 @@
         else {
             idMap = new HashMap<String, Object>(numJoins * 2);
             for (int i = 0; i < numJoins; i++) {
-                DbJoin join = (DbJoin) joins.get(i);
+                DbJoin join = joins.get(i);
                 DbAttribute source = join.getSource();
                 Object val = srcSnapshot.get(join.getSourceName());
 
@@ -398,21 +386,20 @@
      * Common code to srcSnapshotWithTargetSnapshot. Both are functionally the same,
      * except for the name, and whether they operate on a toMany or a toOne.
      */
-    private Map srcSnapshotWithTargetSnapshot(Map targetSnapshot) {
+    private Map<String, Object> srcSnapshotWithTargetSnapshot(Map<String, Object> targetSnapshot) {
         int len = joins.size();
 
         // optimize for the most common single column join
         if (len == 1) {
-            DbJoin join = (DbJoin) joins.get(0);
+            DbJoin join = joins.get(0);
             Object val = targetSnapshot.get(join.getTargetName());
             return Collections.singletonMap(join.getSourceName(), val);
-
         }
 
         // general case
-        Map idMap = new HashMap(len * 2);
+        Map<String, Object> idMap = new HashMap<String, Object>(len * 2);
         for (int i = 0; i < len; i++) {
-            DbJoin join = (DbJoin) joins.get(i);
+            DbJoin join = joins.get(i);
             Object val = targetSnapshot.get(join.getTargetName());
             idMap.put(join.getSourceName(), val);
         }
@@ -425,7 +412,7 @@
      * relationship based on a snapshot of a target. Only "to-one" relationships are
      * supported. Throws CayenneRuntimeException if relationship is "to many".
      */
-    public Map srcFkSnapshotWithTargetSnapshot(Map targetSnapshot) {
+    public Map<String, Object> srcFkSnapshotWithTargetSnapshot(Map<String, Object> targetSnapshot) {
 
         if (isToMany()) {
             throw new CayenneRuntimeException(
@@ -440,7 +427,7 @@
      * relationship based on a snapshot of a target. Only "to-many" relationships are
      * supported. Throws CayenneRuntimeException if relationship is "to one".
      */
-    public Map srcPkSnapshotWithTargetSnapshot(Map targetSnapshot) {
+    public Map<String, Object> srcPkSnapshotWithTargetSnapshot(Map<String, Object> targetSnapshot) {
         if (!isToMany())
             throw new CayenneRuntimeException(
                     "Only 'to many' relationships support this method.");

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/Embeddable.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/Embeddable.java?rev=599363&r1=599362&r2=599363&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/Embeddable.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/Embeddable.java Thu Nov 29 02:06:07 2007
@@ -109,7 +109,7 @@
     }
 
     public EmbeddableAttribute getAttribute(String name) {
-        return (EmbeddableAttribute) attributes.get(name);
+        return attributes.get(name);
     }
 
     public void removeAttribute(String name) {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/EmbeddedAttribute.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/EmbeddedAttribute.java?rev=599363&r1=599362&r2=599363&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/EmbeddedAttribute.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/EmbeddedAttribute.java Thu Nov 29 02:06:07 2007
@@ -98,7 +98,7 @@
     }
 
     private ObjAttribute makeObjAttribute(EmbeddableAttribute embeddableAttribute) {
-        String dbPath = (String) attributeOverrides.get(embeddableAttribute.getName());
+        String dbPath = attributeOverrides.get(embeddableAttribute.getName());
         if (dbPath == null) {
             dbPath = embeddableAttribute.getDbAttributeName();
         }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/Entity.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/Entity.java?rev=599363&r1=599362&r2=599363&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/Entity.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/Entity.java Thu Nov 29 02:06:07 2007
@@ -47,8 +47,8 @@
     protected String name;
     protected DataMap dataMap;
 
-    protected SortedMap attributes;
-    protected SortedMap relationships;
+    protected SortedMap<String, Attribute> attributes;
+    protected SortedMap<String, Relationship> relationships;
 
     /**
      * Creates an unnamed Entity.
@@ -61,12 +61,13 @@
      * Creates a named Entity.
      */
     public Entity(String name) {
-        this.attributes = new TreeMap();
-        this.relationships = new TreeMap();
+        attributes = new TreeMap<String, Attribute>();
+        relationships = new TreeMap<String, Relationship>();
 
         setName(name);
     }
-    
+
+    @Override
     public String toString() {
         return new ToStringBuilder(this).append("name", getName()).toString();
     }
@@ -87,9 +88,8 @@
     }
 
     public void setParent(Object parent) {
-        if (parent != null && !(parent instanceof DataMap)) {
+        if (parent != null && !(parent instanceof DataMap))
             throw new IllegalArgumentException("Expected null or DataMap, got: " + parent);
-        }
 
         setDataMap((DataMap) parent);
     }
@@ -113,7 +113,7 @@
      * with this name exists.
      */
     public Attribute getAttribute(String attributeName) {
-        return (Attribute) attributes.get(attributeName);
+        return attributes.get(attributeName);
     }
 
     /**
@@ -121,9 +121,8 @@
      * attribute has no name, IllegalArgumentException is thrown.
      */
     public void addAttribute(Attribute attribute) {
-        if (attribute.getName() == null) {
+        if (attribute.getName() == null)
             throw new IllegalArgumentException("Attempt to insert unnamed attribute.");
-        }
 
         // block overrides
 
@@ -131,24 +130,22 @@
         // Modeler handles it...
         Object existingAttribute = attributes.get(attribute.getName());
         if (existingAttribute != null) {
-            if (existingAttribute == attribute) {
+            if (existingAttribute == attribute)
                 return;
-            }
-            else {
-                throw new IllegalArgumentException("An attempt to override attribute '"
-                        + attribute.getName()
-                        + "'");
-            }
+            else
+                throw new IllegalArgumentException("An attempt to override attribute '" +
+                        attribute.getName() +
+                        "'");
         }
-        
-        // Check that there aren't any relationships with the same name as the given attribute.
+
+        // Check that there aren't any relationships with the same name as the given
+        // attribute.
         Object existingRelationship = relationships.get(attribute.getName());
-        if (existingRelationship != null) {            
+        if (existingRelationship != null)
             throw new IllegalArgumentException(
-                    "Attribute name conflict with existing relationship '"
-                            + attribute.getName()
-                            + "'");
-        }
+                    "Attribute name conflict with existing relationship '" +
+                            attribute.getName() +
+                            "'");
 
         attributes.put(attribute.getName(), attribute);
         attribute.setEntity(this);
@@ -168,14 +165,13 @@
      * relationship with this name exists in the entity.
      */
     public Relationship getRelationship(String relName) {
-        return (Relationship) relationships.get(relName);
+        return relationships.get(relName);
     }
 
     /** Adds new relationship to the entity. */
     public void addRelationship(Relationship relationship) {
-        if (relationship.getName() == null) {
+        if (relationship.getName() == null)
             throw new IllegalArgumentException("Attempt to insert unnamed relationship.");
-        }
 
         // block overrides
 
@@ -183,25 +179,23 @@
         // Modeler handles it...
         Object existingRelationship = relationships.get(relationship.getName());
         if (existingRelationship != null) {
-            if (existingRelationship == relationship) {
+            if (existingRelationship == relationship)
                 return;
-            }
-            else {
+            else
                 throw new IllegalArgumentException(
-                        "An attempt to override relationship '"
-                                + relationship.getName()
-                                + "'");
-            }
+                        "An attempt to override relationship '" +
+                                relationship.getName() +
+                                "'");
         }
-        
-        // Check that there aren't any attributes with the same name as the given relationship.
+
+        // Check that there aren't any attributes with the same name as the given
+        // relationship.
         Object existingAttribute = attributes.get(relationship.getName());
-        if (existingAttribute != null) {
+        if (existingAttribute != null)
             throw new IllegalArgumentException(
-                    "Relationship name conflict with existing attribute '"
-                            + relationship.getName()
-                            + "'");
-        }
+                    "Relationship name conflict with existing attribute '" +
+                            relationship.getName() +
+                            "'");
 
         relationships.put(relationship.getName(), relationship);
         relationship.setSourceEntity(this);
@@ -219,7 +213,7 @@
     /**
      * Returns an unmodifiable map of relationships sorted by name.
      */
-    public SortedMap<String,Relationship> getRelationshipMap() {
+    public SortedMap<String, Relationship> getRelationshipMap() {
         // create a new instance ... earlier attempts to cache it in the entity caused
         // serialization issues (esp. with Hessian).
         return Collections.unmodifiableSortedMap(relationships);
@@ -233,16 +227,12 @@
      * @since 1.1
      */
     public Relationship getAnyRelationship(Entity targetEntity) {
-        if (getRelationships().isEmpty()) {
+        if (getRelationships().isEmpty())
             return null;
-        }
 
-        Iterator it = getRelationships().iterator();
-        while (it.hasNext()) {
-            Relationship r = (Relationship) it.next();
-            if (r.getTargetEntity() == targetEntity) {
+        for (Relationship r : getRelationships()) {
+            if (r.getTargetEntity() == targetEntity)
                 return r;
-            }
         }
         return null;
     }
@@ -292,7 +282,7 @@
      */
     public Object lastPathComponent(Expression pathExp) {
         Object last = null;
-        Iterator it = resolvePathComponents(pathExp);
+        Iterator<Object> it = resolvePathComponents(pathExp);
         while (it.hasNext()) {
             last = it.next();
         }
@@ -307,7 +297,7 @@
      * return an Iterator, but an attempt to read the first invalid path component will
      * result in ExpressionException.
      */
-    public abstract Iterator resolvePathComponents(Expression pathExp)
+    public abstract Iterator<Object> resolvePathComponents(Expression pathExp)
             throws ExpressionException;
 
     /**
@@ -316,13 +306,13 @@
      * entity, this method will still return an Iterator, but an attempt to read the first
      * invalid path component will result in ExpressionException.
      */
-    public Iterator resolvePathComponents(String path) throws ExpressionException {
+    public Iterator<Object> resolvePathComponents(String path) throws ExpressionException {
         return new PathIterator(path);
     }
 
     // An iterator resolving mapping components represented by the path string.
     // This entity is assumed to be the root of the path.
-    final class PathIterator implements Iterator {
+    final class PathIterator implements Iterator<Object> {
 
         private StringTokenizer toks;
         private Entity currentEnt;
@@ -330,8 +320,8 @@
 
         PathIterator(String path) {
             super();
-            this.currentEnt = Entity.this;
-            this.toks = new StringTokenizer(path, PATH_SEPARATOR);
+            currentEnt = Entity.this;
+            toks = new StringTokenizer(path, PATH_SEPARATOR);
             this.path = path;
         }
 
@@ -346,14 +336,13 @@
             Attribute attr = currentEnt.getAttribute(pathComp);
             if (attr != null) {
                 // do a sanity check...
-                if (toks.hasMoreTokens()) {
+                if (toks.hasMoreTokens())
                     throw new ExpressionException(
-                            "Attribute must be the last component of the path: '"
-                                    + pathComp
-                                    + "'.",
+                            "Attribute must be the last component of the path: '" +
+                                    pathComp +
+                                    "'.",
                             path,
                             null);
-                }
 
                 return attr;
             }
@@ -383,11 +372,10 @@
 
     final MappingNamespace getNonNullNamespace() {
         MappingNamespace parent = getDataMap();
-        if (parent == null) {
-            throw new CayenneRuntimeException("Entity '"
-                    + getName()
-                    + "' has no parent MappingNamespace (such as DataMap)");
-        }
+        if (parent == null)
+            throw new CayenneRuntimeException("Entity '" +
+                    getName() +
+                    "' has no parent MappingNamespace (such as DataMap)");
 
         return parent;
     }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/EntityInheritanceTree.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/EntityInheritanceTree.java?rev=599363&r1=599362&r2=599363&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/EntityInheritanceTree.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/EntityInheritanceTree.java Thu Nov 29 02:06:07 2007
@@ -22,7 +22,6 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.Iterator;
 
 import org.apache.cayenne.DataRow;
 import org.apache.cayenne.exp.Expression;
@@ -36,7 +35,7 @@
  */
 public class EntityInheritanceTree {
     protected ObjEntity entity;
-    protected Collection subentities;
+    protected Collection<EntityInheritanceTree> subentities;
     protected Expression normalizedQualifier;
 
     public EntityInheritanceTree(ObjEntity entity) {
@@ -56,9 +55,7 @@
         }
 
         if (subentities != null) {
-            Iterator it = subentities.iterator();
-            while (it.hasNext()) {
-                EntityInheritanceTree child = (EntityInheritanceTree) it.next();
+            for (EntityInheritanceTree child : subentities) {
                 Expression childQualifier = child.qualifierForEntityAndSubclasses();
 
                 // if any child qualifier is null, just return null, since no filtering is possible
@@ -80,9 +77,7 @@
     public ObjEntity entityMatchingRow(DataRow row) {
         // match depth first
         if (subentities != null) {
-            Iterator it = subentities.iterator();
-            while (it.hasNext()) {
-                EntityInheritanceTree child = (EntityInheritanceTree) it.next();
+            for (EntityInheritanceTree child : subentities) {
                 ObjEntity matched = child.entityMatchingRow(row);
 
                 if (matched != null) {
@@ -106,7 +101,7 @@
 
     public void addChildNode(EntityInheritanceTree node) {
         if (subentities == null) {
-            subentities = new ArrayList(2);
+            subentities = new ArrayList<EntityInheritanceTree>(2);
         }
 
         subentities.add(node);
@@ -116,7 +111,7 @@
         return (subentities != null) ? subentities.size() : 0;
     }
 
-    public Collection getChildren() {
+    public Collection<EntityInheritanceTree> getChildren() {
         return (subentities != null) ? subentities : Collections.EMPTY_LIST;
     }
 
@@ -124,12 +119,12 @@
         return entity;
     }
 
-    public Collection allAttributes() {
+    public Collection<Attribute> allAttributes() {
         if (subentities == null) {
             return entity.getAttributes();
         }
 
-        Collection c = new ArrayList();
+        Collection<Attribute> c = new ArrayList<Attribute>();
         appendDeclaredAttributes(c);
 
         // add base attributes if any
@@ -141,12 +136,12 @@
         return c;
     }
 
-    public Collection allRelationships() {
+    public Collection<Relationship> allRelationships() {
         if (subentities == null) {
             return entity.getRelationships();
         }
 
-        Collection c = new ArrayList();
+        Collection<Relationship> c = new ArrayList<Relationship>();
         appendDeclaredRelationships(c);
 
         // add base relationships if any
@@ -158,25 +153,21 @@
         return c;
     }
 
-    protected void appendDeclaredAttributes(Collection c) {
+    protected void appendDeclaredAttributes(Collection<Attribute> c) {
         c.addAll(entity.getDeclaredAttributes());
 
         if (subentities != null) {
-            Iterator it = subentities.iterator();
-            while (it.hasNext()) {
-                EntityInheritanceTree child = (EntityInheritanceTree) it.next();
+            for (EntityInheritanceTree child : subentities) {
                 child.appendDeclaredAttributes(c);
             }
         }
     }
 
-    protected void appendDeclaredRelationships(Collection c) {
+    protected void appendDeclaredRelationships(Collection<Relationship> c) {
         c.addAll(entity.getDeclaredRelationships());
 
         if (subentities != null) {
-            Iterator it = subentities.iterator();
-            while (it.hasNext()) {
-                EntityInheritanceTree child = (EntityInheritanceTree) it.next();
+            for (EntityInheritanceTree child : subentities) {
                 child.appendDeclaredRelationships(c);
             }
         }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/EntityListener.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/EntityListener.java?rev=599363&r1=599362&r2=599363&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/EntityListener.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/EntityListener.java Thu Nov 29 02:06:07 2007
@@ -18,10 +18,10 @@
  ****************************************************************/
 package org.apache.cayenne.map;
 
+import java.io.Serializable;
+
 import org.apache.cayenne.util.XMLEncoder;
 import org.apache.cayenne.util.XMLSerializable;
-
-import java.io.Serializable;
 
 /**
  * A mapping descriptor of an entity listener class that declares one or more callback

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/EntityResolver.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/EntityResolver.java?rev=599363&r1=599362&r2=599363&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/EntityResolver.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/EntityResolver.java Thu Nov 29 02:06:07 2007
@@ -312,13 +312,13 @@
      * @since 3.0
      */
     public Embeddable getEmbeddable(String className) {
-        Embeddable result = (Embeddable) embeddableCache.get(className);
+        Embeddable result = embeddableCache.get(className);
 
         if (result == null) {
             // reconstruct cache just in case some of the datamaps
             // have changed and now contain the required information
             constructCache();
-            result = (Embeddable) embeddableCache.get(className);
+            result = embeddableCache.get(className);
         }
 
         return result;
@@ -435,7 +435,7 @@
 
                 // build inheritance tree... include nodes that
                 // have no children to avoid unneeded cache rebuilding on lookup...
-                EntityInheritanceTree node = (EntityInheritanceTree) entityInheritanceCache
+                EntityInheritanceTree node = entityInheritanceCache
                         .get(oe.getName());
                 if (node == null) {
                     node = new EntityInheritanceTree(oe);
@@ -444,12 +444,12 @@
 
                 String superOEName = oe.getSuperEntityName();
                 if (superOEName != null) {
-                    EntityInheritanceTree superNode = (EntityInheritanceTree) entityInheritanceCache
+                    EntityInheritanceTree superNode = entityInheritanceCache
                             .get(superOEName);
 
                     if (superNode == null) {
                         // do direct entity lookup to avoid recursive cache rebuild
-                        ObjEntity superOE = (ObjEntity) objEntityCache.get(superOEName);
+                        ObjEntity superOE = objEntityCache.get(superOEName);
                         if (superOE != null) {
                             superNode = new EntityInheritanceTree(superOE);
                             entityInheritanceCache.put(superOEName, superNode);
@@ -529,7 +529,7 @@
      */
     public EntityInheritanceTree lookupInheritanceTree(ObjEntity entity) {
 
-        EntityInheritanceTree tree = (EntityInheritanceTree) entityInheritanceCache
+        EntityInheritanceTree tree = entityInheritanceCache
                 .get(entity.getName());
 
         if (tree == null) {
@@ -539,7 +539,7 @@
             // rebuild cache just in case some of the datamaps
             // have changed and now contain the required information
             constructCache();
-            tree = (EntityInheritanceTree) entityInheritanceCache.get(entity.getName());
+            tree = entityInheritanceCache.get(entity.getName());
         }
 
         // don't return "trivial" trees
@@ -601,12 +601,12 @@
 
     public Procedure lookupProcedure(String procedureName) {
 
-        Procedure result = (Procedure) procedureCache.get(procedureName);
+        Procedure result = procedureCache.get(procedureName);
         if (result == null) {
             // reconstruct cache just in case some of the datamaps
             // have changed and now contain the required information
             constructCache();
-            result = (Procedure) procedureCache.get(procedureName);
+            result = procedureCache.get(procedureName);
         }
 
         return result;
@@ -616,13 +616,13 @@
      * Returns a named query or null if no query exists for a given name.
      */
     public synchronized Query lookupQuery(String name) {
-        Query result = (Query) queryCache.get(name);
+        Query result = queryCache.get(name);
 
         if (result == null) {
             // reconstruct cache just in case some of the datamaps
             // have changed and now contain the required information
             constructCache();
-            result = (Query) queryCache.get(name);
+            result = queryCache.get(name);
         }
         return result;
     }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjAttribute.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjAttribute.java?rev=599363&r1=599362&r2=599363&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjAttribute.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjAttribute.java Thu Nov 29 02:06:07 2007
@@ -56,7 +56,7 @@
      * Returns Java class of an object property described by this attribute. Wraps any
      * thrown exceptions into CayenneRuntimeException.
      */
-    public Class getJavaClass() {
+    public Class<?> getJavaClass() {
         if (this.getType() == null) {
             return null;
         }
@@ -138,7 +138,7 @@
      * Returns a DbAttribute mapped by this ObjAttribute.
      */
     public DbAttribute getDbAttribute() {
-        Iterator pathIterator = getDbPathIterator();
+        Iterator<Object> pathIterator = getDbPathIterator();
         Object o = null;
         while (pathIterator.hasNext()) {
             o = pathIterator.next();
@@ -146,7 +146,7 @@
         return (DbAttribute) o;
     }
 
-    public Iterator getDbPathIterator() {
+    public Iterator<Object> getDbPathIterator() {
         if (dbAttributePath == null) {
             return IteratorUtils.EMPTY_ITERATOR;
         }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjEntity.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjEntity.java?rev=599363&r1=599362&r2=599363&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjEntity.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjEntity.java Thu Nov 29 02:06:07 2007
@@ -198,17 +198,12 @@
         // TODO: should we also copy lock type?
 
         // copy attributes
-        Iterator attributes = getDeclaredAttributes().iterator();
-        while (attributes.hasNext()) {
-            ObjAttribute attribute = (ObjAttribute) attributes.next();
-            entity.addAttribute(attribute.getClientAttribute());
+        for (Attribute attribute : getDeclaredAttributes()) {
+            entity.addAttribute(((ObjAttribute)attribute).getClientAttribute());
         }
 
         // copy relationships; skip runtime generated relationships
-        Iterator relationships = getDeclaredRelationships().iterator();
-        while (relationships.hasNext()) {
-            ObjRelationship relationship = (ObjRelationship) relationships.next();
-
+        for (Relationship relationship : getDeclaredRelationships()) {
             if (relationship.isRuntime()) {
                 continue;
             }
@@ -220,7 +215,7 @@
                 continue;
             }
 
-            entity.addRelationship(relationship.getClientRelationship());
+            entity.addRelationship(((ObjRelationship)relationship).getClientRelationship());
         }
 
         // TODO: andrus 2/5/2007 - copy embeddables
@@ -767,18 +762,16 @@
         if (dbEntityName == null)
             return;
 
-        Iterator it = getAttributeMap().values().iterator();
-        while (it.hasNext()) {
-            ObjAttribute objAttr = (ObjAttribute) it.next();
+        for (Attribute attribute : getAttributeMap().values()) {
+            ObjAttribute objAttr = (ObjAttribute) attribute;
             DbAttribute dbAttr = objAttr.getDbAttribute();
             if (null != dbAttr) {
                 objAttr.setDbAttribute(null);
             }
         }
 
-        Iterator rels = this.getRelationships().iterator();
-        while (rels.hasNext()) {
-            ((ObjRelationship) rels.next()).clearDbRelationships();
+        for (Relationship relationship : this.getRelationships()) {
+            ((ObjRelationship) relationship).clearDbRelationships();
         }
 
         dbEntityName = null;
@@ -821,7 +814,7 @@
         return (superEntity != null) ? superEntity.isSubentityOf(entity) : false;
     }
 
-    public Iterator resolvePathComponents(Expression pathExp) throws ExpressionException {
+    public Iterator<Object> resolvePathComponents(Expression pathExp) throws ExpressionException {
 
         // resolve DB_PATH if we can
         if (pathExp.getType() == Expression.DB_PATH) {
@@ -905,12 +898,12 @@
 
         // TODO: make it a public method - resolveDBPathComponents or something...
         // seems generally useful
-        String toDbPath(Iterator objectPathComponents) {
+        String toDbPath(Iterator<Object> objectPathComponents) {
             StringBuffer buf = new StringBuffer();
             while (objectPathComponents.hasNext()) {
                 Object component = objectPathComponents.next();
 
-                Iterator dbSubpath;
+                Iterator<?> dbSubpath;
 
                 if (component instanceof ObjRelationship) {
                     dbSubpath = ((ObjRelationship) component)
@@ -998,12 +991,10 @@
             DataMap map = getDataMap();
             if (map != null) {
                 ObjEntity oe = (ObjEntity) e.getEntity();
-                Iterator rit = oe.getRelationships().iterator();
-                while (rit.hasNext()) {
-                    ObjRelationship or = (ObjRelationship) rit.next();
-                    or = or.getReverseRelationship();
-                    if (null != or && or.targetEntityName.equals(oldName)) {
-                        or.targetEntityName = newName;
+                for (Relationship relationship : oe.getRelationships()) {
+                    relationship = ((ObjRelationship)relationship).getReverseRelationship();
+                    if (null != relationship && relationship.targetEntityName.equals(oldName)) {
+                        relationship.targetEntityName = newName;
                     }
                 }
             }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjRelationship.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjRelationship.java?rev=599363&r1=599362&r2=599363&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjRelationship.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjRelationship.java Thu Nov 29 02:06:07 2007
@@ -248,7 +248,7 @@
         // on the flattened path
         int numDbRelationships = dbRelationships.size();
         if (numDbRelationships > 0) {
-            DbRelationship lastRel = (DbRelationship) dbRelationships
+            DbRelationship lastRel = dbRelationships
                     .get(numDbRelationships - 1);
             if (!lastRel.getTargetEntityName().equals(dbRel.getSourceEntity().getName())) {
                 throw new CayenneRuntimeException("Error adding db relationship "
@@ -296,7 +296,7 @@
                 StringBuffer path = new StringBuffer();
 
                 for (int i = 0; i < dbRelationships.size(); i++) {
-                    DbRelationship r = (DbRelationship) dbRelationships.get(i);
+                    DbRelationship r = dbRelationships.get(i);
                     if (i > 0) {
                         path.append('.');
                     }
@@ -343,7 +343,7 @@
      * Returns true if underlying DbRelationships point to dependent entity.
      */
     public boolean isToDependentEntity() {
-        return ((DbRelationship) getDbRelationships().get(0)).isToDependentPK();
+        return (getDbRelationships().get(0)).isToDependentPK();
     }
 
     /**
@@ -353,7 +353,7 @@
      * @since 1.1
      */
     public boolean isToPK() {
-        return ((DbRelationship) getDbRelationships().get(0)).isToPK();
+        return (getDbRelationships().get(0)).isToPK();
     }
 
     /**
@@ -459,9 +459,9 @@
             }
 
             StringBuffer path = new StringBuffer();
-            Iterator it = getDbRelationships().iterator();
+            Iterator<DbRelationship> it = getDbRelationships().iterator();
             while (it.hasNext()) {
-                DbRelationship next = (DbRelationship) it.next();
+                DbRelationship next = it.next();
                 path.append(next.getName());
                 if (it.hasNext()) {
                     path.append(Entity.PATH_SEPARATOR);
@@ -479,7 +479,7 @@
      */
     public String getReverseDbRelationshipPath() throws ExpressionException {
 
-        List relationships = getDbRelationships();
+        List<DbRelationship> relationships = getDbRelationships();
         if (relationships == null || relationships.isEmpty()) {
             return null;
         }
@@ -487,10 +487,10 @@
         StringBuffer buffer = new StringBuffer();
 
         // iterate in reverse order
-        ListIterator it = relationships.listIterator(relationships.size());
+        ListIterator<DbRelationship> it = relationships.listIterator(relationships.size());
         while (it.hasPrevious()) {
 
-            DbRelationship relationship = (DbRelationship) it.previous();
+            DbRelationship relationship = it.previous();
             DbRelationship reverse = relationship.getReverseRelationship();
 
             // another sanity check
@@ -538,7 +538,7 @@
         StringBuffer validPath = new StringBuffer();
 
         try {
-            Iterator it = entity.resolvePathComponents(new ASTDbPath(path));
+            Iterator<Object> it = entity.resolvePathComponents(new ASTDbPath(path));
             while (it.hasNext()) {
                 DbRelationship relationship = (DbRelationship) it.next();
 
@@ -572,9 +572,9 @@
             EventManager eventLoop = EventManager.getDefaultManager();
 
             // remove existing relationships
-            Iterator removeIt = dbRelationships.iterator();
+            Iterator<DbRelationship> removeIt = dbRelationships.iterator();
             while (removeIt.hasNext()) {
-                DbRelationship relationship = (DbRelationship) removeIt.next();
+                DbRelationship relationship = removeIt.next();
                 eventLoop.removeListener(
                         this,
                         DbRelationship.PROPERTY_DID_CHANGE,
@@ -593,7 +593,7 @@
 
                 try {
                     // add new relationships from path
-                    Iterator it = entity.resolvePathComponents(new ASTDbPath(
+                    Iterator<Object> it = entity.resolvePathComponents(new ASTDbPath(
                             this.dbRelationshipPath));
 
                     while (it.hasNext()) {
@@ -633,9 +633,7 @@
         // rel is toMany. If all are toOne, then the rel is toOne.
         // Simple (non-flattened) relationships form the degenerate case
         // taking the value of the single underlying dbrel.
-        Iterator dbRelIterator = this.dbRelationships.iterator();
-        while (dbRelIterator.hasNext()) {
-            DbRelationship thisRel = (DbRelationship) dbRelIterator.next();
+        for (DbRelationship thisRel : this.dbRelationships) {
             if (thisRel.isToMany()) {
                 this.toMany = true;
                 return;
@@ -661,8 +659,8 @@
             return;
         }
 
-        DbRelationship firstRel = (DbRelationship) dbRelationships.get(0);
-        DbRelationship secondRel = (DbRelationship) dbRelationships.get(1);
+        DbRelationship firstRel = dbRelationships.get(0);
+        DbRelationship secondRel = dbRelationships.get(1);
 
         // only support many-to-many with single-step join
         if (!firstRel.isToMany() || secondRel.isToMany()) {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/Relationship.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/Relationship.java?rev=599363&r1=599362&r2=599363&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/Relationship.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/Relationship.java Thu Nov 29 02:06:07 2007
@@ -21,10 +21,10 @@
 
 import java.io.Serializable;
 
-import org.apache.commons.lang.builder.ToStringBuilder;
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.util.CayenneMapEntry;
 import org.apache.cayenne.util.XMLSerializable;
+import org.apache.commons.lang.builder.ToStringBuilder;
 
 /**
  * Defines a relationship between two entities. In a DataMap graph relationships represent

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/SQLTemplateBuilder.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/SQLTemplateBuilder.java?rev=599363&r1=599362&r2=599363&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/SQLTemplateBuilder.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/SQLTemplateBuilder.java Thu Nov 29 02:06:07 2007
@@ -19,7 +19,6 @@
 
 package org.apache.cayenne.map;
 
-import java.util.Iterator;
 import java.util.Map;
 
 import org.apache.cayenne.query.Query;
@@ -51,13 +50,11 @@
         // init SQL
         template.setDefaultTemplate(sql);
         if (adapterSql != null) {
-            Iterator it = adapterSql.entrySet().iterator();
-            while (it.hasNext()) {
-                Map.Entry entry = (Map.Entry) it.next();
-                Object key = entry.getKey();
-                Object value = entry.getValue();
+            for (Map.Entry<String, String> entry : adapterSql.entrySet()) {
+                String key = entry.getKey();
+                String value = entry.getValue();
                 if (key != null && value != null) {
-                    template.setTemplate(key.toString(), value.toString());
+                    template.setTemplate(key, value);
                 }
             }
         }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/SelectQueryBuilder.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/SelectQueryBuilder.java?rev=599363&r1=599362&r2=599363&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/SelectQueryBuilder.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/SelectQueryBuilder.java Thu Nov 29 02:06:07 2007
@@ -19,8 +19,6 @@
 
 package org.apache.cayenne.map;
 
-import java.util.Iterator;
-
 import org.apache.cayenne.query.Query;
 import org.apache.cayenne.query.SelectQuery;
 
@@ -46,9 +44,8 @@
         }
 
         if (prefetches != null && !prefetches.isEmpty()) {
-            Iterator it = prefetches.iterator();
-            while(it.hasNext()) {
-                query.addPrefetch((String) it.next());
+            for (String prefetch : prefetches) {
+                query.addPrefetch(prefetch);
             }
         }
 



Mime
View raw message