/** * Create a new <code>desscendant-or-self</code> axis iterator. * * @param contextNode the node to start from * @param navigator the object model specific navigator */ public DescendantOrSelfAxisIterator(Object contextNode, Navigator navigator) { super(navigator, new SingleObjectIterator(contextNode)); }
static public Iterator convertToIterator(Object obj) { if ( obj instanceof Iterator ) { return (Iterator) obj; } if ( obj instanceof List ) { return ((List)obj).iterator(); } return new SingleObjectIterator( obj ); }
public Iterator getParentAxisIterator(Object contextNode) { if ( contextNode instanceof Element ) { return new SingleObjectIterator( ((Element)contextNode).getParent() ); } return JaxenConstants.EMPTY_ITERATOR; }
/** * Get a (single-member) iterator over this node's parent. * * @param contextNode * the context node for the parent axis. * @return A possibly-empty iterator (not null). */ @Override public Iterator<Node> getParentAxisIterator(Object contextNode) { if (isAttribute(contextNode)) { return new SingleObjectIterator(((Attribute) contextNode).getParent()); } Node parent = ((Node) contextNode).jjtGetParent(); if (parent != null) { return new SingleObjectIterator(parent); } else { return EMPTY_ITERATOR; } }
public Iterator getParentAxisIterator(Object contextNode) { if ( contextNode instanceof Document ) { return JaxenConstants.EMPTY_ITERATOR; } Node node = (Node) contextNode; Object parent = node.getParent(); if ( parent == null ) { parent = node.getDocument(); } return new SingleObjectIterator( parent ); }
/** * Retrieves an <code>Iterator</code> over the attribute elements that * match the supplied name. * * @param contextNode the origin context node * @param localName the local name of the attributes to return, always present * @param namespacePrefix the prefix of the namespace of the attributes to return * @param namespaceURI the URI of the namespace of the attributes to return * @return an Iterator that traverses the named attributes, not null */ public Iterator getAttributeAxisIterator( Object contextNode, String localName, String namespacePrefix, String namespaceURI) { if ( contextNode instanceof Element ) { Element node = (Element) contextNode; Namespace namespace = (namespaceURI == null ? Namespace.NO_NAMESPACE : Namespace.getNamespace(namespacePrefix, namespaceURI)); Attribute attr = node.getAttribute(localName, namespace); if (attr != null) { return new SingleObjectIterator(attr); } } return JaxenConstants.EMPTY_ITERATOR; }
return new SingleObjectIterator(el);
/** * Retrieves an <code>Iterator</code> over the attribute elements that * match the supplied name. * * @param contextNode the origin context node * @param localName the local name of the attributes to return, always present * @param namespacePrefix the prefix of the namespace of the attributes to return * @param namespaceURI the URI of the namespace of the attributes to return * @return an Iterator that traverses the named attributes, not null */ public Iterator getAttributeAxisIterator( Object contextNode, String localName, String namespacePrefix, String namespaceURI) { if ( contextNode instanceof Element ) { Element node = (Element) contextNode; Attribute attr = node.attribute(QName.get(localName, namespacePrefix, namespaceURI)); if (attr == null) { return JaxenConstants.EMPTY_ITERATOR; } return new SingleObjectIterator(attr); } return JaxenConstants.EMPTY_ITERATOR; }
public Iterator getParentAxisIterator(Object o) { Object parent = null; if (o instanceof Node) { parent = ((Node)o).getParent(); } else if (isNamespace(o)) { parent = ((XPathNamespace)o).getElement(); } return (parent != null ? new SingleObjectIterator(parent) : null); }
return new SingleObjectIterator(el);
return new SingleObjectIterator( new Element( (Element) contextNode, localName, result ) );
return new SingleObjectIterator( parent );
@Override public final Iterator<?> getParentAxisIterator(Object contextNode) throws UnsupportedAxisException { Parent p = null; if (contextNode instanceof Content) { p = ((Content)contextNode).getParent(); } else if (contextNode instanceof NamespaceContainer) { p = ((NamespaceContainer)contextNode).getParentElement(); } else if (contextNode instanceof Attribute) { p = ((Attribute)contextNode).getParent(); } if (p != null) { return new SingleObjectIterator(p); } return JaxenConstants.EMPTY_ITERATOR; }
public Iterator getParentAxisIterator(Object contextNode) { if (contextNode instanceof LogicalComponent) { return new SingleObjectIterator(((LogicalComponent) contextNode).getParent()); } return JaxenConstants.EMPTY_ITERATOR; }
/** * Returns a (single-member) iterator over this node's parent. * * @param contextNode * the context node for the parent axis * @return a possibly-empty iterator (not null) */ @SuppressWarnings("unchecked") @Override public Iterator<XPathNode<?>> getParentAxisIterator( Object contextNode ) { return new SingleObjectIterator( ( (XPathNode<?>) contextNode ).getParent() ); }
/** * Retrieves an <code>Iterator</code> matching the <code>parent</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 parent axis are not supported by * this object model */ public Iterator getParentAxisIterator(Object contextNode) throws UnsupportedAxisException { if (contextNode instanceof OMNode) { return new SingleObjectIterator(((OMNode) contextNode).getParent()); } else if (contextNode instanceof OMNamespaceEx) { return new SingleObjectIterator( ((OMNamespaceEx) contextNode).getParent()); } else if (contextNode instanceof OMAttribute) { return new SingleObjectIterator( ((OMAttribute) contextNode).getOwner()); } return JaxenConstants.EMPTY_ITERATOR; }
@SuppressWarnings("unchecked") @Override public Iterator getParentAxisIterator(Object contextNode) { if (isElement(contextNode)) { AstNode astNode = (AstNode) contextNode; AstNode parent = astNode.getParent(); return parent == null ? EMPTY_ITERATOR : new SingleObjectIterator(parent); } else if (isAttribute(contextNode)) { Attribute attribute = (Attribute) contextNode; return new SingleObjectIterator(attribute.getAstNode()); } else { throw new UnsupportedOperationException("Unsupported context object type for parent axis \"" + contextNode.getClass().getSimpleName() + "\": " + contextNode); } }
@SuppressWarnings("unchecked") @Override public Iterator getParentAxisIterator(Object contextNode) { if (isElement(contextNode)) { AstNode astNode = (AstNode) contextNode; AstNode parent = astNode.getParent(); return parent == null ? Collections.emptyIterator() : new SingleObjectIterator(parent); } else if (isAttribute(contextNode)) { Attribute attribute = (Attribute) contextNode; return new SingleObjectIterator(attribute.getAstNode()); } else { throw new UnsupportedOperationException("Unsupported context object type for parent axis \"" + contextNode.getClass().getSimpleName() + "\": " + contextNode); } }
/** * Get a (single-member) iterator over this node's parent. * * @param contextNode * the context node for the parent axis. * @return A possibly-empty iterator (not null). */ @Override public Iterator<Node> getParentAxisIterator(Object contextNode) { if (isAttribute(contextNode)) { return new SingleObjectIterator(((Attribute) contextNode).getParent()); } Node parent = ((Node) contextNode).jjtGetParent(); if (parent != null) { return new SingleObjectIterator(parent); } else { return EMPTY_ITERATOR; } }
public Iterator getParentAxisIterator(Object obj) { Object parent = null; if (obj instanceof NodeAttribute) { parent = ((NodeAttribute) obj).getNode(); } else if (obj instanceof NodeTreeWalker) { parent = ((NodeTreeWalker) obj).getParentNode(); } if (parent != null) { return new SingleObjectIterator(parent); } return NullIterator.getInstance(); }