public OMText createOMText(String contentID, OMContainer parent, OMXMLParserWrapper builder) { TextImpl text = new TextImpl(contentID, parent, builder, this); parent.addChild(text); return text; }
/** * Retrieves an <code>Iterator</code> matching the <code>child</code> XPath axis. * * @param contextNode the original context node * @return Returns an Iterator capable of traversing the axis, not null. * @throws UnsupportedAxisException if the semantics of the child axis are not supported by this * object model */ public Iterator getChildAxisIterator(Object contextNode) throws UnsupportedAxisException { if (contextNode instanceof OMContainer) { return ((OMContainer) contextNode).getChildren(); } return JaxenConstants.EMPTY_ITERATOR; }
public OMDescendantsIterator(OMContainer container, boolean includeSelf) { super(includeSelf ? (OMSerializable)container : (OMSerializable)container.getFirstOMChild()); level = includeSelf ? 0 : 1; }
public SAXResultContentHandler(OMContainer root) { super(true); this.root = root; factory = root.getOMFactory(); }
/** 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; } } }
SOAPEnvelope envelope = (stAXSOAPModelBuilder) .getSOAPEnvelope(); envelope.getParent().build();
public SAXResultContentHandler(OMContainer root) { super(true); this.root = root; factory = root.getOMFactory(); }
/** Private method to encapsulate the searching logic. */ private void updateNextNode() { if (!isLeaf(next) && !visited) { OMNode firstChild = _getFirstChild((OMContainer) next); if (firstChild != null) { next = firstChild; } else if (next.isComplete()) { backtracked = true; } else { next = null; } } else { if (next instanceof OMDocument) { next = null; } else { OMNode nextNode = (OMNode)next; OMContainer parent = nextNode.getParent(); OMNode nextSibling = getNextSibling(nextNode); if (nextSibling != null) { next = nextSibling; } else if ((parent != null) && parent.isComplete()) { next = parent; backtracked = true; } else { next = null; } } } }
public OMComment createOMComment(OMContainer parent, String content) { DocumentImpl doc; if (parent instanceof DocumentImpl) { doc = (DocumentImpl) parent; } else { doc = (DocumentImpl) ((ParentNode) parent).getOwnerDocument(); } CommentImpl comment = new CommentImpl(doc, content, this); parent.addChild(comment); return comment; }
/** Removes the contents (i.e. children) of the container. */ public static void removeContents(OMContainer container) { for (Iterator<?> iterator = container.getChildren(); iterator.hasNext();) { iterator.next(); iterator.remove(); } }
public final void hasNumberOfChildren(int expected) { OMNode child = getSubject().getFirstOMChild(); int actual = 0; while (child != null) { actual++; child = child.getNextOMSibling(); } if (actual != expected) { failWithRawMessage("number of children is %s instead of %s", actual, expected); } } }
omContextNode.getOMFactory().createOMNamespace( "http://www.w3.org/XML/1998/namespace", "xml"),
public final OMElement createOMElement(QName qname, OMContainer parent) { AxiomElement element = createNode(AxiomElement.class); if (parent != null) { parent.addChild(element); } element.internalSetLocalName(qname.getLocalPart()); String prefix = qname.getPrefix(); String namespaceURI = qname.getNamespaceURI(); if (namespaceURI.length() > 0) { // The goal here is twofold: // * check if the namespace needs to be declared; // * locate an existing OMNamespace object, so that we can avoid creating a new one. OMNamespace ns = element.findNamespace(namespaceURI, prefix.length() == 0 ? null : prefix); if (ns == null) { if ("".equals(prefix)) { prefix = generatePrefix(namespaceURI); } ns = element.declareNamespace(namespaceURI, prefix); } element.internalSetNamespace(ns); } else if (prefix.length() > 0) { throw new IllegalArgumentException("Cannot create a prefixed element with an empty namespace name"); } else { if (element.getDefaultNamespace() != null) { element.declareDefaultNamespace(""); } element.internalSetNamespace(null); } return element; }
/** Removes the contents (i.e. children) of the container. */ public static void removeContents(OMContainer container) { for (Iterator<?> iterator = container.getChildren(); iterator.hasNext();) { iterator.next(); iterator.remove(); } }
protected OMSerializable getNextNode(OMSerializable currentNode) { if (currentNode instanceof OMContainer) { OMNode firstChild = ((OMContainer)currentNode).getFirstOMChild(); if (firstChild != null) { level++; return firstChild; } } OMSerializable node = currentNode; while (true) { if (level == 0) { return null; } OMNode nextSibling = ((OMNode)node).getNextOMSibling(); if (nextSibling != null) { return nextSibling; } else { node = ((OMNode)node).getParent(); level--; } } } }
/** * Creates an OMDOM Text node, adds it to the give parent element and returns it. * * @see org.apache.axiom.om.OMFactory#createOMText(OMContainer, String, * String, boolean) */ public OMText createOMText(OMContainer parent, String s, String mimeType, boolean optimize) { TextImpl text = new TextImpl((DocumentImpl) ((ElementImpl) parent) .getOwnerDocument(), s, mimeType, optimize, this); parent.addChild(text); return text; }
/** Removes the contents (i.e. children) of the container. */ public static void removeContents(OMContainer container) { for (Iterator<?> iterator = container.getChildren(); iterator.hasNext();) { iterator.next(); iterator.remove(); } }
/** * @param node * @return first child or null */ private OMNode _getFirstChild(OMContainer node) { if (isOMSourcedElement(node)) { OMNode first = node.getFirstOMChild(); OMNode sibling = first; while (sibling != null) { sibling = sibling.getNextOMSibling(); } return first; } else { return ((IContainer)node).getFirstOMChildIfAvailable(); } }
public final OMElement createOMElement(QName qname, OMContainer parent) { AxiomElement element = createNode(AxiomElement.class); if (parent != null) { parent.addChild(element); } element.internalSetLocalName(qname.getLocalPart()); String prefix = qname.getPrefix(); String namespaceURI = qname.getNamespaceURI(); if (namespaceURI.length() > 0) { // The goal here is twofold: // * check if the namespace needs to be declared; // * locate an existing OMNamespace object, so that we can avoid creating a new one. OMNamespace ns = element.findNamespace(namespaceURI, prefix.length() == 0 ? null : prefix); if (ns == null) { if ("".equals(prefix)) { prefix = generatePrefix(namespaceURI); } ns = element.declareNamespace(namespaceURI, prefix); } element.internalSetNamespace(ns); } else if (prefix.length() > 0) { throw new IllegalArgumentException("Cannot create a prefixed element with an empty namespace name"); } else { if (element.getDefaultNamespace() != null) { element.declareDefaultNamespace(""); } element.internalSetNamespace(null); } return element; }
/** Removes the contents (i.e. children) of the container. */ public static void removeContents(OMContainer container) { for (Iterator<?> iterator = container.getChildren(); iterator.hasNext();) { OMNode child = (OMNode) iterator.next(); child.detach(); } }