Author: veithen Date: Fri Mar 13 22:49:33 2009 New Revision: 753464 URL: http://svn.apache.org/viewvc?rev=753464&view=rev Log: Resurrected org.apache.axiom.om.impl.llom.OMNavigator and org.apache.axiom.om.impl.dom.DOMNavigator as subclasses of org.apache.axiom.om.impl.OMNavigator to avoid breaking existing code.
Added: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMNavigator.java - copied, changed from r751429, webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMNavigator.java webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNavigator.java - copied, changed from r751429, webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNavigator.java Copied: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMNavigator.java (from r751429, webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMNavigator.java) URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMNavigator.java?p2=webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMNavigator.java&p1=webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMNavigator.java&r1=751429&r2=753464&rev=753464&view=diff ============================================================================== --- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMNavigator.java (original) +++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMNavigator.java Fri Mar 13 22:49:33 2009 @@ -19,42 +19,13 @@ package org.apache.axiom.om.impl.dom; -import org.apache.axiom.om.OMContainer; -import org.apache.axiom.om.OMElement; import org.apache.axiom.om.OMNode; +import org.apache.axiom.om.impl.OMNavigator; /** - * This is exactly the same as org.apache.axiom.om.impl.om.OMNavigator, only the llom specifics are - * changed to dom. Refer to the testClass to find out how to use features like isNavigable, - * isComplete and step. + * Empty subclass of {...@link OMNavigator} to keep compatibility with existing code. */ -public class DOMNavigator { - /** Field node */ - protected OMNode node; - - /** Field visited */ - private boolean visited; - - /** Field next */ - private OMNode next; - - // root is the starting element. Once the navigator comes back to the - // root, the traversal is terminated - - /** Field root */ - private OMNode root; - - /** Field backtracked */ - private boolean backtracked; - - // flags that tell the status of the navigator - - /** Field end */ - private boolean end = false; - - /** Field start */ - private boolean start = true; - +public class DOMNavigator extends OMNavigator { /** Constructor OMNavigator. */ public DOMNavigator() { } @@ -65,113 +36,6 @@ * @param node */ public DOMNavigator(OMNode node) { - init(node); - } - - /** - * Method init. - * - * @param node - */ - public void init(OMNode node) { - next = node; - root = node; - backtracked = false; - } - - /** - * Gets the next node. - * - * @return Returns OMNode in the sequence of preorder traversal. Note however that an element - * node is treated slightly differently. Once the element is passed it returns the same - * element in the next encounter as well. - */ - public OMNode next() { - if (next == null) { - return null; - } - node = next; - visited = backtracked; - backtracked = false; - updateNextNode(); - - // set the starting and ending flags - if (root.equals(node)) { - if (!start) { - end = true; - } else { - start = false; - } - } - return node; - } - - /** Private method to encapsulate the searching logic */ - private void updateNextNode() { - if ((next instanceof OMElement) && !visited) { - ElementImpl e = (ElementImpl) next; - if (e.firstChild != null) { - next = e.firstChild; - } else if (e.isComplete()) { - backtracked = true; - } else { - next = null; - } - } else { - OMNode nextSibling = ((ChildNode) next).nextSibling; - OMContainer parent = next.getParent(); - if (nextSibling != null) { - next = nextSibling; - } else if ((parent != null) && parent.isComplete()) { - next = (NodeImpl) parent; - backtracked = true; - } else { - next = null; - } - } - } - - /** - * Method visited. - * - * @return Returns boolean. - */ - public boolean visited() { - return visited; - } - - /** - * This is a very special method. This allows the navigator to step once it has reached the - * existing OM. At this point the isNavigable method will return false but the isComplete method - * may return false which means that the navigating the given element is not complete but the - * navigator cannot proceed. - */ - public void step() { - if (!end) { - next = node; - updateNextNode(); - } - } - - /** - * Returns the navigable status. - * - * @return Returns boolean. - */ - public boolean isNavigable() { - if (end) { - return false; - } else { - return !(next == null); - } - } - - /** - * Returns the completed status. - * - * @return Returns boolean. - */ - public boolean isCompleted() { - return end; + super(node); } } Copied: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNavigator.java (from r751429, webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNavigator.java) URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNavigator.java?p2=webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNavigator.java&p1=webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNavigator.java&r1=751429&r2=753464&rev=753464&view=diff ============================================================================== --- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNavigator.java (original) +++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNavigator.java Fri Mar 13 22:49:33 2009 @@ -19,43 +19,13 @@ package org.apache.axiom.om.impl.llom; -import org.apache.axiom.om.OMContainer; -import org.apache.axiom.om.OMDocument; -import org.apache.axiom.om.OMElement; import org.apache.axiom.om.OMNode; -import org.apache.axiom.om.OMSourcedElement; /** - * Refer to the test, org.apache.axiom.om.OMNavigatorTest, to find out how to use features like - * isNavigable, isComplete and step. + * Empty subclass of {...@link org.apache.axiom.om.impl.OMNavigator} to keep compatibility + * with existing code. */ -public class OMNavigator { - /** Field node */ - protected OMNode node; - - /** Field visited */ - private boolean visited; - - /** Field next */ - private OMNode next; - - // root is the starting element. Once the navigator comes back to the - // root, the traversal is terminated - - /** Field root */ - private OMNode root; - - /** Field backtracked */ - private boolean backtracked; - - // flags that tell the status of the navigator - - /** Field end */ - private boolean end = false; - - /** Field start */ - private boolean start = true; - +public class OMNavigator extends org.apache.axiom.om.impl.OMNavigator { /** Constructor OMNavigator. */ public OMNavigator() { } @@ -66,149 +36,6 @@ * @param node */ public OMNavigator(OMNode node) { - init(node); - } - - /** - * Method init. - * - * @param node - */ - public void init(OMNode node) { - next = node; - root = node; - backtracked = false; - } - - /** - * Gets the next node. - * - * @return Returns OMnode in the sequence of preorder traversal. Note however that an element - * node is treated slightly differently. Once the element is passed it returns the same - * element in the next encounter as well. - */ - public OMNode next() { - if (next == null) { - return null; - } - node = next; - visited = backtracked; - backtracked = false; - updateNextNode(); - - // set the starting and ending flags - if (root.equals(node)) { - if (!start) { - end = true; - } else { - start = false; - } - } - return node; - } - - /** Private method to encapsulate the searching logic. */ - private void updateNextNode() { - - if ((next instanceof OMElement) && !visited) { - OMNode firstChild = _getFirstChild((OMElement) next); - if (firstChild != null) { - next = firstChild; - } else if (next.isComplete()) { - backtracked = true; - } else { - next = null; - } - } else { - OMContainer parent = next.getParent(); - OMNode nextSibling = getNextSibling(next); - if (nextSibling != null) { - next = nextSibling; - } else if ((parent != null) && parent.isComplete() && !(parent instanceof OMDocument)) { - next = (OMNodeImpl) parent; - backtracked = true; - } else { - next = null; - } - } - } - - /** - * @param node - * @return first child or null - */ - private OMNode _getFirstChild(OMElement node) { - if (node instanceof OMSourcedElement) { - OMNode first = node.getFirstOMChild(); - OMNode sibling = first; - while (sibling != null) { - sibling = sibling.getNextOMSibling(); - } - return first; - } else { - // Field access is used to prevent advancing the parser. - // Some tests fail if the following is used - // return node.getFirstOMChild() - return ((OMElementImpl) node).firstChild; - } - } - - /** - * @param node - * @return next sibling or null - */ - private OMNode getNextSibling(OMNode node) { - if (node instanceof OMSourcedElement) { - return node.getNextOMSibling(); - } else { - // Field access is used to prevent advancing the parser. - // Some tests fail if the following is used - // return node.getNextOMSibling() - return ((OMNodeImpl) node).nextSibling; - } - } - - /** - * Method visited. - * - * @return Returns boolean. - */ - public boolean visited() { - return visited; - } - - /** - * This is a very special method. This allows the navigator to step once it has reached the - * existing OM. At this point the isNavigable method will return false but the isComplete method - * may return false which means that the navigating the given element is not complete and the - * navigator cannot proceed. - */ - public void step() { - if (!end) { - next = node; - updateNextNode(); - } - } - - /** - * Returns the navigable status. - * - * @return Returns boolean. - */ - public boolean isNavigable() { - if (end) { - return false; - } else { - return !(next == null); - } - } - - /** - * Returns the completed status. - * - * @return Returns boolean. - */ - public boolean isCompleted() { - return end; + super(node); } }