/** * Signals to end of the element with the given name. * * @param name the NCName of the element. It is an error if the name is a QName (ie. contains a * prefix). * @param namespace the namespace of the element. **/ public void endElement(String name, String namespace) throws XMLException { AnyNode node = (AnyNode) _nodes.pop(); if (_nodes.isEmpty()) { // -- add to appInfo _documentation.add(node); } else { // -- add to parent AnyNode ((AnyNode) _nodes.peek()).addChild(node); } } // -- endElement
public void characters(char[] ch, int start, int length) throws XMLException { // -- Do delagation if necessary AnyNode text = new AnyNode(AnyNode.TEXT, null, // -- no local name for text nodes null, // -- no prefix null, // -- no namespace new String(ch, start, length)); if (!_nodes.isEmpty()) { AnyNode parent = (AnyNode) _nodes.peek(); parent.addChild(text); } else { _documentation.add(text); } } // -- characters
public void characters(char[] ch, int start, int length) throws XMLException { // -- Do delegation if necessary AnyNode text = new AnyNode(AnyNode.TEXT, null, // -- no local name for text nodes null, // -- no prefix null, // -- no namespace new String(ch, start, length)); if (!_nodes.isEmpty()) { AnyNode parent = _nodes.peek(); parent.addChild(text); } else { _appInfo.add(text); } }
/** * Signals to end of the element with the given name. * * @param name the NCName of the element. It is an error * if the name is a QName (ie. contains a prefix). * @param namespace the namespace of the element. **/ public void endElement(String name, String namespace) throws XMLException { AnyNode node = (AnyNode)_nodes.pop(); if (_nodes.isEmpty()) { //-- add to appInfo _appInfo.add(node); } else { //-- add to parent AnyNode ((AnyNode)_nodes.peek()).addChild(node); } } //-- endElement
/** * Signals to end of the element with the given name. * * @param name the NCName of the element. It is an error * if the name is a QName (ie. contains a prefix). * @param namespace the namespace of the element. **/ public void endElement(String name, String namespace) throws XMLException { AnyNode node = (AnyNode)_nodes.pop(); if (_nodes.isEmpty()) { //-- add to appInfo _documentation.add(node); } else { //-- add to parent AnyNode ((AnyNode)_nodes.peek()).addChild(node); } } //-- endElement
public void characters(char[] ch, int start, int length) throws XMLException { //-- Do delagation if necessary AnyNode text = new AnyNode(AnyNode.TEXT, null, //-- no local name for text nodes null, //-- no prefix null, //-- no namespace new String(ch, start, length)); if (!_nodes.isEmpty()) { AnyNode parent = (AnyNode)_nodes.peek(); parent.addChild(text); } else { _documentation.add(text); } } //-- characters
public void characters(char[] ch, int start, int length) throws SAXException { // create a Text Node String temp = new String(ch, start, length); // skip whitespaces if (isWhitespace(temp) && !_wsPreserve && !_character) return; AnyNode tempNode = new AnyNode(AnyNode.TEXT, null, null, null, temp); _node.addChild(tempNode); _character = true; }
public void characters(char[] ch, int start, int length) throws SAXException { //create a Text Node String temp = new String(ch, start, length); //skip whitespaces if (isWhitespace(temp) && !_wsPreserve && !_character) return; AnyNode tempNode = new AnyNode(AnyNode.TEXT, null, null, null, temp); _node.addChild(tempNode); _character = true; }
public void characters(char[] ch, int start, int length) throws XMLException { //-- Do delagation if necessary AnyNode text = new AnyNode(AnyNode.TEXT, null, //-- no local name for text nodes null, //-- no prefix null, //-- no namespace new String(ch, start, length)); if (!_nodes.isEmpty()) { AnyNode parent = (AnyNode)_nodes.peek(); parent.addChild(text); } else { _appInfo.add(text); } } //-- characters
public void endElement(String namespaceURI, String localName, String qName) throws SAXException { _character = false; String name = null; // -- if namespace processing is disabled then the localName might be null, in that case // -- we use the QName if (localName != null && localName.length() > 0) { name = localName; } else { name = getLocalPart(qName); } // --if it is the starting element just returns if (_startingNode.getLocalName().equals(name) && _nodeStack.empty()) return; // --else just add the node we have built to the previous node _node = (AnyNode) _nodeStack.pop(); // -- if the stack is empty, we have a new child for the root node // -- or a new sibling for the first child of the root node if (_nodeStack.empty()) { _startingNode.addChild(_node); _node = _startingNode; } else { AnyNode previousNode = (AnyNode) _nodeStack.peek(); previousNode.addChild(_node); // --the node processing is finished -> come back to the previous node _node = previousNode; } }
public void endElement(String namespaceURI, String localName, String qName) throws SAXException { _character = false; String name = null; //-- if namespace processing is disabled then the localName might be null, in that case //-- we use the QName if (localName != null && localName.length() > 0) { name = localName; } else { name = getLocalPart(qName); } //--if it is the starting element just returns if (_startingNode.getLocalName().equals(name) && _nodeStack.empty()) return; //--else just add the node we have built to the previous node _node = (AnyNode)_nodeStack.pop(); //-- if the stack is empty, we have a new child for the root node //-- or a new sibling for the first child of the root node if (_nodeStack.empty()) { _startingNode.addChild(_node); _node = _startingNode; } else { AnyNode previousNode = (AnyNode) _nodeStack.peek(); previousNode.addChild(_node); //--the node processing is finished -> come back to the previous node _node = previousNode; } }
/** * Adds an AnyNode to the current node * @param node the node to append */ public void addAnyNode(AnyNode node) { if (node == null) { throw new IllegalArgumentException("null argument in addAnyNode"); } switch(node.getNodeType()) { case ATTRIBUTE: addAttribute(node); break; case NAMESPACE: addNamespace(node); break; default: addChild(node); break; } }
/** * Adds an AnyNode to the current node * * @param node the node to append */ public void addAnyNode(AnyNode node) { if (node == null) { throw new IllegalArgumentException("null argument in addAnyNode"); } switch (node.getNodeType()) { case ATTRIBUTE: addAttribute(node); break; case NAMESPACE: addNamespace(node); break; default: addChild(node); break; } }
/** * <p> * Adds a child AnyNode to this node. A 'child' can be either an ELEMENT node, a COMMENT node, a * TEXT node or a PROCESSING INSTRUCTION. If the current node already has a child then the node to * add will be append as a sibling. * <p> * Note: you cannot add a child to a TEXT node. * * @param node the node to add. */ public void addChild(AnyNode node) { if (node == null) { throw new IllegalArgumentException("null argument in appendChild"); } if (node.getNodeType() == ATTRIBUTE || node.getNodeType() == NAMESPACE) { throw new IllegalArgumentException("An Attribute or an Namespace can't be added as a child"); } if (this.getNodeType() == TEXT) { throw new IllegalArgumentException("a TEXT node can't have children."); } if (_firstChildNode == null) { _firstChildNode = node; } else if (_firstChildNode.getNodeType() == ATTRIBUTE || _firstChildNode.getNodeType() == NAMESPACE) { _firstChildNode.addChild(node); } else { _firstChildNode.appendSibling(node); } }
/** * Adds an attribute to the current node. * @param node the attribute to add. */ public void addAttribute(AnyNode node) { if (node == null) { throw new IllegalArgumentException("null argument in addAttribute"); } if (node.getNodeType() != ATTRIBUTE) { throw new IllegalArgumentException("Only attribute can be added as an attribute"); } if (_firstChildNode == null) { _firstChildNode = node; } else { if (_firstChildNode.getNodeType() == ATTRIBUTE) { //if we reach an attribute then we add the node as its sibling _firstChildNode.appendSibling(node); } else if (_firstChildNode.getNodeType() == NAMESPACE) { //if we reach an namespace the attributre should be added to //the first child of the namespace _firstChildNode.addAttribute(node); } else { //unplug the current firstNode to add a new one node.addChild(_firstChildNode); _firstChildNode = node; } } } //addAttribute
/** * Appends an namespace to the current node. * @param node the attribute to add. */ public void addNamespace(AnyNode node){ if (node == null) { throw new IllegalArgumentException("null argument in addNamespace"); } if (node.getNodeType() != NAMESPACE) { throw new IllegalArgumentException("Only namespace can be added as an namespace"); } if (_firstChildNode == null) { _firstChildNode = node; } else { if (_firstChildNode.getNodeType() == NAMESPACE) { //if we reach an namepace then we add the node as its sibling _firstChildNode.appendSibling(node); } else if (_firstChildNode.getNodeType() == ATTRIBUTE) { //if we reach an attribute the attributre should be added to //the first child of the attribute _firstChildNode.addNamespace(node); } else { //unplug the current firstNode to add a new one node.addChild(_firstChildNode); _firstChildNode = node; } } } //addNamespace
/** * Adds an attribute to the current node. * * @param node the attribute to add. */ public void addAttribute(AnyNode node) { if (node == null) { throw new IllegalArgumentException("null argument in addAttribute"); } if (node.getNodeType() != ATTRIBUTE) { throw new IllegalArgumentException("Only attribute can be added as an attribute"); } if (_firstChildNode == null) { _firstChildNode = node; } else { if (_firstChildNode.getNodeType() == ATTRIBUTE) { // if we reach an attribute then we add the node as its sibling _firstChildNode.appendSibling(node); } else if (_firstChildNode.getNodeType() == NAMESPACE) { // if we reach an namespace the attributre should be added to // the first child of the namespace _firstChildNode.addAttribute(node); } else { // unplug the current firstNode to add a new one node.addChild(_firstChildNode); _firstChildNode = node; } } } // addAttribute
/** * Appends an namespace to the current node. * * @param node the attribute to add. */ public void addNamespace(AnyNode node) { if (node == null) { throw new IllegalArgumentException("null argument in addNamespace"); } if (node.getNodeType() != NAMESPACE) { throw new IllegalArgumentException("Only namespace can be added as an namespace"); } if (_firstChildNode == null) { _firstChildNode = node; } else { if (_firstChildNode.getNodeType() == NAMESPACE) { // if we reach an namepace then we add the node as its sibling _firstChildNode.appendSibling(node); } else if (_firstChildNode.getNodeType() == ATTRIBUTE) { // if we reach an attribute the attributre should be added to // the first child of the attribute _firstChildNode.addNamespace(node); } else { // unplug the current firstNode to add a new one node.addChild(_firstChildNode); _firstChildNode = node; } } } // addNamespace
/** * <p> * Adds a child AnyNode to this node. A 'child' can be either an ELEMENT * node, a COMMENT node, a TEXT node or a PROCESSING INSTRUCTION. If the * current node already has a child then the node to add will be append as a * sibling. * <p> * Note: you cannot add a child to a TEXT node. * * @param node * the node to add. */ public void addChild(AnyNode node) { if (node == null) { throw new IllegalArgumentException("null argument in appendChild"); } if (node.getNodeType() == ATTRIBUTE || node.getNodeType() == NAMESPACE) { throw new IllegalArgumentException("An Attribute or an Namespace can't be added as a child"); } if (this.getNodeType() == TEXT) { throw new IllegalArgumentException("a TEXT node can't have children."); } if (_firstChildNode == null) { _firstChildNode = node; } else if (_firstChildNode.getNodeType() == ATTRIBUTE || _firstChildNode.getNodeType() == NAMESPACE) { _firstChildNode.addChild(node); } else { _firstChildNode.appendSibling(node); } }
} else { _nodes.peek().addChild(node);