/** * Ask whether the pattern is anchored on a call on current-group() * * @return true if calls on matchesBeneathAnchor should test with all nodes in the * current group as anchor nodes. If false, only the first node in a group is * treated as the anchor node */ public boolean matchesCurrentGroup() { return getBasePattern().matchesCurrentGroup(); }
/** * Get a UType indicating which kinds of items this Pattern can match. * * @return a UType indicating all the primitive types of item that the pattern can match. */ @Override public UType getUType() { return getBasePattern().getUType(); }
/** * Get an ItemType that all the items matching this pattern must satisfy * * @return an ItemType, as specific as possible, which all the matching items satisfy */ /*@Nullable*/ @Override public ItemType getItemType() { return getBasePattern().getItemType(); }
/** * Get a NodeTest that all the nodes matching this pattern must satisfy */ public NodeTest getNodeTest() { if (nodeType==Type.NODE) { return AnyNodeTest.getInstance(); } else { return NodeKindTest.makeNodeKindTest(nodeType); } }
/** * Determine the name fingerprint of nodes to which this pattern applies. Used for * optimisation. * * @return A fingerprint that the nodes must match, or -1 if it can match multiple fingerprints, * or it if matches atomic values */ @Override public int getFingerprint() { return getBasePattern().getFingerprint(); }
/** * Create an NodeTestPattern that matches all items of a given type * * @param test the type that the items must satisfy for the pattern to match */ public NodeTestPattern(NodeTest test) { nodeTest = test; setPriority(test.getDefaultPriority()); }
@Override public boolean matchesBeneathAnchor(NodeInfo node, NodeInfo anchor, XPathContext context) throws XPathException { return getBasePattern().matchesBeneathAnchor(node, anchor, context) && matchesPredicate(node, context); }
/** * Type-check the pattern. * This is only needed for patterns that contain variable references or function calls. * * @return the optimised Pattern */ public Pattern typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException { mustBeNodePattern(p1); p1 = p1.typeCheck(visitor, contextItemType); mustBeNodePattern(p2); p2 = p2.typeCheck(visitor, contextItemType); return this; }
/** * Display the pattern for diagnostics */ public String toString() { return ".[" + getPredicate() + "]"; }
/** * Determine whether the pattern matches a given item. * * @param item the item to be tested * @return true if the pattern matches, else false */ public boolean matches(Item<?> item, XPathContext context) throws XPathException { return item instanceof NodeInfo && matchesBeneathAnchor((NodeInfo) item, null, context); }
/** * Get a NodeTest that all the nodes matching this pattern must satisfy */ public ItemType getItemType() { if (refinedItemType != null) { return refinedItemType; } return basePattern.getItemType(); }
/** * Get a NodeTest that all the nodes matching this pattern must satisfy */ public NodeTest getNodeTest() { if (nodeType == Type.NODE) { return AnyNodeTest.getInstance(); } else { return NodeKindTest.makeNodeKindTest(nodeType); } }
/** * Determine the name fingerprint of nodes to which this pattern applies. Used for * optimisation. * * @return A fingerprint that the nodes must match, or -1 if it can match multiple fingerprints, * or it if matches atomic values */ @Override public int getFingerprint() { return getBasePattern().getFingerprint(); }
/** * Create an NodeTestPattern that matches all items of a given type * * @param test the type that the items must satisfy for the pattern to match */ public NodeTestPattern(NodeTest test) { nodeTest = test; setPriority(test.getDefaultPriority()); }
@Override public boolean matchesBeneathAnchor(NodeInfo node, NodeInfo anchor, XPathContext context) throws XPathException { return getBasePattern().matchesBeneathAnchor(node, anchor, context) && matchesPredicate(node, context); }
/** * Ask whether the pattern is anchored on a call on current-group() * * @return true if calls on matchesBeneathAnchor should test with all nodes in the * current group as anchor nodes. If false, only the first node in a group is * treated as the anchor node */ public boolean matchesCurrentGroup() { return getBasePattern().matchesCurrentGroup(); }
/** * Get a UType indicating which kinds of items this Pattern can match. * * @return a UType indicating all the primitive types of item that the pattern can match. */ @Override public UType getUType() { return getBasePattern().getUType(); }
/** * Get an ItemType that all the items matching this pattern must satisfy * * @return an ItemType, as specific as possible, which all the matching items satisfy */ /*@Nullable*/ @Override public ItemType getItemType() { return getBasePattern().getItemType(); }
/** * Type-check the pattern. * This is only needed for patterns that contain variable references or function calls. * * @return the optimised Pattern */ public Pattern typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException { mustBeNodePattern(p1); p1 = p1.typeCheck(visitor, contextItemType); mustBeNodePattern(p2); p2 = p2.typeCheck(visitor, contextItemType); return this; }