Class SimplePositionalPattern

  • All Implemented Interfaces:
    ExportAgent, Locatable, IdentityComparable, Traceable

    public final class SimplePositionalPattern
    extends Pattern
    A SimplePositionalPattern is a pattern of the form A[N] where A is an axis expression using the child axis and P is a numeric literal.
    • Constructor Detail

      • SimplePositionalPattern

        public SimplePositionalPattern​(NodeTest nodeTest,
                                       int position)
        Create a SimplePositionalPattern
        nodeTest - the test that the node must satisfy
        position - the required position of the node
    • Method Detail

      • getPosition

        public int getPosition()
        Get the required position
        the integer appearing as the filter predicate
      • getNodeTest

        public NodeTest getNodeTest()
        Get the node test
        the node test used
      • matches

        public boolean matches​(Item item,
                               XPathContext context)
        Determine whether the pattern matches a given item.
        Specified by:
        matches in class Pattern
        item - the item to be tested
        context - The dynamic context.
        true if the pattern matches, else false
      • getUType

        public UType getUType()
        Get a UType indicating which kinds of items this Pattern can match.
        Specified by:
        getUType in class Pattern
        a UType indicating all the primitive types of item that the pattern can match.
      • getFingerprint

        public int getFingerprint()
        Determine the fingerprint of nodes to which this pattern applies. Used for optimisation.
        getFingerprint in class Pattern
        the fingerprint of nodes matched by this pattern.
      • getItemType

        public ItemType getItemType()
        Get an ItemType that all the nodes matching this pattern must satisfy
        Specified by:
        getItemType in class Pattern
        an ItemType, as specific as possible, which all the matching items satisfy
      • equals

        public boolean equals​(java.lang.Object other)
        Determine whether this pattern is the same as another pattern
        equals in class Expression
        other - the other object
        true if the other operand is an expression and if it can be determined that the two expressions are equivalent, in the sense that they will always return the same result.
      • computeHashCode

        protected int computeHashCode()
        hashcode supporting equals()
        computeHashCode in class Expression
        a computed hash code
      • isMotionless

        public boolean isMotionless()
        Test whether a pattern is motionless, that is, whether it can be evaluated against a node without repositioning the input stream. This is a necessary condition for patterns used as the match pattern of a streamed template rule.
        isMotionless in class Pattern
        true if the pattern is motionless, that is, if it can be evaluated against a streamed node without changing the position in the streamed input file
      • matchesBeneathAnchor

        public boolean matchesBeneathAnchor​(NodeInfo node,
                                            NodeInfo anchor,
                                            XPathContext context)
        Determine whether this pattern matches a given Node within the subtree rooted at a given anchor node. This method is used when the pattern is used for streaming.
        matchesBeneathAnchor in class Pattern
        node - The NodeInfo representing the Element or other node to be tested against the Pattern
        anchor - The anchor node, which must match any AnchorPattern subpattern
        context - The dynamic context. Only relevant if the pattern uses variables, or contains calls on functions such as document() or key().
        true if the node matches the Pattern, false otherwise
      • copy

        public Pattern copy​(RebindingMap rebindings)
        Copy a pattern. This makes a deep copy.
        Specified by:
        copy in class Pattern
        rebindings - variables that need to be re-bound
        the copy of the original pattern
      • reconstruct

        public java.lang.String reconstruct()
        Get the original pattern text
        reconstruct in class Pattern
      • export

        public void export​(ExpressionPresenter presenter)
        Description copied from class: Expression
        Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.
        Specified by:
        export in interface ExportAgent
        Specified by:
        export in class Pattern
        presenter - the expression presenter used to display the structure