db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r930722 - in /db/torque/torque4/trunk: torque-generator/src/main/java/org/apache/torque/gf/control/ torque-generator/src/main/java/org/apache/torque/gf/source/ torque-generator/src/main/java/org/apache/torque/gf/source/properties/ torque-ge...
Date Sun, 04 Apr 2010 17:39:59 GMT
Author: tfischer
Date: Sun Apr  4 17:39:58 2010
New Revision: 930722

URL: http://svn.apache.org/viewvc?rev=930722&view=rev
Log:
- Simplified the SourceElement class hierarchy to a single class SourceElement, since the only implementation will be used all the time anyway, so having a set of interfaces only complicates the code.
- Removed the methods from SourceElement in which the parents and children can be modified. Instead, modifications should occur directly on the Lists obtained by getParents() and getChildren().
- SourceElement now checks that a certain SourceElement can only be added once to the List of SourceElements.

Added:
    db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/source/SourceElement.java
      - copied, changed from r916199, db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/source/RichSourceElementImpl.java
Removed:
    db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/source/RichSourceElement.java
    db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/source/RichSourceElementImpl.java
Modified:
    db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/control/Controller.java
    db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/source/properties/PropertiesSourceParser.java
    db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/source/xml/XmlSourceSaxHandler.java
    db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/source/RichSourceElementImplTest.java
    db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/source/SourcePathTest.java
    db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/source/transform/BeanPropertyMethodNameTransformerTest.java
    db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/source/xml/SourceToXmlTest.java
    db/torque/torque4/trunk/torque-generator/src/test/resources/org/apache/torque/gf/source/xml/sourceToXmlWithReferenceResult.xml
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/CollectAttributeSetTrueTransformer.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMForeignKeyColumnTransformer.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMForeignKeyTransformer.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMReferencingForeignKeyTableTransformer.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMTableTransformer.java

Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/control/Controller.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/control/Controller.java?rev=930722&r1=930721&r2=930722&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/control/Controller.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/control/Controller.java Sun Apr  4 17:39:58 2010
@@ -452,9 +452,9 @@ public class Controller
                 }
                 else
                 {
-                    int index = parent.getChildIndex(sourceElement);
-                    parent.removeChild(sourceElement);
-                    parent.addChild(index, transformedElement);
+                    List<SourceElement> children = parent.getChildren();
+                    int index = children.indexOf(sourceElement);
+                    children.set(index, transformedElement);
                 }
             }
             log.debug("Transformation ended");

Copied: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/source/SourceElement.java (from r916199, db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/source/RichSourceElementImpl.java)
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/source/SourceElement.java?p2=db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/source/SourceElement.java&p1=db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/source/RichSourceElementImpl.java&r1=916199&r2=930722&rev=930722&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/source/RichSourceElementImpl.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/source/SourceElement.java Sun Apr  4 17:39:58 2010
@@ -19,6 +19,7 @@ package org.apache.torque.gf.source;
  * under the License.
  */
 
+import java.util.AbstractList;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -30,8 +31,7 @@ import java.util.Set;
 /**
  * Implementation of the RichSourceElement interface.
  */
