You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by dk...@apache.org on 2014/09/19 19:40:41 UTC

svn commit: r1626281 - in /webservices/xmlschema/trunk/xmlschema-walker/src: main/java/org/apache/ws/commons/schema/docpath/ test/java/org/apache/ws/commons/schema/docpath/ test/java/org/apache/ws/commons/schema/walker/

Author: dkulp
Date: Fri Sep 19 17:40:41 2014
New Revision: 1626281

URL: http://svn.apache.org/r1626281
Log:
[XMLSCHEMA-38] Update the xmlschema-walker to properly define the generics
Patch from Michael Pigott applied

Modified:
    webservices/xmlschema/trunk/xmlschema-walker/src/main/java/org/apache/ws/commons/schema/docpath/XmlSchemaDocumentNode.java
    webservices/xmlschema/trunk/xmlschema-walker/src/main/java/org/apache/ws/commons/schema/docpath/XmlSchemaPathFinder.java
    webservices/xmlschema/trunk/xmlschema-walker/src/test/java/org/apache/ws/commons/schema/docpath/ExpectedElement.java
    webservices/xmlschema/trunk/xmlschema-walker/src/test/java/org/apache/ws/commons/schema/docpath/ExpectedNode.java
    webservices/xmlschema/trunk/xmlschema-walker/src/test/java/org/apache/ws/commons/schema/docpath/ExpectedPathNode.java
    webservices/xmlschema/trunk/xmlschema-walker/src/test/java/org/apache/ws/commons/schema/docpath/TestXmlSchemaNamespaceContext.java
    webservices/xmlschema/trunk/xmlschema-walker/src/test/java/org/apache/ws/commons/schema/docpath/TestXmlSchemaPathFinder.java
    webservices/xmlschema/trunk/xmlschema-walker/src/test/java/org/apache/ws/commons/schema/walker/TestSchemaWalker.java

Modified: webservices/xmlschema/trunk/xmlschema-walker/src/main/java/org/apache/ws/commons/schema/docpath/XmlSchemaDocumentNode.java
URL: http://svn.apache.org/viewvc/webservices/xmlschema/trunk/xmlschema-walker/src/main/java/org/apache/ws/commons/schema/docpath/XmlSchemaDocumentNode.java?rev=1626281&r1=1626280&r2=1626281&view=diff
==============================================================================
--- webservices/xmlschema/trunk/xmlschema-walker/src/main/java/org/apache/ws/commons/schema/docpath/XmlSchemaDocumentNode.java (original)
+++ webservices/xmlschema/trunk/xmlschema-walker/src/main/java/org/apache/ws/commons/schema/docpath/XmlSchemaDocumentNode.java Fri Sep 19 17:40:41 2014
@@ -46,7 +46,7 @@ public final class XmlSchemaDocumentNode
     private XmlSchemaStateMachineNode stateMachineNode;
     private XmlSchemaDocumentNode<U> parent;
     private List<SortedMap<Integer, XmlSchemaDocumentNode<U>>> children;
-    private List<XmlSchemaPathNode> visitors;
+    private List<XmlSchemaPathNode<U, ?>> visitors;
     private boolean receivedContent;
     private U userDefinedContent;
 
@@ -120,7 +120,7 @@ public final class XmlSchemaDocumentNode
      * many occurrences are active via the current path winding through the
      * schema.
      */
