Class CombinedNodeTest

java.lang.Object
net.sf.saxon.pattern.CombinedNodeTest
All Implemented Interfaces:
NodePredicate, NodeTest

public class CombinedNodeTest extends Object implements NodeTest
A CombinedNodeTest combines two node tests using one of the operators union (=or), intersect (=and), difference (= "and not"). This arises when optimizing a union (etc) of two path expressions using the same axis.
  • Constructor Details

    • CombinedNodeTest

      public CombinedNodeTest(NodeTest nt1, OperatorSymbol operator, NodeTest nt2)
      Create a NodeTest that combines two other node tests
      Parameters:
      nt1 - the first operand. Note that if the defaultPriority of the pattern is required, it will be taken from that of the first operand.
      operator - one of Token.UNION, Token.INTERSECT, Token.EXCEPT
      nt2 - the second operand
  • Method Details

    • getUType

      public UType getUType()
      Get the corresponding UType. A UType is a union of primitive item types.
      Specified by:
      getUType in interface NodeTest
      Returns:
      the smallest UType that subsumes this item type
    • asXNodeTest

      public NodeTest asXNodeTest(Configuration config)
      Description copied from interface: NodeTest
      Get an XNodeTest that will match any XNode that this NodeTest matches: that is, eliminate the possibility of matching a JNode.
      Specified by:
      asXNodeTest in interface NodeTest
    • test

      public boolean test(GNode node)
      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.
      Specified by:
      test in interface NodePredicate
      Specified by:
      test in interface NodeTest
      Parameters:
      node - the node to be matched
      Returns:
      true if the node test is satisfied by the supplied node, false otherwise
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • export

      public String export()
      Return a string representation of this ItemType suitable for use in stylesheet export files. This differs from the result of toString() in that it will not contain any references to anonymous types. Note that it may also use the Saxon extended syntax for union types and tuple types. The default implementation returns the result of calling toString().
      Specified by:
      export in interface NodeTest
      Returns:
      the string representation as an instance of the XPath SequenceType construct
    • addTypeDetails

      public void addTypeDetails(StringMapBuilder map)
      Add the "parameters" of the type to a dictionary containing the type information in structured form
    • getQNameTest

      public QNameTest getQNameTest()
      Extract a QNameTest (the strongest one possible) that must be satisfied by a node if it is to satisfy this NodeTest
      Specified by:
      getQNameTest in interface NodeTest
      Returns:
      the strongest possible QNameTest
    • getItemType

      public ItemType getItemType()
      Get an item type that all matching nodes must satisfy
      Specified by:
      getItemType in interface NodeTest
      Returns:
      an item type
    • toShortString

      public String toShortString()
      Get a concise string representation of this node test for use in diagnostics
      Specified by:
      toShortString in interface NodeTest
      Returns:
      a suitably abbreviated represention of the node test
    • isNillable

      public boolean isNillable()
      Determine whether the content type (if present) is nillable
      Specified by:
      isNillable in interface NodeTest
      Returns:
      true if the content test (when present) can match nodes that are nilled
    • hashCode

      public int hashCode()
      Returns a hash code value for the object.
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object other)
      Indicates whether some other object is "equal to" this one.
      Overrides:
      equals in class Object
    • getDefaultPriority

      public double getDefaultPriority()
      Get the default priority of this nodeTest when used as a pattern. In the case of a union, this will always be (arbitrarily) the default priority of the first operand. In other cases, again somewhat arbitrarily, it is 0.25, reflecting the common usage of an intersection to represent the pattern element(E, T).
      Specified by:
      getDefaultPriority in interface NodeTest
      Returns:
      the default priority for the pattern
    • getComponentNodeTests

      public NodeTest[] getComponentNodeTests()
      Get the two parts of the combined node test
      Returns:
      the two operands
    • getOperator

      public OperatorSymbol getOperator()
      Get the operator used to combine the two node tests: one of Token.VBAR, OperatorSymbol.INTERSECT, OperatorSymbol.EXCEPT,
      Returns:
      the operator
    • getOperand

      public NodeTest getOperand(int which)
    • explainMismatch

      public Optional<String> explainMismatch(Item item, TypeHierarchy th)
      Get extra diagnostic information about why a supplied item does not conform to this item type, if available. If extra information is returned, it should be in the form of a complete sentence, minus the closing full stop. No information should be returned for obvious cases.
      Specified by:
      explainMismatch in interface NodeTest
      Parameters:
      item - the item that doesn't match this type
      th - the type hierarchy cache
      Returns:
      optionally, a message explaining why the item does not match the type