-public class RichSourceElementImpl
-    implements RichSourceElement, SourceElement
+public class SourceElement
 {
     /**
      * The name of the source element.
@@ -41,12 +41,12 @@ public class RichSourceElementImpl
     /**
      * The parents of this  element; may be empty but not null.
      */
-    private List<SourceElement> parents = new ArrayList<SourceElement>();
+    private List<SourceElement> parents = new ParentList(this);
 
     /**
      * All children elements.
      */
-    private List<SourceElement> children = new ArrayList<SourceElement>();
+    private List<SourceElement> children = new ChildList(this);
 
     /**
      * the source element's attributes.
@@ -60,7 +60,7 @@ public class RichSourceElementImpl
      *
      * @throws NullPointerException if name is null.
      */
-    public RichSourceElementImpl(String name)
+    public SourceElement(String name)
     {
         if (name == null)
         {
@@ -76,16 +76,27 @@ public class RichSourceElementImpl
      *
      * @throws NullPointerException if sourceElementName is null.
      */
-    public RichSourceElementImpl(SourceElementName sourceElementName)
+    public SourceElement(SourceElementName sourceElementName)
     {
         this(sourceElementName.getName());
     }
 
+    /**
+     * Returns the name of this source element.
+     *
+     * @return the name of this source element, never null.
+     */
     public String getName()
     {
         return name;
     }
 
+    /**
+     * Returns the primary parent of this SourceElement.
+     *
+     * @return the primary parent of this SourceElement,
+     *         or null if this is a root element of the source graph.
+     */
     public SourceElement getParent()
     {
         if (parents.size() == 0)
@@ -95,82 +106,42 @@ public class RichSourceElementImpl
         return parents.get(0);
     }
 
-    public void addParent(SourceElement parent)
-    {
-        if (parent == null)
-        {
-            throw new NullPointerException("parent must not be null");
-        }
-        parents.add(parent);
-        // We can use contains here as we did not overwrite the equals()
-        // and hassCode() methods.
-        if (!parent.getChildren().contains(this))
-        {
-            parent.addChild(this);
-        }
-    }
-
+    /**
+     * Returns the list of parents of this SourceElement.
+     * Parents can be added and removed via the methods exposed by
+     * the returned list.
+     *
+     * @return the list of parents of this source element, never null.
+     */
     public List<SourceElement> getParents()
     {
         return parents;
     }
 
+    /**
+     * Returns all children of this SourceElement.
+     * Children can be added and removed via the methods exposed by
+     * the returned list.
+     *
+     * @return the list of children of this source element, never null.
+     */
     public List<SourceElement> getChildren()
     {
         return children;
     }
-
-    public void addChild(SourceElement child)
-    {
-        if (child == null)
-        {
-            throw new NullPointerException("child must not be null");
-        }
-        children.add(child);
-
-        // We can use contains here as we did not overwrite the equals()
-        // and hassCode() methods.
-        if (!child.getParents().contains(this))
-        {
-            child.addParent(this);
-        }
-    }
-
-    public void addChild(int position, SourceElement child)
-    {
-        if (child == null)
-        {
-            throw new NullPointerException("child must not be null");
-        }
-        children.add(position, child);
-
-        // We can use contains here as we did not overwrite the equals()
-        // and hashCode() methods.
-        if (!child.getParents().contains(this))
-        {
-            child.addParent(this);
-        }
-    }
-
-    public SourceElement removeChild(SourceElement toRemove)
-    {
-        if (toRemove == null)
-        {
-            throw new NullPointerException("toRemove must not be null");
-        }
-        Iterator<SourceElement> childIt = children.iterator();
-        while (childIt.hasNext())
-        {
-            SourceElement candidate = childIt.next();
-            if (candidate == toRemove)
-            {
-                childIt.remove();
-                return candidate;
-            }
-        }
-        return null;
-    }
-
+    
+    /**
+     * Returns all children of this SourceElement which have the given name.
+     * Modifications on the returned list have no effect 
+     * on the list of children of this SourceElement.
+     *
+     * @param name the name of the children to select, not null.
+     *
+     * @return the list of children of this source element with the given name,
+     *         never null.
+     *
+     * @throws NullPointerException if name is null.
+     */
     public List<SourceElement> getChildren(String name)
     {
         if (name == null)
@@ -188,11 +159,35 @@ public class RichSourceElementImpl
         return result;
     }
 
+    /**
+     * Returns all children of this SourceElement which have the given name. 
+     * Modifications on the returned list have no effect 
+     * on the list of children of this SourceElement.
+     *
+     * @param sourceElementName contains the name of the child to select,
+     *        not null.
+     *
+     * @return the list of children of this source element with the given name,
+     *         never null.
+     *
+     * @throws NullPointerException if sourceElementName is null.
+     */
     public List<SourceElement> getChildren(SourceElementName sourceElementName)
     {
         return getChildren(sourceElementName.getName());
     }
 
+    /**
+     * Returns the first child of this SourceElement which has
+     * the given name. 
+     *
+     * @param name the name of the child to select, not null.
+     *
+     * @return the first child with the given name, or null if no child with
+     *         the given name exits.
+     *
+     * @throws NullPointerException if name is null.
+     */
     public SourceElement getChild(String name)
     {
         for (SourceElement sourceElement : children)
@@ -205,27 +200,44 @@ public class RichSourceElementImpl
         return null;
     }
 
+    /**
+     * Returns the first child of this SourceElement which has
+     * the given name.
+     *
+     * @param sourceElementName contains the name of the child to select,
+     *        not null.
+     *
+     * @return the first child with the given name, or null if no child with
+     *         the given name exits.
+     *
+     * @throws NullPointerException if sourceElementName is null.
+     */
     public SourceElement getChild(SourceElementName sourceElementName)
     {
         return getChild(sourceElementName.getName());
     }
 
+    /**
+     * Returns whether children with the given name exist.
+     *
+     * @param name the name of the child element, not null.
+     *
+     * @return true if children with the given name exist, false otherwise.
+     *
+     * @throws NullPointerException if name is null.
+     */
     public boolean hasChild(String name)
     {
         return SourcePath.hasChild(this, name);
     }
 
-    public int getChildIndex(SourceElement child)
-    {
-        return children.indexOf(child);
-    }
-
 
     /**
      * Returns all the following elements after this element
      * with the given name.
      * If name is null, all following elements are returned.
      * If this element has no parent, an empty list is returned.
+     *
      * @param name the name of the following elements to select,
      *        or null to select all following elements.
      * @return a list containing the following elements with the given name,
@@ -238,21 +250,45 @@ public class RichSourceElementImpl
         return SourcePath.getFollowing(this, name);
     }
 
+    /**
+     * Returns whether a following element exists as a child of the parent of
+     * this element.
+     *
+     * @return true if a following element exists, false if not.
+     */
     public boolean hasFollowing()
     {
         return SourcePath.hasFollowing(this);
     }
 
+    /**
+     * Returns whether an preceding exists as a child of the parent of
+     * this element.
+     *
+     * @return true if a preceding element exists, false if not.
+     */
     public boolean hasPreceding()
     {
         return SourcePath.hasPreceding(this);
     }
 
+    /**
+     * Returns whether a following element exists as a child of the parent of
+     * this element, which has the same name as this source element.
+     *
+     * @return true if a following sibling exists, false if not.
+     */
     public boolean hasFollowingSibling()
     {
         return SourcePath.hasFollowingSibling(this);
     }
 
+    /**
+     * Returns whether an preceding exists as a child of the parent of
+     * this element, which has the same name as this source element.
+     *
+     * @return true if a preceding sibling exists, false if not.
+     */
     public boolean hasPrecedingSibling()
     {
         return SourcePath.hasPrecedingSibling(this);
@@ -263,6 +299,7 @@ public class RichSourceElementImpl
      * with the given name.
      * If name is null, all preceding elements are returned.
      * If this element has no parent, an empty list is returned.
+     *
      * @param name the name of the preceding elements to select,
      *        or null to select all preceding elements.
      * @return a list containing the following elements with the given name,
@@ -275,16 +312,41 @@ public class RichSourceElementImpl
         return SourcePath.getPreceding(this, name);
     }
 
+    /**
+     * Returns the object stored in a given attribute.
+     *
+     * @param name the name of the attribute, can be null.
+     *
+     * @return the stored object, or null if no object is stored under that key.
+     */
     public Object getAttribute(String name)
     {
         return attributes.get(name);
     }
 
+    /**
+     * Returns the object stored in a given attribute.
+     *
+     * @param sourceAttributeName contains the name of the attribute, not null.
+     *
+     * @return the stored object, or null if no object is stored under that key.
+     *
+     * @throws NullPointerException if sourceAttributeName is null.
+     */
     public Object getAttribute(SourceAttributeName sourceAttributeName)
     {
         return getAttribute(sourceAttributeName.getName());
     }
 
+    /**
+     * Sets the attribute of a Source element.
+     *
+     * @param name the name of the attribute.
+     * @param value the value of the attribute,
+     *        or null to remove the attribute.
+     *
+     * @return the previous value of this attribute.
+     */
     public Object setAttribute(String name, Object value)
     {
         if (value == null)
@@ -294,6 +356,15 @@ public class RichSourceElementImpl
         return attributes.put(name, value);
     }
 
+    /**
+     * Sets the attribute of a Source element.
+     *
+     * @param sourceAttributeName contains the name of the attribute, not null.
+     * @param value the value of the attribute,
+     *        or null to remove the attribute.
+     *
+     * @return the previous value of this attribute.
+     */
     public Object setAttribute(
             SourceAttributeName sourceAttributeName,
             Object value)
@@ -301,6 +372,12 @@ public class RichSourceElementImpl
         return setAttribute(sourceAttributeName.getName(), value);
     }
 
+    /**
+     * Returns the name of all set attributes. Note : null may be contained
+     * in the set.
+     *
+     * @return the name of all set values.
+     */
     public Set<String> getAttributeNames()
     {
         return attributes.keySet();
@@ -308,13 +385,16 @@ public class RichSourceElementImpl
 
     /**
      * Creates a deep copy of this RichSourceelementImpl object.
+     * All the elements in the source graph of this Element are copied as well
+     * (i.e the copy contains the children, the children's children, ...., 
+     * the parents, the parent's parents...)
      *
      * @return the copy, not null.
      */
-    public RichSourceElementImpl copy()
+    public SourceElement copy()
     {
-        Map<SourceElement, RichSourceElementImpl> copied
-                = new HashMap<SourceElement, RichSourceElementImpl>();
+        Map<SourceElement, SourceElement> copied
+                = new HashMap<SourceElement, SourceElement>();
         return copy(this, copied);
     }
 
@@ -327,15 +407,15 @@ public class RichSourceElementImpl
      *
      * @return the copy of the source, not null.
      */
-    private RichSourceElementImpl copy(SourceElement toCopy,
-            Map<SourceElement, RichSourceElementImpl> copiedElements)
+    private SourceElement copy(SourceElement toCopy,
+            Map<SourceElement, SourceElement> copiedElements)
     {
-        RichSourceElementImpl copied = copiedElements.get(toCopy);
+        SourceElement copied = copiedElements.get(toCopy);
         if (copied != null)
         {
             return copied;
         }
-        copied = new RichSourceElementImpl(toCopy.getName());
+        copied = new SourceElement(toCopy.getName());
         copiedElements.put(toCopy, copied);
 
         for (String attributeName : toCopy.getAttributeNames())
@@ -343,20 +423,29 @@ public class RichSourceElementImpl
             copied.setAttribute(attributeName, toCopy.getAttribute(attributeName));
         }
 
-        for (SourceElement child : toCopy.getChildren())
         {
-            RichSourceElementImpl copiedChild = copy(child, copiedElements);
-            copied.addChild(copiedChild);
+            List<SourceElement> childrenOfCopied = copied.getChildren();
+            for (SourceElement child : toCopy.getChildren())
+            {
+                SourceElement copiedChild = copy(child, copiedElements);
+                if (!childrenOfCopied.contains(copiedChild))
+                {
+                    childrenOfCopied.add(copiedChild);
+                }
+            }
         }
 
-        for (SourceElement parent : toCopy.getParents())
         {
-            RichSourceElementImpl copiedParent
-                    = copy(parent, copiedElements);
-            // do not use setParent because this will add copied as a child
-            // to copiedParent. Later on, when processing the children of
-            // copiedParent, it will be added again.
-            copied.parents.add(copiedParent);
+            List<SourceElement> parentsOfCopied = copied.getParents();
+            for (SourceElement parent : toCopy.getParents())
+            {
+                SourceElement copiedParent
+                        = copy(parent, copiedElements);
+                if (!parentsOfCopied.contains(copiedParent))
+                {
+                    parentsOfCopied.add(copiedParent);
+                }
+            }
         }
 
         return copied;
@@ -525,10 +614,10 @@ public class RichSourceElementImpl
             }
             else
             {
-                if (child instanceof RichSourceElementImpl)
+                if (child instanceof SourceElement)
                 {
 
-                    ((RichSourceElementImpl) child).toString(
+                    ((SourceElement) child).toString(
                             alreadyProcessed, result);
                 }
                 else
@@ -543,4 +632,153 @@ public class RichSourceElementImpl
         }
         result.append("))");
     }
+    
+    /**
+     * Overrides the add and remove methods such that the parents of the
+     * source element are updated as well.
+     */
+    private static class ChildList extends AbstractList<SourceElement>
+    {
+        private SourceElement sourceElement;
+        
+        private List<SourceElement> children 
+                = new ArrayList<SourceElement>();
+        
+        public ChildList(SourceElement sourceElement)
+        {
+            this.sourceElement = sourceElement;
+        }
+
+        @Override
+        public SourceElement get(int index)
+        {
+            return children.get(index);
+        }
+
+        @Override
+        public int size()
+        {
+            return children.size();
+        }
+
+        @Override
+        public void add(int position, SourceElement child)
+        {
+            if (children.contains(child))
+            {
+                throw new IllegalArgumentException(
+                        "Element " + child + " is already a child of "
+                        + sourceElement);
+            }
+            children.add(position, child);
+            List<SourceElement> parents = child.getParents();
+            if (!parents.contains(sourceElement))
+            {
+                parents.add(sourceElement);
+            }
+        }
+
+        @Override
+        public SourceElement remove(int index)
+        {
+            SourceElement result = children.remove(index);
+            result.getParents().remove(sourceElement);
+            return result;
+        }
+
+        @Override
+        public SourceElement set(int index, SourceElement child)
+        {
+            // allow setting an already contained child at the same position,
+            // but throw an error if the child is set at other position.
+            if (children.contains(child) && !children.get(index).equals(child))
+            {
+                throw new IllegalArgumentException(
+                        "Element " + child + " is already a child of "
+                        + sourceElement);
+            }
+            SourceElement previousChild = children.set(index, child);
+            previousChild.getParents().remove(sourceElement);
+            List<SourceElement> parents = child.getParents();
+            if (!parents.contains(sourceElement))
+            {
+                parents.add(sourceElement);
+            }
+            return previousChild;
+        }
+    }
+    /**
+     * Overrides the add and remove methods such that the children of the
+     * source element are updated as well.
+     */
+    private static class ParentList extends AbstractList<SourceElement>
+    {
+        private SourceElement sourceElement;
+        
+        private List<SourceElement> parents 
+                = new ArrayList<SourceElement>();
+        
+        public ParentList(SourceElement sourceElement)
+        {
+            this.sourceElement = sourceElement;
+        }
+
+        @Override
+        public SourceElement get(int index)
+        {
+            return parents.get(index);
+        }
+
+        @Override
+        public int size()
+        {
+            return parents.size();
+        }
+
+        @Override
+        public void add(int position, SourceElement parent)
+        {
+            if (parents.contains(parent))
+            {
+                throw new IllegalArgumentException(
+                        "Element " + parent + " is already a parent of "
+                        + sourceElement);
+            }
+            parents.add(position, parent);
+            List<SourceElement> children = parent.getChildren();
+            if (!children.contains(sourceElement))
+            {
+                children.add(sourceElement);
+            }
+        }
+        
+        @Override
+        public SourceElement remove(int index)
+        {
+            SourceElement result = parents.remove(index);
+            result.getChildren().remove(sourceElement);
+            return result;
+        }
+
+        @Override
+        public SourceElement set(int index, SourceElement parent)
+        {
+            // allow setting an already contained parent at the same position,
+            // but throw an error if the parent is set at other position.
+            if (parents.contains(parent) && !parents.get(index).equals(parent))
+            {
+                throw new IllegalArgumentException(
+                        "Element " + parent + " is already a parent of "
+                        + sourceElement);
+            }
+            SourceElement previousParent = parents.set(index, parent);
+            previousParent.getChildren().remove(sourceElement);
+            List<SourceElement> children = parent.getChildren();
+            if (!children.contains(sourceElement))
+            {
+                children.add(sourceElement);
+            }
+            return previousParent;
+        }
+    }
 }

Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/source/properties/PropertiesSourceParser.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/source/properties/PropertiesSourceParser.java?rev=930722&r1=930721&r2=930722&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/source/properties/PropertiesSourceParser.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/source/properties/PropertiesSourceParser.java Sun Apr  4 17:39:58 2010
@@ -26,7 +26,7 @@ import java.util.Properties;
 import java.util.Set;
 
 import org.apache.commons.collections.set.ListOrderedSet;
-import org.apache.torque.gf.source.RichSourceElementImpl;
+import org.apache.torque.gf.source.SourceElement;
 import org.apache.torque.gf.source.SourceElement;
 import org.apache.torque.gf.source.SourceException;
 import org.apache.torque.gf.source.SourceParser;
@@ -93,17 +93,17 @@ public class PropertiesSourceParser impl
                     e);
         }
 
