Class PortableNamedXNodeType

All Implemented Interfaces:
NodePredicate, NodeTest, ItemType, ItemTypeWithSequenceTypeCache

public class PortableNamedXNodeType extends XNodeType
PortableNamedXNodeType is variant of the NamedXNodeType class that works across Configurations. It is used in the function signatures of functions like fn:analyze-string; these signatures appear in Java static data, so they cannot be tied to a particular configuration.
  • Constructor Details

    • PortableNamedXNodeType

      public PortableNamedXNodeType(int nodeKind, QNameTest qNameTest)
      Create a NameTest to match nodes by name
      Parameters:
      nodeKind - the kind of node, for example Type.ELEMENT
      qNameTest - a test that the name of the node must satisfy
      Since:
      13.0
    • PortableNamedXNodeType

      public PortableNamedXNodeType(int nodeKind, StructuredQName requiredName)
      Create a NameTest to match nodes by name
      Parameters:
      nodeKind - the kind of node, for example Type.ELEMENT
      requiredName - the required name of the nodes
      Since:
      13.0
  • Method Details

    • matches

      public boolean matches(Item item)
      Test whether a given item conforms to this type
      Specified by:
      matches in interface ItemType
      Specified by:
      matches in class GNodeType
      Parameters:
      item - The item to be tested
      Returns:
      true if the item is an instance of this type; false otherwise
    • getAllowedNodeNames

      public QNameTest getAllowedNodeNames()
      Get the set of allowed node names that this type if capable of matching
      Specified by:
      getAllowedNodeNames in class XNodeType
      Returns:
      the allowed node names
    • getNodeKind

      public int getNodeKind()
      Get the node kind that this name test matches
      Returns:
      the matching node kind
    • getUType

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

      public final double getDefaultPriority()
      Determine the default priority of this node test when used on its own as a Pattern
      Returns:
      the default priority
    • getBasicAlphaCode

      public String getBasicAlphaCode()
      Get an alphabetic code representing the type, or at any rate, the nearest built-in type from which this type is derived. The codes are designed so that for any two built-in types A and B, alphaCode(A) is a prefix of alphaCode(B) if and only if A is a supertype of B.
      Returns:
      the alphacode for the nearest containing built-in type. For example: for xs:string return "AS", for xs:boolean "AB", for node() "N", for element() "NE", for map(*) "FM", for array(*) "FA".
    • getPrimitiveType

      public int getPrimitiveType()
      Determine the types of nodes to which this pattern applies. Used for optimisation. For patterns that match nodes of several types, return Type.NODE
      Specified by:
      getPrimitiveType in interface ItemType
      Overrides:
      getPrimitiveType in class GNodeType
      Returns:
      the type of node matched by this pattern. e.g. Type.ELEMENT or Type.TEXT
    • toString

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

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

      public boolean equals(Object other)
      Determines whether two NameTests are equal
      Overrides:
      equals in class Object
    • 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 ItemType
      Specified by:
      explainMismatch in interface NodeTest
      Overrides:
      explainMismatch in class GNodeType
      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