/** Method updateNextNode. */ private void updateNextNode() { if (navigator.isNavigable()) { nextNode = navigator.next(); } else { if (!switchingAllowed) { if (navigator.isCompleted()) { nextNode = null; } else { builder.next(); navigator.step(); nextNode = navigator.next(); } } else { // reset caching (the default is ON so it was not needed in the // earlier case! builder.setCache(false); state = SWITCH_AT_NEXT; } } }
/** * Constructor OMStAXWrapper * * @param builder * @param startNode * @param cache */ public DOMStAXWrapper(OMXMLParserWrapper builder, OMElement startNode, boolean cache) { // create a navigator this.navigator = new DOMNavigator(startNode); this.builder = builder; this.rootNode = startNode; if (rootNode != null && rootNode.getParent() != null && rootNode.getParent() instanceof OMDocument) { needToThrowEndDocument = true; } // initaite 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(); updateNextNode(); switchingAllowed = !cache; }