Author: veithen Date: Sun Mar 8 14:52:02 2009 New Revision: 751435 URL: http://svn.apache.org/viewvc?rev=751435&view=rev Log: Some minor formatting and Javadoc changes to allow us to better compare OMStAXWrapper and DOMStAXWrapper.
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMStAXWrapper.java webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMStAXWrapper.java Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMStAXWrapper.java URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMStAXWrapper.java?rev=751435&r1=751434&r2=751435&view=diff ============================================================================== --- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMStAXWrapper.java (original) +++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMStAXWrapper.java Sun Mar 8 14:52:02 2009 @@ -70,20 +70,16 @@ /** Field isFirst */ private boolean isFirst = true; - // Navigable means the output should be taken from the navigator - // as soon as the navigator returns a null navigable will be reset + // Navigable means the output should be taken from the navigator. + // As soon as the navigator returns a null navigable will be reset // to false and the subsequent events will be taken from the builder // or the parser directly. /** Field NAVIGABLE */ private static final short NAVIGABLE = 0; - private static final short SWITCH_AT_NEXT = 1; - private static final short COMPLETED = 2; - private static final short SWITCHED = 3; - private static final short DOCUMENT_COMPLETE = 4; /** Field state */ @@ -92,10 +88,10 @@ /** Field currentEvent Default set to START_DOCUMENT */ private int currentEvent = START_DOCUMENT; - // SwitchingAllowed is set to false by default - // this means that unless the user explicitly states + // SwitchingAllowed is set to false by default. + // This means that unless the user explicitly states // that he wants things not to be cached, everything will - // be cached + // be cached. /** Field switchingAllowed */ boolean switchingAllowed = false; @@ -150,9 +146,9 @@ /** * When constructing the OMStaxWrapper, the creator must produce the builder (an instance of the - * OMXMLparserWrapper of the input) and the Element Node to start parsing. The wrapper - * parses(proceed) until the end of the given element. Hence care must be taken to pass the root - * element if the entire document is needed. + * OMXMLparserWrapper of the input) and the Element Node to start parsing. The wrapper will + * parse(proceed) until the end of the given element. Hence care should be taken to pass the + * root element if the entire document is needed. * * @param builder * @param startNode @@ -162,7 +158,7 @@ } /** - * Constructor OMStAXWrapper + * Constructor OMStAXWrapper. * * @param builder * @param startNode @@ -175,12 +171,12 @@ this.navigator = new OMNavigator(startNode); this.builder = builder; this.rootNode = startNode; - if (rootNode != null && rootNode.getParent() != null - && rootNode.getParent() instanceof OMDocument) { + if (rootNode != null && rootNode.getParent() != null && + rootNode.getParent() instanceof OMDocument) { needToThrowEndDocument = true; } - // initaite the next and current nodes + // initiate the next and current nodes // Note - navigator is written in such a way that it first // returns the starting node at the first call to it currentNode = navigator.next(); @@ -226,15 +222,15 @@ } /** - * @return Returns String. + * @return Returns boolean. * @see javax.xml.stream.XMLStreamReader#hasName() */ public boolean hasName() { if (parser != null) { return parser.hasName(); } else { - return ((currentEvent == START_ELEMENT) || - (currentEvent == END_ELEMENT)); + return ((currentEvent == START_ELEMENT) + || (currentEvent == END_ELEMENT)); } } @@ -278,7 +274,7 @@ * @see javax.xml.stream.XMLStreamReader#hasText() */ public boolean hasText() { - return ((currentEvent == CHARACTERS) || (currentEvent == DTD) + return ((currentEvent == CHARACTERS) || (currentEvent == DTD) || (currentEvent == CDATA) || (currentEvent == ENTITY_REFERENCE) || (currentEvent == COMMENT) || (currentEvent == SPACE)); @@ -626,8 +622,8 @@ returnCount = getCount(elt.getAllAttributes()); } else { throw new IllegalStateException( - "attribute count accessed in illegal event (" - + currentEvent + ")!"); + "attribute count accessed in illegal event (" + + currentEvent + ")!"); } } return returnCount; @@ -890,7 +886,7 @@ throw new IllegalArgumentException(); } if (parser != null) { - return parser.getProperty(s); + return parser.getProperty(s); } // Delegate to the builder's parser. if (builder != null && builder instanceof StAXBuilder) { @@ -911,9 +907,9 @@ } /** - * This is a very important method. This keeps the navigator one step ahead and pushes the - * navigator one event ahead. If the nextNode is null then navigable is set to false; At the - * same time the parser and builder are set up for the upcoming event generation + * This is a very important method. It keeps the navigator one step ahead and pushes it one + * event ahead. If the nextNode is null then navigable is set to false. At the same time the + * parser and builder are set up for the upcoming event generation. * * @throws XMLStreamException */ @@ -1048,15 +1044,15 @@ } /* - * + * * ################################################################ * Generator methods for the OMNodes returned by the navigator * ################################################################ - * + * */ /** - * Method generateEvents + * Method generateEvents. * * @param node * @return Returns int. @@ -1137,7 +1133,7 @@ */ /** - * helper method. + * helper method getCount. * * @param it * @return Returns int. @@ -1154,7 +1150,7 @@ } /** - * Helper method. + * Helper method getItemFromIterator. * * @param it * @param index @@ -1181,7 +1177,7 @@ } /** - * Helper method. + * Helper method getQName. * * @param element * @return Returns QName. Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMStAXWrapper.java URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMStAXWrapper.java?rev=751435&r1=751434&r2=751435&view=diff ============================================================================== --- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMStAXWrapper.java (original) +++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMStAXWrapper.java Sun Mar 8 14:52:02 2009 @@ -55,8 +55,8 @@ import org.apache.commons.logging.LogFactory; /** - * Note - This class also implements the streaming constants interface to get access to the StAX - * constants + * Note - This class also implements the streaming constants interface to get access to the StAX + * constants. */ public class OMStAXWrapper implements OMXMLStreamReader, XMLStreamConstants { @@ -75,7 +75,6 @@ private boolean _isClosed = false; // Indicate if parser is closed private boolean _releaseParserOnClose = false; // Defaults to legacy behavior, which is keep the reference - /** Field rootNode */ private OMNode rootNode; @@ -93,8 +92,7 @@ private static final short COMPLETED = 2; private static final short SWITCHED = 3; private static final short DOCUMENT_COMPLETE = 4; - - + // Variables used to build an xop:include representation private final static QName XOP_INCLUDE = new QName("http://www.w3.org/2004/08/xop/include", "Include", "xop"); @@ -102,7 +100,6 @@ private OMText xopIncludeText = null; private boolean xopIncludeStart = false; - /** Field state */ private short state; @@ -132,7 +129,8 @@ /** Field nextNode */ private OMNode nextNode = null; - // holder for the current node. Needs this to generate events from the current node + // holder for the current node. Needs this to generate events from the + // current node /** Field currentNode */ private OMNode currentNode = null; @@ -153,7 +151,7 @@ * the consumer must call getDataHandler(cid) to access the datahandler. */ private boolean inlineMTOM = true; - + /** * Method setAllowSwitching. * @@ -221,7 +219,7 @@ } // initiate the next and current nodes - // Note - navigator is written in such a way that it first + // Note - navigator is written in such a way that it first // returns the starting node at the first call to it // Note - for OMSourcedElements, temporarily set caching // to get the initial navigator nodes @@ -257,9 +255,7 @@ if ((currentEvent == START_ELEMENT) || (currentEvent == END_ELEMENT)) { OMNamespace ns = ((OMElement) getNode()).getNamespace(); - returnStr = (ns == null) - ? null - : ns.getPrefix(); + returnStr = (ns == null) ? null : ns.getPrefix(); } } return returnStr; @@ -278,9 +274,7 @@ || (currentEvent == END_ELEMENT) || (currentEvent == NAMESPACE)) { OMNamespace ns = ((OMElement) getNode()).getNamespace(); - returnStr = (ns == null) - ? null - : ns.getNamespaceURI(); + returnStr = (ns == null) ? null : ns.getNamespaceURI(); } } @@ -466,7 +460,6 @@ String returnString = null; if (parser != null) { returnString = parser.getNamespaceURI(i); - } else { if (isStartElement() || isEndElement() || (currentEvent == NAMESPACE)) { @@ -506,9 +499,7 @@ || (currentEvent == NAMESPACE)) { OMNamespace ns = (OMNamespace) getItemFromIterator( ((OMElement) getNode()).getAllDeclaredNamespaces(), i); - returnString = (ns == null) - ? null - : ns.getPrefix(); + returnString = (ns == null) ? null : ns.getPrefix(); } } return returnString; @@ -525,9 +516,8 @@ } else { if (isStartElement() || isEndElement() || (currentEvent == NAMESPACE)) { - returnCount = - getCount( - ((OMElement) getNode()).getAllDeclaredNamespaces()); + returnCount = getCount(((OMElement) getNode()) + .getAllDeclaredNamespaces()); } } return returnCount; @@ -588,8 +578,7 @@ returnString = parser.getAttributeType(i); } else { if (isStartElement() || (currentEvent == ATTRIBUTE)) { - - OMAttribute attrib = getAttribute((OMElement) getNode(), i); + OMAttribute attrib = getAttribute((OMElement) getNode(), i); if (attrib != null) { returnString = attrib.getAttributeType(); } @@ -599,7 +588,6 @@ "attribute type accessed in illegal event!"); } } - return returnString; } @@ -840,8 +828,6 @@ } } } - - return returnString; } @@ -986,17 +972,15 @@ } // We should throw an END_DOCUMENT - if ((currentEvent == START_DOCUMENT) && - (currentEvent == parser.getEventType())) { + if ((currentEvent == START_DOCUMENT) + && (currentEvent == parser.getEventType())) { currentEvent = parser.next(); } else { currentEvent = parser.getEventType(); } - updateCompleteStatus(); break; case NAVIGABLE: - currentEvent = generateEvents(currentNode); updateCompleteStatus(); updateLastNode(); @@ -1007,7 +991,7 @@ } updateCompleteStatus(); break; - default : + default: throw new OMStreamingException("unsuppported state!"); } return currentEvent; @@ -1042,7 +1026,7 @@ throw new IllegalArgumentException(); } if (parser != null) { - return parser.getProperty(s); + return parser.getProperty(s); } // Delegate to the builder's parser. if (builder != null && builder instanceof StAXBuilder) { @@ -1061,13 +1045,12 @@ } return null; } - /** * This is a very important method. It keeps the navigator one step ahead and pushes it one * event ahead. If the nextNode is null then navigable is set to false. At the same time the * parser and builder are set up for the upcoming event generation. - * + * * @throws XMLStreamException */ private void updateLastNode() throws XMLStreamException { @@ -1201,7 +1184,6 @@ return "1.0"; //todo put the constant } - /** * Method isStandalone. * @@ -1369,16 +1351,17 @@ } /** - * Method generateCommentEvents + * Method generateCommentEvents. * * @return Returns int. + * @noinspection SameReturnValue */ private int generateCommentEvents() { return COMMENT; } /** - * Method generateCdataEvents + * Method generateCdataEvents. * * @return Returns int. */