-        RichSourceElementImpl result
-                = new RichSourceElementImpl(ROOT_ELEMENT_NAME);
+        SourceElement result
+                = new SourceElement(ROOT_ELEMENT_NAME);
 
         for (String key : properties.orderedKeySet())
         {
             String value = properties.getProperty(key);
-            RichSourceElementImpl entryElement
-                    = new RichSourceElementImpl(ENTRY_ELEMENT_NAME);
+            SourceElement entryElement
+                    = new SourceElement(ENTRY_ELEMENT_NAME);
             entryElement.setAttribute(KEY_ATTRIBUTE_NAME, key);
             entryElement.setAttribute((String) null, value);
-            result.addChild(entryElement);
+            result.getChildren().add(entryElement);
         }
         return result;
     }

Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/source/xml/XmlSourceSaxHandler.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/source/xml/XmlSourceSaxHandler.java?rev=930722&r1=930721&r2=930722&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/source/xml/XmlSourceSaxHandler.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/source/xml/XmlSourceSaxHandler.java Sun Apr  4 17:39:58 2010
@@ -19,7 +19,7 @@ package org.apache.torque.gf.source.xml;
  * under the License.
  */
 
-import org.apache.torque.gf.source.RichSourceElementImpl;
+import org.apache.torque.gf.source.SourceElement;
 import org.apache.torque.gf.source.SourceElement;
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
@@ -45,7 +45,7 @@ public class XmlSourceSaxHandler extends
                     String qName, Attributes attributes)
             throws SAXException
     {
-        SourceElement current = new RichSourceElementImpl(qName);
+        SourceElement current = new SourceElement(qName);
         for (int i = 0; i < attributes.getLength(); ++i)
         {
             current.setAttribute(
@@ -53,7 +53,7 @@ public class XmlSourceSaxHandler extends
         }
         if (element != null)
         {
-            element.addChild(current);
+            element.getChildren().add(current);
         }
         else
         {

Modified: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/source/RichSourceElementImplTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/source/RichSourceElementImplTest.java?rev=930722&r1=930721&r2=930722&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/source/RichSourceElementImplTest.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/source/RichSourceElementImplTest.java Sun Apr  4 17:39:58 2010
@@ -20,12 +20,15 @@ package org.apache.torque.gf.source;
  */
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import java.io.File;
 import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
 
 import org.apache.torque.gf.configuration.paths.Maven2DirectoryProjectPaths;
 import org.apache.torque.gf.configuration.paths.ProjectPaths;
@@ -35,20 +38,29 @@ import org.junit.Test;
 
 public class RichSourceElementImplTest
 {
-    private RichSourceElementImpl rootSourceElement;
+    private SourceElement rootSourceElement;
 
     @Before
     public void setUp()
     {
-        rootSourceElement = new RichSourceElementImpl("parent");
-        RichSourceElementImpl child1 = new RichSourceElementImpl("child1");
-        rootSourceElement.addChild(child1);
-        RichSourceElementImpl child2 = new RichSourceElementImpl("child2");
-        rootSourceElement.addChild(child2);
-        RichSourceElementImpl child3 = new RichSourceElementImpl("child3");
-        rootSourceElement.addChild(child3);
+        rootSourceElement = new SourceElement("parent");
+        SourceElement child1 = new SourceElement("child1");
+        List<SourceElement> children = rootSourceElement.getChildren();
+        children.add(child1);
+        SourceElement child2 = new SourceElement("child2");
+        children.add(child2);
+        SourceElement child3 = new SourceElement("child3");
+        children.add(child3);
     }
 
+    @Test
+    public void testGetParents()
+    {
+        SourceElement child1 = rootSourceElement.getChildren().get(0);
+        List<SourceElement> parentsOfChild1 = child1.getParents();
+        assertEquals(1, parentsOfChild1.size());
+        assertSame(rootSourceElement, parentsOfChild1.get(0));
+    }
 
     @Test
     public void testAddChild()
@@ -56,8 +68,8 @@ public class RichSourceElementImplTest
         SourceElement child1 = rootSourceElement.getChildren().get(0);
         SourceElement child2 = rootSourceElement.getChildren().get(1);
         SourceElement child3 = rootSourceElement.getChildren().get(2);
-        RichSourceElementImpl child4 = new RichSourceElementImpl("child4");
-        rootSourceElement.addChild(child4);
+        SourceElement child4 = new SourceElement("child4");
+        rootSourceElement.getChildren().add(child4);
 
         assertEquals("parent should have 4 children",
                 4,
@@ -66,9 +78,8 @@ public class RichSourceElementImplTest
         assertSame(child2, rootSourceElement.getChildren().get(1));
         assertSame(child3, rootSourceElement.getChildren().get(2));
         assertSame(child4, rootSourceElement.getChildren().get(3));
-        assertSame("child2 has wrong parent",
-                rootSourceElement,
-                child4.getParent());
+        assertSame(rootSourceElement, child4.getParent());
+        assertEquals(1, child4.getParents().size());
     }
 
     @Test
@@ -77,39 +88,66 @@ public class RichSourceElementImplTest
         SourceElement child1 = rootSourceElement.getChildren().get(0);
         SourceElement child2 = rootSourceElement.getChildren().get(1);
         SourceElement child3 = rootSourceElement.getChildren().get(2);
-        RichSourceElementImpl child4 = new RichSourceElementImpl("child4");
-        rootSourceElement.addChild(1, child4);
+        SourceElement child4 = new SourceElement("child4");
+        List<SourceElement> children = rootSourceElement.getChildren();
+        children.add(1, child4);
         assertSame(child1, rootSourceElement.getChildren().get(0));
         assertSame(child4, rootSourceElement.getChildren().get(1));
         assertSame(child2, rootSourceElement.getChildren().get(2));
         assertSame(child3, rootSourceElement.getChildren().get(3));
+        assertSame(rootSourceElement, child4.getParent());
+        assertEquals(1, child4.getParents().size());
     }
 
     @Test
     public void testRemoveChild()
     {
-        SourceElement child1 = rootSourceElement.getChildren().get(0);
-        SourceElement child2 = rootSourceElement.getChildren().get(1);
-        SourceElement child3 = rootSourceElement.getChildren().get(2);
-        SourceElement result = rootSourceElement.removeChild(child2);
-        assertSame(child2, result);
+        List<SourceElement> children = rootSourceElement.getChildren();
+        SourceElement child1 = children.get(0);
+        SourceElement child2 = children.get(1);
+        SourceElement child3 = children.get(2);
+        boolean result = children.remove(child2);
+        assertTrue(result);
         assertEquals("parent should have 2 children",
                 2,
                 rootSourceElement.getChildren().size());
         assertSame(child1, rootSourceElement.getChildren().get(0));
         assertSame(child3, rootSourceElement.getChildren().get(1));
+        assertEquals(0, child2.getParents().size());
+        assertEquals(null, child2.getParent());
+    }
+
+    @Test
+    public void testRemoveChildViaIterator()
+    {
+        Iterator<SourceElement> childIt 
+                = rootSourceElement.getChildren().iterator();
+        List<SourceElement> children = rootSourceElement.getChildren();
+        SourceElement child1 = children.get(0);
+        SourceElement child2 = children.get(1);
+        SourceElement child3 = children.get(2);
+        childIt.next(); //child1 
+        childIt.next(); //child2
+        childIt.remove();
+
+        assertEquals(2, children.size());
+        assertEquals(child1, children.get(0));
+        assertEquals(child3, children.get(1));
+        assertEquals(0, child2.getParents().size());
+        assertEquals(null, child2.getParent());
     }
 
     @Test
     public void testRemoveNonExistingChild()
     {
-        SourceElement child1 = rootSourceElement.getChildren().get(0);
-        SourceElement child2 = rootSourceElement.getChildren().get(1);
-        SourceElement child3 = rootSourceElement.getChildren().get(2);
-        RichSourceElementImpl child4 = new RichSourceElementImpl("child4");
+        List<SourceElement> children = rootSourceElement.getChildren();
+        SourceElement child1 = children.get(0);
+        SourceElement child2 = children.get(1);
+        SourceElement child3 = children.get(2);
+        SourceElement child4 = new SourceElement("child4");
 
-        SourceElement result = rootSourceElement.removeChild(child4);
-        assertNull(result);
+        boolean result = children.remove(child4);
+        assertFalse(result);
         assertEquals("parent should have 3 children",
                 3,
                 rootSourceElement.getChildren().size());
@@ -125,30 +163,31 @@ public class RichSourceElementImplTest
 
         assertEquals("child index should be 1",
                 1,
-                rootSourceElement.getChildIndex(child2));
+                rootSourceElement.getChildren().indexOf(child2));
     }
 
     @Test
     public void testGetNonExistingChildIndex()
     {
-        RichSourceElementImpl child4 = new RichSourceElementImpl("child4");
+        SourceElement child4 = new SourceElement("child4");
         assertEquals("child index should be -1",
                 -1,
-                rootSourceElement.getChildIndex(child4));
+                rootSourceElement.getChildren().indexOf(child4));
     }
 
     @Test
     public void testAddParent()
     {
-        RichSourceElementImpl child = new RichSourceElementImpl("chiild");
-        RichSourceElementImpl parent1 = new RichSourceElementImpl("parent1");
-        child.addParent(parent1);
-        RichSourceElementImpl parent2 = new RichSourceElementImpl("parent2");
-        child.addParent(parent2);
+        SourceElement child = new SourceElement("child");
+        List<SourceElement> parentsOfChild = child.getParents();
+        SourceElement parent1 = new SourceElement("parent1");
+        parentsOfChild.add(parent1);
+        SourceElement parent2 = new SourceElement("parent2");
+        parentsOfChild.add(parent2);
 
         assertEquals("child should have 2 parents",
                 2,
-                child.getParents().size());
+                parentsOfChild.size());
         assertSame("child has wrong primary parent",
                 parent1,
                 child.getParent());
@@ -166,15 +205,15 @@ public class RichSourceElementImplTest
     @Test
     public void testTreeEquals()
     {
-        RichSourceElementImpl original = new RichSourceElementImpl("root");
+        SourceElement original = new SourceElement("root");
         SourceElement toCompare
-                = new RichSourceElementImpl("wrongName");
+                = new SourceElement("wrongName");
         if (original.graphEquals(toCompare))
         {
             fail("SourceElements with different names must not be equal");
         }
 
-        toCompare = new RichSourceElementImpl("root");
+        toCompare = new SourceElement("root");
         if (!original.graphEquals(toCompare))
         {
             fail("empty SourceElements with equal names must be equal");
@@ -222,37 +261,37 @@ public class RichSourceElementImplTest
                     + " must be equal(2)");
         }
 
-        original.addChild(new RichSourceElementImpl("child"));
+        original.getChildren().add(new SourceElement("child"));
         if (original.graphEquals(toCompare))
         {
             fail("SourceElements with different children"
                     + " must not be equal(1)");
         }
 
-        toCompare.addChild(new RichSourceElementImpl("wrongChild"));
+        toCompare.getChildren().add(new SourceElement("wrongChild"));
         if (original.graphEquals(toCompare))
         {
             fail("SourceElements with different children"
                     + " must not be equal(2)");
         }
 
-        toCompare = new RichSourceElementImpl("root");
+        toCompare = new SourceElement("root");
         toCompare.setAttribute("attributeName", null);
-        toCompare.addChild(new RichSourceElementImpl("child"));
+        toCompare.getChildren().add(new SourceElement("child"));
         if (!original.graphEquals(toCompare))
         {
             fail("SourceElements with equal children"
                     + " must be equal(1)");
         }
 
-        original.addChild(original);
+        original.getChildren().add(original);
         if (original.graphEquals(toCompare))
         {
             fail("SourceElements with different children"
                     + " must not be equal(3)");
         }
 
-        toCompare.addChild(toCompare);
+        toCompare.getChildren().add(toCompare);
         if (!original.graphEquals(toCompare))
         {
             fail("SourceElements with equal children"
@@ -263,7 +302,7 @@ public class RichSourceElementImplTest
     @Test
     public void testSetAttribute()
     {
-        SourceElement sourceElement = new RichSourceElementImpl("root");
+        SourceElement sourceElement = new SourceElement("root");
         assertEquals(sourceElement.getAttributeNames().size(), 0);
         assertEquals(null, sourceElement.getAttribute("attributeName"));
 
@@ -275,7 +314,7 @@ public class RichSourceElementImplTest
     @Test
     public void testSetAttributeToNull()
     {
-        SourceElement sourceElement = new RichSourceElementImpl("root");
+        SourceElement sourceElement = new SourceElement("root");
         sourceElement.setAttribute("attributeName", "123");
         assertEquals(1, sourceElement.getAttributeNames().size());
 
@@ -286,10 +325,10 @@ public class RichSourceElementImplTest
     @Test
     public void testToString() throws Exception
     {
-        SourceElement sourceElement = new RichSourceElementImpl("root");
+        SourceElement sourceElement = new SourceElement("root");
         sourceElement.setAttribute("attributeName", "123");
-        sourceElement.addChild(new RichSourceElementImpl("child"));
-        sourceElement.addChild(sourceElement);
+        sourceElement.getChildren().add(new SourceElement("child"));
+        sourceElement.getChildren().add(sourceElement);
         String expected
                 = "(name=root,attributes=(attributeName=123),"
                     + "children=((name=child,attributes=(),children=()),"
@@ -314,8 +353,8 @@ public class RichSourceElementImplTest
                         null,
                         null,
                         new ArrayList<TransformerDefinition>());
-        RichSourceElementImpl rootElement
-                = (RichSourceElementImpl) fileSource.getRootElement();
+        SourceElement rootElement
+                = (SourceElement) fileSource.getRootElement();
 
         SourceElement copiedRootElement = rootElement.copy();
         if (!rootElement.graphEquals(copiedRootElement))

Modified: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/source/SourcePathTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/source/SourcePathTest.java?rev=930722&r1=930721&r2=930722&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/source/SourcePathTest.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/source/SourcePathTest.java Sun Apr  4 17:39:58 2010
@@ -30,23 +30,23 @@ import org.junit.Test;
 
 public class SourcePathTest
 {
-    private RichSourceElementImpl root;
-    private RichSourceElementImpl firstLevel;
-    private RichSourceElementImpl secondLevel;
-    private RichSourceElementImpl thirdLevel;
+    private SourceElement root;
+    private SourceElement firstLevel;
+    private SourceElement secondLevel;
+    private SourceElement thirdLevel;
 
     @Before
     public void setUp()
     {
-        root = new RichSourceElementImpl("root");
-        root.addChild(new RichSourceElementImpl("firstLevel1"));
-        firstLevel  = new RichSourceElementImpl("firstLevel2");
-        root.addChild(firstLevel);
-        root.addChild(new RichSourceElementImpl("firstLevel3"));
-        secondLevel = new RichSourceElementImpl("secondLevel");
-        firstLevel.addChild(secondLevel);
-        thirdLevel = new RichSourceElementImpl("thirdLevel");
-        secondLevel.addChild(thirdLevel);
+        root = new SourceElement("root");
+        root.getChildren().add(new SourceElement("firstLevel1"));
+        firstLevel  = new SourceElement("firstLevel2");
+        root.getChildren().add(firstLevel);
+        root.getChildren().add(new SourceElement("firstLevel3"));
+        secondLevel = new SourceElement("secondLevel");
+        firstLevel.getChildren().add(secondLevel);
+        thirdLevel = new SourceElement("thirdLevel");
+        secondLevel.getChildren().add(thirdLevel);
     }
 
     @Test
@@ -60,10 +60,10 @@ public class SourcePathTest
     @Test(expected=GeneratorException.class)
     public void testGetPathInfiniteLoop() throws GeneratorException
     {
-        SourceElement loopElement1 = new RichSourceElementImpl("loopElement1");
-        SourceElement loopElement2 = new RichSourceElementImpl("loopElement2");
-        loopElement1.addChild(loopElement2);
-        loopElement2.addChild(loopElement1);
+        SourceElement loopElement1 = new SourceElement("loopElement1");
+        SourceElement loopElement2 = new SourceElement("loopElement2");
+        loopElement1.getChildren().add(loopElement2);
+        loopElement2.getChildren().add(loopElement1);
         SourcePath.getPathAsString(loopElement1);
     }
 

Modified: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/source/transform/BeanPropertyMethodNameTransformerTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/source/transform/BeanPropertyMethodNameTransformerTest.java?rev=930722&r1=930721&r2=930722&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/source/transform/BeanPropertyMethodNameTransformerTest.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/source/transform/BeanPropertyMethodNameTransformerTest.java Sun Apr  4 17:39:58 2010
@@ -21,8 +21,6 @@ package org.apache.torque.gf.source.tran
 
 import static org.junit.Assert.assertEquals;
 
-import org.apache.torque.gf.source.RichSourceElement;
-import org.apache.torque.gf.source.RichSourceElementImpl;
 import org.apache.torque.gf.source.SourceElement;
 import org.junit.Before;
 import org.junit.Test;
@@ -49,8 +47,8 @@ public class BeanPropertyMethodNameTrans
     @Test
     public void testNoPrefixSuffix() throws SourceTransformerException
     {
-        RichSourceElement sourceElement
-                = new RichSourceElementImpl("elementName");
+        SourceElement sourceElement
+                = new SourceElement("elementName");
         sourceElement.setAttribute("name", "vaL_ue");
 
         transformer.setTargetAttributeName("targetAttribute");
@@ -61,8 +59,8 @@ public class BeanPropertyMethodNameTrans
     @Test
     public void testPrefixSuffix() throws SourceTransformerException
     {
-        RichSourceElement sourceElement
-                = new RichSourceElementImpl("elementName");
+        SourceElement sourceElement
+                = new SourceElement("elementName");
         sourceElement.setAttribute("sourceAttribute", "someProperty");
 
         transformer.setSourceAttributeName("sourceAttribute");
@@ -78,8 +76,8 @@ public class BeanPropertyMethodNameTrans
     @Test
     public void testNoOverwrite() throws SourceTransformerException
     {
-        RichSourceElement sourceElement
-                = new RichSourceElementImpl("elementName");
+        SourceElement sourceElement
+                = new SourceElement("elementName");
         sourceElement.setAttribute("name", "modified");
         sourceElement.setAttribute("targetAttribute", "unmodified");
 
@@ -94,8 +92,8 @@ public class BeanPropertyMethodNameTrans
     @Test
     public void testNoOverwriteEmptyTarget() throws SourceTransformerException
     {
-        RichSourceElement sourceElement
-                = new RichSourceElementImpl("elementName");
+        SourceElement sourceElement
+                = new SourceElement("elementName");
         sourceElement.setAttribute("name", "source");
 
         transformer.setOverwrite(false);

Modified: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/source/xml/SourceToXmlTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/source/xml/SourceToXmlTest.java?rev=930722&r1=930721&r2=930722&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/source/xml/SourceToXmlTest.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/source/xml/SourceToXmlTest.java Sun Apr  4 17:39:58 2010
@@ -27,7 +27,7 @@ import java.util.ArrayList;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.torque.gf.source.FileSource;
-import org.apache.torque.gf.source.RichSourceElementImpl;
+import org.apache.torque.gf.source.SourceElement;
 import org.apache.torque.gf.source.SourceElement;
 import org.apache.torque.gf.source.TransformerDefinition;
 import org.junit.Test;
@@ -63,8 +63,8 @@ public class SourceToXmlTest
     @Test
     public void testSourceToXmlWithReferences() throws Exception
     {
-        File xmlFile
-            = new File("src/test/resources/org/apache/torque/gf/source/xml/source.xml");
+        File xmlFile = new File(
+                "src/test/resources/org/apache/torque/gf/source/xml/source.xml");
         FileSource fileSource = new FileSource(
                 new XmlSourceType(),
                 xmlFile,
@@ -72,7 +72,8 @@ public class SourceToXmlTest
                 null,
                 new ArrayList<TransformerDefinition>());
         SourceElement rootElement = fileSource.getRootElement();
-        rootElement.addChild(rootElement.getChildren().get(2));
+        rootElement.getChildren().get(2).getChildren().add(
+                rootElement.getChildren().get(0).getChildren().get(0));
 
         String result = new SourceToXml().toXml(rootElement);
         String expected = FileUtils.readFileToString(new File(
@@ -85,7 +86,7 @@ public class SourceToXmlTest
     @Test
     public void testSourceToXmlTextEscaping() throws Exception
     {
-        SourceElement rootElement = new RichSourceElementImpl("root");
+        SourceElement rootElement = new SourceElement("root");
         rootElement.setAttribute((String) null, "X&<>Y'\"Z");
         String result = new SourceToXml().toXml(rootElement);
         assertEquals(
@@ -96,7 +97,7 @@ public class SourceToXmlTest
     @Test
     public void testSourceToXmlAttributeEscaping() throws Exception
     {
-        SourceElement rootElement = new RichSourceElementImpl("root");
+        SourceElement rootElement = new SourceElement("root");
         rootElement.setAttribute("attribute", "&<>'\"");
         String result = new SourceToXml().toXml(rootElement);
         assertEquals(

Modified: db/torque/torque4/trunk/torque-generator/src/test/resources/org/apache/torque/gf/source/xml/sourceToXmlWithReferenceResult.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/resources/org/apache/torque/gf/source/xml/sourceToXmlWithReferenceResult.xml?rev=930722&r1=930721&r2=930722&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/resources/org/apache/torque/gf/source/xml/sourceToXmlWithReferenceResult.xml (original)
+++ db/torque/torque4/trunk/torque-generator/src/test/resources/org/apache/torque/gf/source/xml/sourceToXmlWithReferenceResult.xml Sun Apr  4 17:39:58 2010
@@ -23,8 +23,7 @@
     <thirdLevelElement1 tla="tlaValue" id="3"/>
   </secondLevelElement1>
   <secondLevelElement2 id="4"/>
-  <secondLevelElement3 sla="slaValue" id="5"> text For Second Level Element 3 <thirdLevelElement2 tla2="tla2Value" id="6"/>
+  <secondLevelElement3 sla="slaValue" id="5"> text For Second Level Element 3 <thirdLevelElement2 tla2="tla2Value" id="6"/>    <thirdLevelElement1 refid="3"/>
   </secondLevelElement3>
   <secondLevelElement4 id="7">  text For Second Level Element 4  </secondLevelElement4>
-  <secondLevelElement3 refid="5"/>
 </root>

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/CollectAttributeSetTrueTransformer.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/CollectAttributeSetTrueTransformer.java?rev=930722&r1=930721&r2=930722&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/CollectAttributeSetTrueTransformer.java (original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/CollectAttributeSetTrueTransformer.java Sun Apr  4 17:39:58 2010
@@ -23,7 +23,6 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.torque.gf.control.ControllerState;
-import org.apache.torque.gf.source.RichSourceElementImpl;
 import org.apache.torque.gf.source.SourceAttributeName;
 import org.apache.torque.gf.source.SourceElement;
 import org.apache.torque.gf.source.SourceElementName;
@@ -87,12 +86,12 @@ public class CollectAttributeSetTrueTran
         }
 
         SourceElement targetElement
-                = new RichSourceElementImpl(targetElementName);
-        rootElement.addChild(targetElement);
+                = new SourceElement(targetElementName);
+        rootElement.getChildren().add(targetElement);
 
         for (SourceElement hit : hits)
         {
-            targetElement.addChild(hit);
+            targetElement.getChildren().add(hit);
         }
     }
 }

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMForeignKeyColumnTransformer.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMForeignKeyColumnTransformer.java?rev=930722&r1=930721&r2=930722&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMForeignKeyColumnTransformer.java (original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMForeignKeyColumnTransformer.java Sun Apr  4 17:39:58 2010
@@ -22,7 +22,6 @@ package org.apache.torque.templates.tran
 import java.util.List;
 
 import org.apache.torque.gf.control.ControllerState;
-import org.apache.torque.gf.source.RichSourceElementImpl;
 import org.apache.torque.gf.source.SourceElement;
 import org.apache.torque.gf.source.transform.SourceTransformerException;
 import org.apache.torque.templates.TorqueSchemaAttributeName;
@@ -119,9 +118,9 @@ public class OMForeignKeyColumnTransform
                             TorqueSchemaAttributeName.LOCAL)))
                     {
                         SourceElement referencedColumn
-                                = new RichSourceElementImpl(
+                                = new SourceElement(
                                     ColumnChildElementName.REFERENCED_COLUMN);
-                        referencedColumn.addChild(foreignKey);
+                        referencedColumn.getChildren().add(foreignKey);
                         String foreignTableName
                                 = (String) foreignKey.getAttribute(
                                     TorqueSchemaAttributeName.FOREIGN_TABLE);
@@ -152,8 +151,8 @@ public class OMForeignKeyColumnTransform
                                     + " not found for a foreignKey of table "
                                     + localTableName);
                         }
-                        referencedColumn.addChild(foreignColumn);
-                        column.addChild(referencedColumn);
+                        referencedColumn.getChildren().add(foreignColumn);
+                        column.getChildren().add(referencedColumn);
                         break;
                     }
                 }
@@ -192,10 +191,10 @@ public class OMForeignKeyColumnTransform
                     if (localColumnName.equals(referenceForeignColumnName))
                     {
                         SourceElement referencingColumn
-                                = new RichSourceElementImpl(
+                                = new SourceElement(
                                         ColumnChildElementName.REFERENCING_COLUMN);
-                        referencingColumn.addChild(foreignKey);
-                        referencingColumn.addChild(foreignTable);
+                        referencingColumn.getChildren().add(foreignKey);
+                        referencingColumn.getChildren().add(foreignTable);
                         SourceElement localColumn = FindHelper.findColumn(
                                 foreignTable,
                                 referenceLocalColumnName);
@@ -208,8 +207,8 @@ public class OMForeignKeyColumnTransform
                                     + " of table "
                                     + foreignTableName);
                         }
-                        referencingColumn.addChild(localColumn);
-                        column.addChild(referencingColumn);
+                        referencingColumn.getChildren().add(localColumn);
+                        column.getChildren().add(referencingColumn);
                         break;
                     }
                 }

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMForeignKeyTransformer.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMForeignKeyTransformer.java?rev=930722&r1=930721&r2=930722&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMForeignKeyTransformer.java (original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMForeignKeyTransformer.java Sun Apr  4 17:39:58 2010
@@ -23,7 +23,6 @@ import java.util.List;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.torque.gf.control.ControllerState;
-import org.apache.torque.gf.source.RichSourceElementImpl;
 import org.apache.torque.gf.source.SourceElement;
 import org.apache.torque.gf.source.transform.SourceTransformerException;
 import org.apache.torque.templates.TorqueSchemaAttributeName;
@@ -103,7 +102,7 @@ public class OMForeignKeyTransformer
                 TorqueSchemaAttributeName.FOREIGN_TABLE);
         SourceElement foreignTable
                 = FindHelper.findTable(database, foreignTableName);
-        foreignKey.addChild(foreignTable);
+        foreignKey.getChildren().add(foreignTable);
 
         for (SourceElement reference : foreignKey.getChildren(
                 TorqueSchemaElementName.REFERENCE))
@@ -115,12 +114,12 @@ public class OMForeignKeyTransformer
                         reference.getAttribute(
                                 TorqueSchemaAttributeName.LOCAL);
                 SourceElement localColumnElement
-                        = new RichSourceElementImpl(
+                        = new SourceElement(
                                 ReferenceChildElementName.LOCAL_COLUMN);
                 SourceElement column
                         = FindHelper.findColumn(localTable, localColumnName);
-                localColumnElement.addChild(column);
-                reference.addChild(localColumnElement);
+                localColumnElement.getChildren().add(column);
+                reference.getChildren().add(localColumnElement);
             }
             // create child element "foreign" for reference
             // and add foreign column
@@ -129,12 +128,12 @@ public class OMForeignKeyTransformer
                         reference.getAttribute(
                                 TorqueSchemaAttributeName.FOREIGN);
                 SourceElement foreignColumnElement
-                        = new RichSourceElementImpl(
+                        = new SourceElement(
                                 ReferenceChildElementName.FOREIGN_COLUMN);
                 SourceElement column
                         = FindHelper.findColumn(foreignTable, foreignColumnName);
-                foreignColumnElement.addChild(column);
-                reference.addChild(foreignColumnElement);
+                foreignColumnElement.getChildren().add(column);
+                reference.getChildren().add(foreignColumnElement);
             }
         }
 
@@ -192,7 +191,7 @@ public class OMForeignKeyTransformer
                             + referencedBySuffix;
 
                 SourceElement localFieldElement
-                        = new RichSourceElementImpl(
+                        = new SourceElement(
                                 ForeignKeyChildElementName.LOCAL_FIELD);
 
                 localFieldElement.setAttribute(
@@ -243,7 +242,7 @@ public class OMForeignKeyTransformer
                             beanSetterName);
                 }
 
-                foreignKey.addChild(localFieldElement);
+                foreignKey.getChildren().add(localFieldElement);
             }
             {
                 // the field name for the variable used
@@ -255,7 +254,7 @@ public class OMForeignKeyTransformer
                                     LOCAL_FIELD_NAME_SUFFIX_OPTION)
                         + referencedBySuffix;
                 SourceElement localFieldInBeanElement
-                        = new RichSourceElementImpl(
+                        = new SourceElement(
                                 ForeignKeyChildElementName.LOCAL_FIELD_IN_BEAN);
 
                 localFieldInBeanElement.setAttribute(
@@ -286,7 +285,7 @@ public class OMForeignKeyTransformer
                             JavaFieldAttributeName.SETTER_NAME,
                             setterName);
                 }
-                foreignKey.addChild(localFieldInBeanElement);
+                foreignKey.getChildren().add(localFieldInBeanElement);
 
             }
         }
@@ -341,7 +340,7 @@ public class OMForeignKeyTransformer
                                 TableAttributeName.DB_OBJECT_CLASS_NAME)
                             + referencedBySuffix;
                 SourceElement foreignFieldElement
-                        = new RichSourceElementImpl(
+                        = new SourceElement(
                                 ForeignKeyChildElementName.FOREIGN_FIELD);
 
                 foreignFieldElement.setAttribute(
@@ -505,7 +504,7 @@ public class OMForeignKeyTransformer
                                 .PEER_JOIN_ALL_EXCEPT_SELECT_METHOD,
                             peerJoinAllExceptSelectMethodName);
                 }
-                foreignKey.addChild(foreignFieldElement);
+                foreignKey.getChildren().add(foreignFieldElement);
             }
             {
                 // the field name for the variable used
@@ -518,7 +517,7 @@ public class OMForeignKeyTransformer
                                 FOREIGN_FIELD_NAME_SUFFIX_OPTION)
                             + referencedBySuffix;
                 SourceElement foreignFieldInBeanElement
-                        = new RichSourceElementImpl(
+                        = new SourceElement(
                             ForeignKeyChildElementName.FOREIGN_FIELD_IN_BEAN);
 
                 foreignFieldInBeanElement.setAttribute(
@@ -578,7 +577,7 @@ public class OMForeignKeyTransformer
                             JavaFieldAttributeName.SETTER_NAME,
                                 setterName);
                 }
-                foreignKey.addChild(foreignFieldInBeanElement);
+                foreignKey.getChildren().add(foreignFieldInBeanElement);
             }
         }
     }

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMReferencingForeignKeyTableTransformer.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMReferencingForeignKeyTableTransformer.java?rev=930722&r1=930721&r2=930722&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMReferencingForeignKeyTableTransformer.java (original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMReferencingForeignKeyTableTransformer.java Sun Apr  4 17:39:58 2010
@@ -23,7 +23,6 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.torque.gf.control.ControllerState;
-import org.apache.torque.gf.source.RichSourceElementImpl;
 import org.apache.torque.gf.source.SourceElement;
 import org.apache.torque.gf.source.transform.SourceTransformerException;
 import org.apache.torque.templates.TorqueSchemaAttributeName;
@@ -88,13 +87,13 @@ public class OMReferencingForeignKeyTabl
         }
 
         SourceElement referencingForeignKeysElement
