Class ItemTypePattern

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

    public class ItemTypePattern
    extends Pattern
    An ItemTypePattern is a pattern that consists simply of an ItemType; although a node test is an item type, this class is used only for non-node item types, such as atomic types, map types, array types etc.
    • Constructor Detail

      • ItemTypePattern

        public ItemTypePattern​(ItemType test)
        Create an ItemTypePattern that matches all items of a given type
        Parameters:
        test - the type that the items must satisfy for the pattern to match
    • Method Detail

      • matches

        public boolean matches​(Item item,
                               XPathContext context)
                        throws XPathException
        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
        Specified by:
        matches in class Pattern
        Parameters:
        item - The item to be tested against the Pattern
        context - The context in which the match is to take place.
        Returns:
        true if the item matches the Pattern, false otherwise
        Throws:
        XPathException - if an error occurs while matching the pattern (the caller will usually treat this the same as a false result)
      • getItemType

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

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

        public java.lang.String reconstruct()
        Display the pattern for diagnostics
        Overrides:
        reconstruct in class Pattern
      • equals

        public boolean equals​(java.lang.Object other)
        Determine whether this pattern is the same as another pattern
        Overrides:
        equals in class Expression
        Parameters:
        other - the other object
        Returns:
        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()
        Overrides:
        computeHashCode in class Expression
        Returns:
        a computed hash code
      • export

        public void export​(ExpressionPresenter presenter)
                    throws XPathException
        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
        Parameters:
        presenter - the expression presenter used to display the structure
        Throws:
        XPathException - if the export fails, for example if an expression is found that won't work in the target environment.
      • copy

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