/** * Determine whether this Pattern matches the given Node. This is the main external interface * for matching patterns: it sets current() to the node being tested * @param node The NodeInfo representing the Element or other node to be tested against the Pattern * @param context The context in which the match is to take place. Only relevant if the pattern * uses variables, or contains calls on functions such as document() or key(). Not used (and can be * set to null) in the case of patterns that are NodeTests * @return true if the node matches the Pattern, false otherwise */ public boolean matches(NodeInfo node, XPathContext context) { return nodeTest.matches(node); }
/** * Test whether a node conforms to the node type and name constraints. * Note that this returns true if the supplied node is null, this is a way of * terminating a loop. */ protected boolean conforms(NodeImpl node) { if (node==null || nodeTest==null) { return true; } return nodeTest.matches(node); }
/** * Determine whether this Pattern matches the given Node. This is the main external interface * for matching patterns: it sets current() to the node being tested * @param node The NodeInfo representing the Element or other node to be tested against the Pattern * @param context The context in which the match is to take place. Only relevant if the pattern * uses variables, or contains calls on functions such as document() or key(). Not used (and can be * set to null) in the case of patterns that are NodeTests * @return true if the node matches the Pattern, false otherwise */ public boolean matches(NodeInfo node, XPathContext context) { return nodeTest.matches(node); }
/** * Test whether a node conforms to the node type and name constraints. * Note that this returns true if the supplied node is null, this is a way of * terminating a loop. */ protected boolean conforms(NodeImpl node) { if (node==null || nodeTest==null) { return true; } return nodeTest.matches(node); }
/** * Test whether a given item conforms to this type. This implements a method of the ItemType interface. * @param item The item to be tested * @param allowURIPromotion * @param config * @return true if the item is an instance of this type; false otherwise */ public boolean matchesItem(Item item, boolean allowURIPromotion, Configuration config) { if (item instanceof NodeInfo) { return matches((NodeInfo)item); } else { return false; } }
public NodeInfo next() { NodeInfo curr; do { // until we find a match curr = advance(); } while (curr != null && nodeTest != null && (!nodeTest.matches(curr))); if (curr != null) position++; current = curr; return curr; }
public NodeInfo next() { NodeInfo curr; do { // until we find a match curr = advance(); } while (curr != null && nodeTest != null && (!nodeTest.matches(curr))); if (curr != null) position++; current = curr; return curr; }
public NodeInfo next() { NodeInfo curr; do { // until we find a match curr = advance(); } while (curr != null && nodeTest != null && (!nodeTest.matches(curr))); if (curr != null) position++; current = curr; return curr; }
public NodeInfo next() { NodeInfo curr; do { // until we find a match curr = advance(); } while (curr != null && nodeTest != null && (!nodeTest.matches(curr))); if (curr != null) position++; current = curr; return curr; }
public Item next() { while (true) { current = (NodeInfo)base.next(); if (current == null) { position = -1; return null; } if (nodeTest.matches(current)) { position++; return current; } } }
public Item next() { while (true) { current = (NodeInfo)base.next(); if (current == null) { position = -1; return null; } if (nodeTest.matches(current)) { position++; return current; } } }
static Deque<NodeInfo> wrapXmlObjectAttributesAsNodeInfos( XmlObject xmlObject, Map<QName, Object> xmlObjectAttributes, Configuration configuration, NodeTest nodeTest) { Deque<NodeInfo> nodeInfos = new LinkedList<NodeInfo>(); for (Map.Entry<QName, Object> entry : xmlObjectAttributes.entrySet()) { NodeInfo xoani = wrapXmlObjectAttributeAsNodeInfo(xmlObject, entry .getKey(), entry.getValue(), configuration); if (nodeTest.matches(xoani)) { nodeInfos.add(xoani); } } return nodeInfos; }
/** * Create an iterator over a singleton node, if it exists and matches a nodetest; * otherwise return an empty iterator * @param node the singleton node, or null if the node does not exist * @param nodeTest the test to be applied * @return an iterator over the node if it exists and matches the test. */ public static AxisIterator filteredSingleton(NodeInfo node, NodeTest nodeTest) { if (node != null && nodeTest.matches(node)) { return SingleNodeIterator.makeIterator(node); } else { return EmptyIterator.getInstance(); } }
/** * Test whether this node test is satisfied by a given node. This alternative * method is used in the case of nodes where calculating the fingerprint is expensive, * for example DOM or JDOM nodes. The default implementation calls the method * {@link #matches(int, NodeName, SchemaType)} * * @param node the node to be matched * @return true if the node test is satisfied by the supplied node, false otherwise */ public boolean matchesNode(/*@NotNull*/ NodeInfo node) { return matches(node.getNodeKind(), NameOfNode.makeName(node), node.getSchemaType()); }
/** * Test whether this node test is satisfied by a given node. This alternative * method is used in the case of nodes where calculating the fingerprint is expensive, * for example DOM or JDOM nodes. The default implementation calls the method * {@link #matches(int, int, int)} * @param node the node to be matched */ public boolean matches(NodeInfo node) { return matches(node.getNodeKind(), node.getFingerprint(), node.getTypeAnnotation()); }
/** * Test whether this node test is satisfied by a given node. This alternative * method is used in the case of nodes where calculating the fingerprint is expensive, * for example DOM or JDOM nodes. The default implementation calls the method * {@link #matches(int, int, int)} * @param node the node to be matched */ public boolean matches(NodeInfo node) { return matches(node.getNodeKind(), node.getFingerprint(), node.getTypeAnnotation()); }
/** * Test whether this node test is satisfied by a given node. This alternative * method is used in the case of nodes where calculating the fingerprint is expensive, * for example DOM or JDOM nodes. The default implementation calls the method * {@link #matches(int, NodeName, SchemaType)} * * @param node the node to be matched * @return true if the node test is satisfied by the supplied node, false otherwise */ public boolean matchesNode(/*@NotNull*/ NodeInfo node) { return matches(node.getNodeKind(), NameOfNode.makeName(node), node.getSchemaType()); }
/** * Get the next item in the sequence. */ public void advance() { while (nsIterator.hasNext()) { int nscode = nsIterator.next(); next = new NamespaceNodeImpl(element, nscode, ++index); if (test == null || test.matches(next)) { return; } } next = null; }
/** * Get the next item in the sequence. */ public void advance() { while (nsIterator.hasNext()) { int nscode = nsIterator.next(); next = new NamespaceNodeImpl(element, nscode, ++index); if (test == null || test.matches(next)) { return; } } next = null; }
static AxisIterator createParentAxisIterator(XmlObjectNode xmlObjectNode, NodeTest nodeTest, Configuration configuration) { XmlObject parent = xmlObjectNode.getXmlObjectParent(); if (parent == null) return createEmptyAxisIterator(); XmlObjectNodeNodeInfo parentNodeInfo = wrapXmlObjectAsNodeInfo(parent, configuration); if (!nodeTest.matches(parentNodeInfo)) return createEmptyAxisIterator(); return SingleNodeIterator.makeIterator(parentNodeInfo); }