-                = new RichSourceElementImpl(
+                = new SourceElement(
                         TableChildElementName.REFERENCING_FOREIGN_KEYS);
-        table.addChild(referencingForeignKeysElement);
+        table.getChildren().add(referencingForeignKeysElement);
 
         for (SourceElement foreignKey : referencingForeignKeys)
         {
-            referencingForeignKeysElement.addChild(foreignKey);
+            referencingForeignKeysElement.getChildren().add(foreignKey);
         }
     }
 }

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMTableTransformer.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMTableTransformer.java?rev=930722&r1=930721&r2=930722&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMTableTransformer.java (original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMTableTransformer.java Sun Apr  4 17:39:58 2010
@@ -25,7 +25,6 @@ import java.util.List;
 import org.apache.commons.lang.StringUtils;
 import org.apache.torque.gf.control.ControllerState;
 import org.apache.torque.gf.processor.string.Camelbacker;
-import org.apache.torque.gf.source.RichSourceElementImpl;
 import org.apache.torque.gf.source.SourceElement;
 import org.apache.torque.gf.source.transform.AttributeTransformer;
 import org.apache.torque.gf.source.transform.SourceTransformerException;
@@ -309,10 +308,10 @@ public class OMTableTransformer extends 
                                         tableElement.getName()));
                 }
                 SourceElement inheritanceColumnElement
-                        = new RichSourceElementImpl(
+                        = new SourceElement(
                                 TableChildElementName.INHERITANCE_COLUMN);
-                inheritanceColumnElement.addChild(columnElement);
-                tableElement.addChild(inheritanceColumnElement);
+                inheritanceColumnElement.getChildren().add(columnElement);
+                tableElement.getChildren().add(inheritanceColumnElement);
                 inheritanceFound = true;
             }
         }



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message