-    void addVisitor(XmlSchemaPathNode path) {
+    void addVisitor(XmlSchemaPathNode<U, ?> path) {
         if (path.getDocumentNode() != this) {
             throw new IllegalArgumentException("Path node must have this XmlSchemaDocumentNode "
                                                + "as its document node.");
@@ -137,7 +137,7 @@ public final class XmlSchemaDocumentNode
         }
 
         if (visitors == null) {
-            visitors = new ArrayList<XmlSchemaPathNode>(4);
+            visitors = new ArrayList<XmlSchemaPathNode<U, ?>>(4);
         }
 
         if (children != null) {
@@ -155,7 +155,7 @@ public final class XmlSchemaDocumentNode
         visitors.add(path);
     }
 
-    boolean removeVisitor(XmlSchemaPathNode path) {
+    boolean removeVisitor(XmlSchemaPathNode<U, ?> path) {
         if ((visitors == null) || visitors.isEmpty()) {
             return false;
         }
@@ -230,7 +230,7 @@ public final class XmlSchemaDocumentNode
         }
     }
 
-    void set(XmlSchemaDocumentNode parent, XmlSchemaStateMachineNode stateMachineNode) {
+    void set(XmlSchemaDocumentNode<U> parent, XmlSchemaStateMachineNode stateMachineNode) {
 
         this.parent = parent;
         this.stateMachineNode = stateMachineNode;

Modified: webservices/xmlschema/trunk/xmlschema-walker/src/main/java/org/apache/ws/commons/schema/docpath/XmlSchemaPathFinder.java
URL: http://svn.apache.org/viewvc/webservices/xmlschema/trunk/xmlschema-walker/src/main/java/org/apache/ws/commons/schema/docpath/XmlSchemaPathFinder.java?rev=1626281&r1=1626280&r2=1626281&view=diff
==============================================================================
--- webservices/xmlschema/trunk/xmlschema-walker/src/main/java/org/apache/ws/commons/schema/docpath/XmlSchemaPathFinder.java (original)
+++ webservices/xmlschema/trunk/xmlschema-walker/src/main/java/org/apache/ws/commons/schema/docpath/XmlSchemaPathFinder.java Fri Sep 19 17:40:41 2014
@@ -49,7 +49,7 @@ import org.xml.sax.helpers.DefaultHandle
  * XML.
  * </p>
  */
-public final class XmlSchemaPathFinder extends DefaultHandler {
+public final class XmlSchemaPathFinder<U, V> extends DefaultHandler {
 
     /*
      * If a group loops back on itself, we don't want to loop until the stack
@@ -60,17 +60,17 @@ public final class XmlSchemaPathFinder e
 
     private final XmlSchemaNamespaceContext nsContext;
 
-    private XmlSchemaPathNode rootPathNode;
+    private XmlSchemaPathNode<U, V> rootPathNode;
 
-    private XmlSchemaPathNode currentPath;
+    private XmlSchemaPathNode<U, V> currentPath;
 
     private ArrayList<TraversedElement> traversedElements;
-    private ArrayList<DecisionPoint> decisionPoints;
+    private ArrayList<DecisionPoint<U, V>> decisionPoints;
 
     private ArrayList<QName> elementStack;
     private ArrayList<QName> anyStack;
 
-    private XmlSchemaPathManager pathMgr;
+    private XmlSchemaPathManager<U, V> pathMgr;
 
     /*
      * We want to keep track of all of the valid path segments to a particular
@@ -83,20 +83,22 @@ public final class XmlSchemaPathFinder e
      * directly after it, while leaving the new start node unlinked. Path
      * segments may also be recycled when a decision point is refuted.
      */
-    private final class PathSegment implements Comparable<PathSegment> {
+    private static final class PathSegment<U, V> implements Comparable<PathSegment<U, V>> {
 
-        private XmlSchemaPathNode start;
-        private XmlSchemaPathNode end;
-        private XmlSchemaPathNode afterStart;
+        private XmlSchemaPathManager<U, V> pathMgr;
+        private XmlSchemaPathNode<U, V> start;
+        private XmlSchemaPathNode<U, V> end;
+        private XmlSchemaPathNode<U, V> afterStart;
         private int length;
         private int afterStartPathIndex;
 
-        PathSegment(XmlSchemaPathNode node) {
+        PathSegment(XmlSchemaPathManager<U, V> pathMgr, XmlSchemaPathNode<U, V> node) {
+            this.pathMgr = pathMgr;
             set(node);
         }
 
         @Override
-        public int compareTo(PathSegment o) {
+        public int compareTo(PathSegment<U, V> o) {
             if (this == o) {
                 return 0;
             }
@@ -116,8 +118,7 @@ public final class XmlSchemaPathFinder e
                     return -1;
 
                 } else {
-                    throw new IllegalStateException(
-                                                    "The end nodes do not have the same machine node type, so one "
+                    throw new IllegalStateException("The end nodes do not have the same machine node type, so one "
                                                         + "should be an ELEMENT and the other should be an ANY.  "
                                                         + "However, this end node is a "
                                                         + end.getStateMachineNode().getNodeType()
@@ -138,8 +139,8 @@ public final class XmlSchemaPathFinder e
              */
             if ((thisLength > 0) && (thatLength > 0)) {
                 // Both paths have more than just one element.
-                XmlSchemaPathNode thisIter = afterStart;
-                XmlSchemaPathNode thatIter = o.getAfterStart();
+                XmlSchemaPathNode<U, V> thisIter = afterStart;
+                XmlSchemaPathNode<U, V> thatIter = o.getAfterStart();
 
                 while ((thisIter != null) && (thatIter != null)) {
                     if (thisIter.getDirection().getRank() < thatIter.getDirection().getRank()) {
@@ -200,7 +201,7 @@ public final class XmlSchemaPathFinder e
 
         int getLength() {
             if ((length == 0) && (start != end)) {
-                for (XmlSchemaPathNode iter = afterStart; iter != end; iter = iter.getNext()) {
+                for (XmlSchemaPathNode<U, V> iter = afterStart; iter != end; iter = iter.getNext()) {
                     ++length;
                 }
                 ++length; // (afterStart -> end) + start
@@ -214,9 +215,9 @@ public final class XmlSchemaPathFinder e
          * to know the newStart's path index to reach the clonedStartNode, so we
          * know how to properly link them later.
          */
-        void prepend(XmlSchemaPathNode newStart, int pathIndexToNextNode) {
+        void prepend(XmlSchemaPathNode<U, V> newStart, int pathIndexToNextNode) {
             // We need to clone start and make it the afterStart.
-            final XmlSchemaPathNode clonedStartNode = pathMgr.clone(start);
+            final XmlSchemaPathNode<U, V> clonedStartNode = pathMgr.clone(start);
 
             if (afterStart != null) {
                 afterStart.setPreviousNode(clonedStartNode);
@@ -234,15 +235,15 @@ public final class XmlSchemaPathFinder e
             length = 0; // Force a recalculation.
         }
 
-        XmlSchemaPathNode getStart() {
+        XmlSchemaPathNode<U, V> getStart() {
             return start;
         }
 
-        XmlSchemaPathNode getEnd() {
+        XmlSchemaPathNode<U, V> getEnd() {
             return end;
         }
 
-        XmlSchemaPathNode getAfterStart() {
+        XmlSchemaPathNode<U, V> getAfterStart() {
             return afterStart;
         }
 
@@ -250,7 +251,7 @@ public final class XmlSchemaPathFinder e
             return afterStartPathIndex;
         }
 
-        void set(XmlSchemaPathNode node) {
+        void set(XmlSchemaPathNode<U, V> node) {
             if (node == null) {
                 throw new IllegalArgumentException("DocumentPathNode cannot be null.");
             }
@@ -270,7 +271,7 @@ public final class XmlSchemaPathFinder e
             str.append(start.getStateMachineNode()).append(" ]");
 
             if (afterStart != null) {
-                XmlSchemaPathNode path = afterStart;
+                XmlSchemaPathNode<U, V> path = afterStart;
 
                 do {
                     str.append(" [").append(path.getDirection()).append(" | ");
@@ -297,16 +298,16 @@ public final class XmlSchemaPathFinder e
      * shortest through the longest, until we find a path that successfully
      * navigates both the document and the schema.
      */
-    private static class DecisionPoint {
+    private static class DecisionPoint<U, V> {
 
-        private final XmlSchemaPathNode decisionPoint;
-        private final List<PathSegment> choices;
+        private final XmlSchemaPathNode<U, V> decisionPoint;
+        private final List<PathSegment<U, V>> choices;
         private final int traversedElementIndex;
         private final ArrayList<QName> elementStack;
         private final ArrayList<QName> anyStack;
 
-        DecisionPoint(XmlSchemaPathNode decisionPoint, List<PathSegment> choices, int traversedElementIndex,
-                      ArrayList<QName> elementStack, ArrayList<QName> anyStack) {
+        DecisionPoint(XmlSchemaPathNode<U, V> decisionPoint, List<PathSegment<U, V>> choices,
+                      int traversedElementIndex, ArrayList<QName> elementStack, ArrayList<QName> anyStack) {
 
             if (decisionPoint == null) {
                 throw new IllegalArgumentException("The decision point path node cannot be null.");
@@ -337,7 +338,7 @@ public final class XmlSchemaPathFinder e
          * <code>null</code> if all <code>PathSegment</code>s have been
          * followed.
          */
-        PathSegment tryNextPath() {
+        PathSegment<U, V> tryNextPath() {
             if (choices.isEmpty()) {
                 return null;
             } else {
@@ -345,7 +346,7 @@ public final class XmlSchemaPathFinder e
             }
         }
 
-        XmlSchemaPathNode getDecisionPoint() {
+        XmlSchemaPathNode<U, V> getDecisionPoint() {
             return decisionPoint;
         }
 
@@ -354,7 +355,7 @@ public final class XmlSchemaPathFinder e
         }
 
         ArrayList<QName> getAnyStack() {
-            return (anyStack == null) ? null : ((ArrayList<QName>)anyStack.clone());
+            return (anyStack == null) ? null : new ArrayList<QName>(anyStack);
         }
 
         @Override
@@ -367,7 +368,7 @@ public final class XmlSchemaPathFinder e
             str.append(decisionPoint.getStateMachineNode());
             str.append(" ]").append(nl);
 
-            for (PathSegment choice : choices) {
+            for (PathSegment<U, V> choice : choices) {
                 str.append('\t').append(choice).append(nl);
             }
 
@@ -418,7 +419,7 @@ public final class XmlSchemaPathFinder e
      * documents.
      */
     public XmlSchemaPathFinder(XmlSchemaStateMachineNode root) {
-        pathMgr = new XmlSchemaPathManager();
+        pathMgr = new XmlSchemaPathManager<U, V>();
         nsContext = new XmlSchemaNamespaceContext();
 
         rootPathNode = pathMgr.createStartPathNode(XmlSchemaPathNode.Direction.CHILD, root);
@@ -503,9 +504,9 @@ public final class XmlSchemaPathFinder e
             }
 
             // 1. Find possible paths.
-            List<PathSegment> possiblePaths = find(currentPath, elemQName);
+            List<PathSegment<U, V>> possiblePaths = find(currentPath, elemQName);
 
-            PathSegment nextPath = null;
+            PathSegment<U, V> nextPath = null;
 
             if ((possiblePaths != null) && !possiblePaths.isEmpty()) {
                 /*
@@ -515,12 +516,12 @@ public final class XmlSchemaPathFinder e
                  * paths.
                  */
                 if (possiblePaths.size() > 1) {
-                    final DecisionPoint decisionPoint = new DecisionPoint(currentPath, possiblePaths,
-                                                                          traversedElements.size(),
-                                                                          elementStack, anyStack);
+                    final DecisionPoint<U, V> decisionPoint =
+                        new DecisionPoint<U, V>(currentPath, possiblePaths, traversedElements.size(),
+                                                elementStack, anyStack);
 
                     if (decisionPoints == null) {
-                        decisionPoints = new ArrayList<DecisionPoint>(4);
+                        decisionPoints = new ArrayList<DecisionPoint<U, V>>(4);
                     }
                     decisionPoints.add(decisionPoint);
 
@@ -545,7 +546,7 @@ public final class XmlSchemaPathFinder e
                      * the top path (the one we just tried), and select the next
                      * one.
                      */
-                    final DecisionPoint priorPoint = decisionPoints.get(decisionPoints.size() - 1);
+                    final DecisionPoint<U, V> priorPoint = decisionPoints.get(decisionPoints.size() - 1);
 
                     nextPath = priorPoint.tryNextPath();
 
@@ -597,9 +598,9 @@ public final class XmlSchemaPathFinder e
                                 break;
 
                             } else if (possiblePaths.size() > 1) {
-                                final DecisionPoint decisionPoint = new DecisionPoint(currentPath,
-                                                                                      possiblePaths, index,
-                                                                                      elementStack, anyStack);
+                                final DecisionPoint<U, V> decisionPoint =
+                                    new DecisionPoint<U, V>(currentPath, possiblePaths, index, elementStack, anyStack);
+
                                 decisionPoints.add(decisionPoint);
                                 nextPath = decisionPoint.tryNextPath();
 
@@ -651,9 +652,10 @@ public final class XmlSchemaPathFinder e
 
                         } else if (te.traversal.equals(TraversedElement.Traversal.CONTENT)) {
 
-                            final XmlSchemaPathNode contentPath = pathMgr
-                                .addParentSiblingOrContentNodeToPath(currentPath,
-                                                                     XmlSchemaPathNode.Direction.CONTENT);
+                            final XmlSchemaPathNode<U, V> contentPath =
+                                pathMgr
+                                  .addParentSiblingOrContentNodeToPath(currentPath,
+                                                                       XmlSchemaPathNode.Direction.CONTENT);
 
                             currentPath.setNextNode(-1, contentPath);
                             currentPath = contentPath;
@@ -685,9 +687,10 @@ public final class XmlSchemaPathFinder e
                         continue;
 
                     } else if (possiblePaths.size() > 1) {
-                        final DecisionPoint decisionPoint = new DecisionPoint(currentPath, possiblePaths,
-                                                                              traversedElements.size(),
-                                                                              elementStack, anyStack);
+                        final DecisionPoint<U, V> decisionPoint =
+                            new DecisionPoint<U, V>(currentPath, possiblePaths, traversedElements.size(),
+                                                    elementStack, anyStack);
+
                         decisionPoints.add(decisionPoint);
                         nextPath = decisionPoint.tryNextPath();
                     } else {
@@ -804,7 +807,7 @@ public final class XmlSchemaPathFinder e
 
             currentPath.getDocumentNode().setReceivedContent(true);
 
-            final XmlSchemaPathNode contentPath = pathMgr
+            final XmlSchemaPathNode<U, V> contentPath = pathMgr
                 .addParentSiblingOrContentNodeToPath(currentPath, XmlSchemaPathNode.Direction.CONTENT);
 
             currentPath.setNextNode(-1, contentPath);
@@ -921,12 +924,12 @@ public final class XmlSchemaPathFinder e
      * traversed.
      * </p>
      */
-    public XmlSchemaPathNode getXmlSchemaTraversal() {
+    public XmlSchemaPathNode<U, V> getXmlSchemaTraversal() {
         return rootPathNode;
     }
 
-    private static Fulfillment isPositionFulfilled(XmlSchemaPathNode currentPath, List<Integer> possiblePaths) {
-
+    private static <U, V> Fulfillment isPositionFulfilled(XmlSchemaPathNode<U, V> currentPath,
+                                                          List<Integer> possiblePaths) {
         boolean completelyFulfilled = true;
         boolean partiallyFulfilled = true;
 
@@ -957,7 +960,7 @@ public final class XmlSchemaPathFinder e
 
         final List<XmlSchemaStateMachineNode> nextStates = state.getPossibleNextStates();
 
-        Map<Integer, XmlSchemaDocumentNode> children = null;
+        Map<Integer, XmlSchemaDocumentNode<U>> children = null;
         if (currentPath.getDocumentNode() != null) {
             children = currentPath.getDocumentNode().getChildren();
         }
@@ -981,7 +984,7 @@ public final class XmlSchemaPathFinder e
                 XmlSchemaStateMachineNode nextState = nextStates.get(stateIndex);
 
                 if ((children != null) && children.containsKey(stateIndex)) {
-                    final XmlSchemaDocumentNode child = children.get(stateIndex);
+                    final XmlSchemaDocumentNode<U> child = children.get(stateIndex);
                     final int iteration = child.getIteration();
                     if (iteration >= nextState.getMinOccurs()) {
                         groupPartiallyFulfilled = true;
@@ -1019,7 +1022,7 @@ public final class XmlSchemaPathFinder e
                 final XmlSchemaStateMachineNode nextState = nextStates.get(stateIndex);
 
                 if ((children != null) && children.containsKey(stateIndex)) {
-                    final XmlSchemaDocumentNode child = children.get(stateIndex);
+                    final XmlSchemaDocumentNode<U> child = children.get(stateIndex);
                     final int iteration = child.getIteration();
                     if (iteration < nextState.getMinOccurs()) {
                         partiallyFulfilled = false;
@@ -1055,7 +1058,7 @@ public final class XmlSchemaPathFinder e
                 final XmlSchemaStateMachineNode nextState = nextStates.get(stateIndex);
 
                 if ((children != null) && children.containsKey(stateIndex)) {
-                    final XmlSchemaDocumentNode child = children.get(stateIndex);
+                    final XmlSchemaDocumentNode<U> child = children.get(stateIndex);
                     if (child.getIteration() < nextState.getMinOccurs()) {
                         partiallyFulfilled = false;
                     }
@@ -1093,9 +1096,9 @@ public final class XmlSchemaPathFinder e
         return fulfillment;
     }
 
-    private List<PathSegment> find(XmlSchemaPathNode startNode, QName elemQName) {
+    private List<PathSegment<U, V>> find(XmlSchemaPathNode<U, V> startNode, QName elemQName) {
 
-        final XmlSchemaPathNode startOfPath = startNode;
+        final XmlSchemaPathNode<U, V> startOfPath = startNode;
 
         if (startNode.getStateMachineNode().getNodeType().equals(XmlSchemaStateMachineNode.Type.ELEMENT)
             && !elementStack.isEmpty()
@@ -1143,20 +1146,20 @@ public final class XmlSchemaPathFinder e
                                                         .getQName());
             }
 
-            final XmlSchemaPathNode childPath = pathMgr.addChildNodeToPath(startNode, 0);
+            final XmlSchemaPathNode<U, V> childPath = pathMgr.addChildNodeToPath(startNode, 0);
 
             startNode.setNextNode(0, childPath);
             startNode = childPath;
         }
 
-        final List<PathSegment> choices = find(startNode, elemQName, null);
+        final List<PathSegment<U, V>> choices = find(startNode, elemQName, null);
 
         if ((choices != null) && (startOfPath != startNode)) {
             /*
              * If we moved down to the children, we need to prepend the path
              * with the original start node.
              */
-            for (PathSegment choice : choices) {
+            for (PathSegment<U, V> choice : choices) {
                 choice.prepend(startOfPath, 0);
             }
         }
@@ -1164,15 +1167,15 @@ public final class XmlSchemaPathFinder e
         return choices;
     }
 
-    private List<PathSegment> find(XmlSchemaPathNode startNode, QName elemQName,
+    private List<PathSegment<U, V>> find(XmlSchemaPathNode<U, V> startNode, QName elemQName,
                                    XmlSchemaStateMachineNode doNotFollow) {
 
         final ArrayList<Integer> childrenNodes = new ArrayList<Integer>();
         final boolean isFulfilled = !isPositionFulfilled(startNode, childrenNodes).equals(Fulfillment.NOT);
 
         // First, try searching down the tree.
-        List<PathSegment> choices = null;
-        List<PathSegment> currChoices = null;
+        List<PathSegment<U, V>> choices = null;
+        List<PathSegment<U, V>> currChoices = null;
 
         if (startNode.getIteration() > startNode.getDocIteration()) {
             choices = find(startNode, elemQName, 0);
@@ -1185,11 +1188,11 @@ public final class XmlSchemaPathFinder e
                      */
                     continue;
                 }
-                final XmlSchemaPathNode currPath = pathMgr.addChildNodeToPath(startNode, childPath);
+                final XmlSchemaPathNode<U, V> currPath = pathMgr.addChildNodeToPath(startNode, childPath);
 
                 currChoices = find(currPath, elemQName, 0);
                 if (currChoices != null) {
-                    for (PathSegment choice : currChoices) {
+                    for (PathSegment<U, V> choice : currChoices) {
                         choice.prepend(startNode, childPath);
                     }
 
@@ -1207,13 +1210,13 @@ public final class XmlSchemaPathFinder e
 
             // Try siblings.
             if (startNode.getIteration() < startNode.getMaxOccurs()) {
-                final XmlSchemaPathNode siblingPath = pathMgr
+                final XmlSchemaPathNode<U, V> siblingPath = pathMgr
                     .addParentSiblingOrContentNodeToPath(startNode, XmlSchemaPathNode.Direction.SIBLING);
                 siblingPath.setIteration(startNode.getIteration() + 1);
 
                 currChoices = find(siblingPath, elemQName, 0);
                 if (currChoices != null) {
-                    for (PathSegment choice : currChoices) {
+                    for (PathSegment<U, V> choice : currChoices) {
                         choice.prepend(startNode, -1);
                     }
 
@@ -1231,7 +1234,7 @@ public final class XmlSchemaPathFinder e
                 return choices;
             }
 
-            final XmlSchemaPathNode path = pathMgr
+            final XmlSchemaPathNode<U, V> path = pathMgr
                 .addParentSiblingOrContentNodeToPath(startNode, XmlSchemaPathNode.Direction.PARENT);
 
             if (path.getStateMachineNode().getNodeType().equals(XmlSchemaStateMachineNode.Type.ELEMENT)
@@ -1240,10 +1243,10 @@ public final class XmlSchemaPathFinder e
                 return choices;
             }
 
-            final List<PathSegment> pathsOfParent = find(path, elemQName, startNode.getStateMachineNode());
+            final List<PathSegment<U, V>> pathsOfParent = find(path, elemQName, startNode.getStateMachineNode());
 
             if (pathsOfParent != null) {
-                for (PathSegment choice : pathsOfParent) {
+                for (PathSegment<U, V> choice : pathsOfParent) {
                     choice.prepend(startNode, -1);
                 }
 
@@ -1261,7 +1264,7 @@ public final class XmlSchemaPathFinder e
         return choices;
     }
 
-    private List<PathSegment> find(XmlSchemaPathNode startNode, QName elemQName, int currDepth) {
+    private List<PathSegment<U, V>> find(XmlSchemaPathNode<U, V> startNode, QName elemQName, int currDepth) {
 
         final XmlSchemaStateMachineNode state = startNode.getStateMachineNode();
 
@@ -1301,15 +1304,15 @@ public final class XmlSchemaPathFinder e
                                             + " has no children.  Found when processing " + elemQName);
         }
 
-        List<PathSegment> choices = null;
+        List<PathSegment<U, V>> choices = null;
 
         switch (state.getNodeType()) {
         case ELEMENT: {
             if (state.getElement().getQName().equals(elemQName)
                 && startNode.getIteration() <= state.getMaxOccurs()) {
 
-                choices = new ArrayList<PathSegment>(1);
-                choices.add(new PathSegment(startNode));
+                choices = new ArrayList<PathSegment<U, V>>(1);
+                choices.add(new PathSegment<U, V>(pathMgr, startNode));
             }
         }
             break;
@@ -1333,7 +1336,7 @@ public final class XmlSchemaPathFinder e
                 .getPossibleNextStates().size(); ++stateIndex) {
 
                 // Process child.
-                final XmlSchemaPathNode nextPath = pathMgr.addChildNodeToPath(startNode, stateIndex);
+                final XmlSchemaPathNode<U, V> nextPath = pathMgr.addChildNodeToPath(startNode, stateIndex);
 
                 /*
                  * Both the tree node's and the document path node's state
@@ -1352,10 +1355,10 @@ public final class XmlSchemaPathFinder e
 
                 final boolean reachedMinOccurs = (nextPath.getDocIteration() >= nextPath.getMinOccurs());
 
-                final List<PathSegment> seqPaths = find(nextPath, elemQName, currDepth + 1);
+                final List<PathSegment<U, V>> seqPaths = find(nextPath, elemQName, currDepth + 1);
 
                 if (seqPaths != null) {
-                    for (PathSegment seqPath : seqPaths) {
+                    for (PathSegment<U, V> seqPath : seqPaths) {
                         seqPath.prepend(startNode, stateIndex);
                     }
 
@@ -1410,12 +1413,12 @@ public final class XmlSchemaPathFinder e
                                                         + nextState.getNodeType() + '.');
                 }
 
-                final XmlSchemaPathNode nextPath = pathMgr.addChildNodeToPath(startNode, stateIndex);
+                final XmlSchemaPathNode<U, V> nextPath = pathMgr.addChildNodeToPath(startNode, stateIndex);
 
-                final List<PathSegment> choicePaths = find(nextPath, elemQName, currDepth + 1);
+                final List<PathSegment<U, V>> choicePaths = find(nextPath, elemQName, currDepth + 1);
 
                 if (choicePaths != null) {
-                    for (PathSegment choicePath : choicePaths) {
+                    for (PathSegment<U, V> choicePath : choicePaths) {
                         choicePath.prepend(startNode, stateIndex);
                     }
 
@@ -1447,8 +1450,8 @@ public final class XmlSchemaPathFinder e
             final XmlSchemaAny any = state.getAny();
 
             if (any.getNamespace() == null) {
-                choices = new ArrayList<PathSegment>(1);
-                choices.add(new PathSegment(startNode));
+                choices = new ArrayList<PathSegment<U, V>>(1);
+                choices.add(new PathSegment<U, V>(pathMgr, startNode));
                 break;
             }
 
@@ -1497,8 +1500,8 @@ public final class XmlSchemaPathFinder e
             }
 
             if (matches) {
-                choices = new ArrayList<PathSegment>(1);
-                choices.add(new PathSegment(startNode));
+                choices = new ArrayList<PathSegment<U, V>>(1);
+                choices.add(new PathSegment<U, V>(pathMgr, startNode));
             }
         }
             break;
@@ -1537,8 +1540,8 @@ public final class XmlSchemaPathFinder e
                                             + state.getNodeType());
         }
 
-        XmlSchemaDocumentNode iter = currentPath.getDocumentNode();
-        XmlSchemaPathNode path = currentPath;
+        XmlSchemaDocumentNode<U> iter = currentPath.getDocumentNode();
+        XmlSchemaPathNode<U, V> path = currentPath;
 
         do {
             if (iter.getIteration() < iter.getStateMachineNode().getMaxOccurs()) {
@@ -1556,7 +1559,7 @@ public final class XmlSchemaPathFinder e
                 break;
             }
 
-            final XmlSchemaPathNode nextPath = pathMgr
+            final XmlSchemaPathNode<U, V> nextPath = pathMgr
                 .addParentSiblingOrContentNodeToPath(path, XmlSchemaPathNode.Direction.PARENT);
 
             path.setNextNode(-1, nextPath);
@@ -1568,7 +1571,7 @@ public final class XmlSchemaPathFinder e
     }
 
     private void walkUpToElement(QName element) {
-        XmlSchemaDocumentNode iter = currentPath.getDocumentNode();
+        XmlSchemaDocumentNode<U> iter = currentPath.getDocumentNode();
 
         if (iter.getStateMachineNode().getNodeType().equals(XmlSchemaStateMachineNode.Type.ELEMENT)
             && iter.getStateMachineNode().getElement().getQName().equals(element)) {
@@ -1580,7 +1583,7 @@ public final class XmlSchemaPathFinder e
 
             iter = iter.getParent();
             if (iter != null) {
-                final XmlSchemaPathNode nextPath = pathMgr
+                final XmlSchemaPathNode<U, V> nextPath = pathMgr
                     .addParentSiblingOrContentNodeToPath(currentPath, XmlSchemaPathNode.Direction.PARENT);
 
                 currentPath.setNextNode(-1, nextPath);
@@ -1597,7 +1600,7 @@ public final class XmlSchemaPathFinder e
         }
     }
 
-    private void followPath(PathSegment path) {
+    private void followPath(PathSegment<U, V> path) {
         switch (path.getEnd().getStateMachineNode().getNodeType()) {
         case ELEMENT:
         case ANY:
@@ -1607,7 +1610,7 @@ public final class XmlSchemaPathFinder e
         }
 
         // Join the start element with the new path.
-        XmlSchemaPathNode startNode = path.getStart();
+        XmlSchemaPathNode<U, V> startNode = path.getStart();
 
         if (path.getAfterStart() != null) {
             startNode.setNextNode(path.getAfterStartPathIndex(), path.getAfterStart());
@@ -1665,7 +1668,7 @@ public final class XmlSchemaPathFinder e
 
     private XmlSchemaStateMachineNode getStateMachineOfOwningElement() {
         QName element = elementStack.get(elementStack.size() - 1);
-        XmlSchemaDocumentNode iter = currentPath.getDocumentNode();
+        XmlSchemaDocumentNode<U> iter = currentPath.getDocumentNode();
 
         if (iter.getStateMachineNode().getNodeType().equals(XmlSchemaStateMachineNode.Type.ELEMENT)
             && iter.getStateMachineNode().getElement().getQName().equals(element)) {

Modified: webservices/xmlschema/trunk/xmlschema-walker/src/test/java/org/apache/ws/commons/schema/docpath/ExpectedElement.java
URL: http://svn.apache.org/viewvc/webservices/xmlschema/trunk/xmlschema-walker/src/test/java/org/apache/ws/commons/schema/docpath/ExpectedElement.java?rev=1626281&r1=1626280&r2=1626281&view=diff
==============================================================================
--- webservices/xmlschema/trunk/xmlschema-walker/src/test/java/org/apache/ws/commons/schema/docpath/ExpectedElement.java (original)
+++ webservices/xmlschema/trunk/xmlschema-walker/src/test/java/org/apache/ws/commons/schema/docpath/ExpectedElement.java Fri Sep 19 17:40:41 2014
@@ -35,7 +35,7 @@ class ExpectedElement {
         this.typeInfo = typeInfo;
     }
 
-    void validate(XmlSchemaDocumentNode docNode) {
+    void validate(XmlSchemaDocumentNode<?> docNode) {
         String qName = docNode.getStateMachineNode().getElement().getQName().toString();
 
         XmlSchemaTypeInfo actType = docNode.getStateMachineNode().getElementType();

Modified: webservices/xmlschema/trunk/xmlschema-walker/src/test/java/org/apache/ws/commons/schema/docpath/ExpectedNode.java
URL: http://svn.apache.org/viewvc/webservices/xmlschema/trunk/xmlschema-walker/src/test/java/org/apache/ws/commons/schema/docpath/ExpectedNode.java?rev=1626281&r1=1626280&r2=1626281&view=diff
==============================================================================
--- webservices/xmlschema/trunk/xmlschema-walker/src/test/java/org/apache/ws/commons/schema/docpath/ExpectedNode.java (original)
+++ webservices/xmlschema/trunk/xmlschema-walker/src/test/java/org/apache/ws/commons/schema/docpath/ExpectedNode.java Fri Sep 19 17:40:41 2014
@@ -51,7 +51,7 @@ public class ExpectedNode {
         this.elemQName = elemQName;
     }
 
-    static void validate(String msg, ExpectedNode exp, XmlSchemaDocumentNode docNode,
+    static <U> void validate(String msg, ExpectedNode exp, XmlSchemaDocumentNode<U> docNode,
                          Map<QName, ExpectedElement> expElements) {
 
         assertEquals(msg, exp.nodeType, docNode.getStateMachineNode().getNodeType());
@@ -75,13 +75,13 @@ public class ExpectedNode {
         for (int iteration = 1; iteration <= docNode.getIteration(); ++iteration) {
             SortedMap<Integer, ExpectedNode> expected = exp.children.get(iteration - 1);
 
-            SortedMap<Integer, XmlSchemaDocumentNode> actual = docNode.getChildren(iteration);
+            SortedMap<Integer, XmlSchemaDocumentNode<U>> actual = docNode.getChildren(iteration);
 
             assertEquals(msg + ", iteration=" + iteration + "; " + exp.nodeType, expected.size(),
                          (actual == null) ? 0 : actual.size());
 
             if (actual != null) {
-                for (Map.Entry<Integer, XmlSchemaDocumentNode> actEntry : actual.entrySet()) {
+                for (Map.Entry<Integer, XmlSchemaDocumentNode<U>> actEntry : actual.entrySet()) {
                     ExpectedNode expNode = expected.get(actEntry.getKey());
                     assertNotNull(msg + ", iteration=" + iteration + ", child = " + actEntry.getKey()
                                   + ": entry " + actEntry.getKey() + " is not expected.", expNode);

Modified: webservices/xmlschema/trunk/xmlschema-walker/src/test/java/org/apache/ws/commons/schema/docpath/ExpectedPathNode.java
URL: http://svn.apache.org/viewvc/webservices/xmlschema/trunk/xmlschema-walker/src/test/java/org/apache/ws/commons/schema/docpath/ExpectedPathNode.java?rev=1626281&r1=1626280&r2=1626281&view=diff
==============================================================================
--- webservices/xmlschema/trunk/xmlschema-walker/src/test/java/org/apache/ws/commons/schema/docpath/ExpectedPathNode.java (original)
+++ webservices/xmlschema/trunk/xmlschema-walker/src/test/java/org/apache/ws/commons/schema/docpath/ExpectedPathNode.java Fri Sep 19 17:40:41 2014
@@ -37,7 +37,7 @@ class ExpectedPathNode {
         expIteration = expectedIteration;
     }
 
-    void validate(int pathIndex, XmlSchemaPathNode actualPathNode) {
+    void validate(int pathIndex, XmlSchemaPathNode<?, ?> actualPathNode) {
         assertEquals("Path Index: " + pathIndex, expDirection, actualPathNode.getDirection());
 
         ExpectedNode.validate("Path Index: " + pathIndex, expDocNode, actualPathNode.getDocumentNode(), null);

Modified: webservices/xmlschema/trunk/xmlschema-walker/src/test/java/org/apache/ws/commons/schema/docpath/TestXmlSchemaNamespaceContext.java
URL: http://svn.apache.org/viewvc/webservices/xmlschema/trunk/xmlschema-walker/src/test/java/org/apache/ws/commons/schema/docpath/TestXmlSchemaNamespaceContext.java?rev=1626281&r1=1626280&r2=1626281&view=diff
==============================================================================
--- webservices/xmlschema/trunk/xmlschema-walker/src/test/java/org/apache/ws/commons/schema/docpath/TestXmlSchemaNamespaceContext.java (original)
+++ webservices/xmlschema/trunk/xmlschema-walker/src/test/java/org/apache/ws/commons/schema/docpath/TestXmlSchemaNamespaceContext.java Fri Sep 19 17:40:41 2014
@@ -249,7 +249,7 @@ public class TestXmlSchemaNamespaceConte
         assertEquals(expected.length, found);
     }
 
-    static void assertArrayEquality(String[] expected, Iterator actual) {
+    static void assertArrayEquality(String[] expected, Iterator<?> actual) {
         HashSet<String> expSet = new HashSet<String>();
         for (String exp : expected) {
             expSet.add(exp);

Modified: webservices/xmlschema/trunk/xmlschema-walker/src/test/java/org/apache/ws/commons/schema/docpath/TestXmlSchemaPathFinder.java
URL: http://svn.apache.org/viewvc/webservices/xmlschema/trunk/xmlschema-walker/src/test/java/org/apache/ws/commons/schema/docpath/TestXmlSchemaPathFinder.java?rev=1626281&r1=1626280&r2=1626281&view=diff
==============================================================================
--- webservices/xmlschema/trunk/xmlschema-walker/src/test/java/org/apache/ws/commons/schema/docpath/TestXmlSchemaPathFinder.java (original)
+++ webservices/xmlschema/trunk/xmlschema-walker/src/test/java/org/apache/ws/commons/schema/docpath/TestXmlSchemaPathFinder.java Fri Sep 19 17:40:41 2014
@@ -74,7 +74,7 @@ public class TestXmlSchemaPathFinder {
 
         final File xmlFile = UtilsForTests.buildFile("src", "test", "resources", "test1_root.xml");
 
-        XmlSchemaPathNode traversal = runTest(schemaFile, xmlFile, root);
+        XmlSchemaPathNode<Void, Void> traversal = runTest(schemaFile, xmlFile, root);
 
         Map<QName, ExpectedElement> expectedElements = new HashMap<QName, ExpectedElement>();
 
@@ -105,7 +105,7 @@ public class TestXmlSchemaPathFinder {
 
         final File xmlFile = UtilsForTests.buildFile("src", "test", "resources", "test2_children.xml");
 
-        XmlSchemaPathNode traversal = runTest(schemaFile, xmlFile, root);
+        XmlSchemaPathNode<Void, Void> traversal = runTest(schemaFile, xmlFile, root);
 
         Map<QName, ExpectedElement> expectedElements = new HashMap<QName, ExpectedElement>();
 
@@ -227,7 +227,7 @@ public class TestXmlSchemaPathFinder {
 
         final File xmlFile = UtilsForTests.buildFile("src", "test", "resources", "test3_grandchildren.xml");
 
-        XmlSchemaPathNode traversal = runTest(schemaFile, xmlFile, root);
+        XmlSchemaPathNode<Void, Void> traversal = runTest(schemaFile, xmlFile, root);
 
         Map<QName, ExpectedElement> expectedElements = new HashMap<QName, ExpectedElement>();
 
@@ -728,7 +728,7 @@ public class TestXmlSchemaPathFinder {
             }
         }
 
-        XmlSchemaPathNode traversal = runTest(xmlSchemaCollection, xmlFile, root);
+        XmlSchemaPathNode<Void, Void> traversal = runTest(xmlSchemaCollection, xmlFile, root);
 
         Map<QName, ExpectedElement> expectedElements = new HashMap<QName, ExpectedElement>();
 
@@ -1252,7 +1252,7 @@ public class TestXmlSchemaPathFinder {
         validate(expPath, traversal);
     }
 
-    private XmlSchemaPathNode runTest(File schemaFile, File xmlFile, QName root) throws Exception {
+    private <U, V> XmlSchemaPathNode<U, V> runTest(File schemaFile, File xmlFile, QName root) throws Exception {
 
         XmlSchemaCollection xmlSchemaCollection = new XmlSchemaCollection();
 
@@ -1269,7 +1269,7 @@ public class TestXmlSchemaPathFinder {
         return runTest(xmlSchemaCollection, xmlFile, root);
     }
 
-    private XmlSchemaPathNode runTest(XmlSchemaCollection xmlSchemaCollection, File xmlFile, QName root)
+    private <U, V> XmlSchemaPathNode<U, V> runTest(XmlSchemaCollection xmlSchemaCollection, File xmlFile, QName root)
         throws Exception {
 
         XmlSchemaStateMachineGenerator stateMachineGen = new XmlSchemaStateMachineGenerator();
@@ -1282,7 +1282,7 @@ public class TestXmlSchemaPathFinder {
 
         XmlSchemaStateMachineNode stateMachine = stateMachineGen.getStartNode();
 
-        XmlSchemaPathFinder pathFinder = new XmlSchemaPathFinder(stateMachine);
+        XmlSchemaPathFinder<U, V> pathFinder = new XmlSchemaPathFinder<U, V>(stateMachine);
 
         Document xmlDoc = docBuilder.parse(xmlFile);
 
@@ -1293,9 +1293,9 @@ public class TestXmlSchemaPathFinder {
         return pathFinder.getXmlSchemaTraversal();
     }
 
-    void validate(ArrayList<ExpectedPathNode> expPath, XmlSchemaPathNode start) {
-        XmlSchemaPathNode prev = null;
-        XmlSchemaPathNode curr = start;
+    <U, V> void validate(ArrayList<ExpectedPathNode> expPath, XmlSchemaPathNode<U, V> start) {
+        XmlSchemaPathNode<U, V> prev = null;
+        XmlSchemaPathNode<U, V> curr = start;
         int position = 0;
 
         do {

Modified: webservices/xmlschema/trunk/xmlschema-walker/src/test/java/org/apache/ws/commons/schema/walker/TestSchemaWalker.java
URL: http://svn.apache.org/viewvc/webservices/xmlschema/trunk/xmlschema-walker/src/test/java/org/apache/ws/commons/schema/walker/TestSchemaWalker.java?rev=1626281&r1=1626280&r2=1626281&view=diff
==============================================================================
--- webservices/xmlschema/trunk/xmlschema-walker/src/test/java/org/apache/ws/commons/schema/walker/TestSchemaWalker.java (original)
+++ webservices/xmlschema/trunk/xmlschema-walker/src/test/java/org/apache/ws/commons/schema/walker/TestSchemaWalker.java Fri Sep 19 17:40:41 2014
@@ -34,7 +34,6 @@ import java.util.Set;
 import javax.xml.transform.stream.StreamSource;
 
 import org.junit.Assert;
-
 import org.apache.ws.commons.schema.XmlSchema;
 import org.apache.ws.commons.schema.XmlSchemaAll;
 import org.apache.ws.commons.schema.XmlSchemaAny;
@@ -497,6 +496,7 @@ public class TestSchemaWalker {
     /**
      * Test for src/main/resources/test_schema.xsd
      */
+    @SuppressWarnings("unchecked")
     @Test
     public void test() throws Exception {
         // Build the expectations.