Class SchemaAttributeType

All Implemented Interfaces:
NamedXNodePredicate, NodePredicate, NodeTest, SchemaNodeTest, ItemType, ItemTypeWithSequenceTypeCache

public class SchemaAttributeType extends XNodeType implements SchemaNodeTest, NamedXNodePredicate
A Node type of the form schema-attribute(attribute-name)
Since:
9.3
  • Constructor Details

  • Method Details

    • getSchema

      public Schema getSchema()
      Get the schema from the static context of this type designation
      Returns:
      the in-scope schema
    • getContentType

      public SchemaType getContentType()
      Get the allowed content type permitted by this item type.
      Overrides:
      getContentType in class XNodeType
      Returns:
      the allowed content type
    • getAllowedNodeNames

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

      public StructuredQName getNodeName()
      Specified by:
      getNodeName in interface SchemaNodeTest
    • getRequiredFingerprint

      public int getRequiredFingerprint(int nodeKind)
      For an XNodeType that can only match one kind of node and one node name, return that node name, as an integer fingerprint. In other cases, return -1.
      Overrides:
      getRequiredFingerprint in class XNodeType
      Parameters:
      nodeKind - the kind of node required. If the XNodeType does not match this node kind, return -1.
      Returns:
      an integer fingerprint in the case of a node type that only matches one node kind and one qualified name. In other cases return -1.
    • 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
    • getNodeKind

      public int getNodeKind()
      Get the kind of nodes that this node predicate matches
      Specified by:
      getNodeKind in interface NamedXNodePredicate
      Returns:
      the kind of nodes specifically Type.ATTRIBUTE
    • getRequiredFingerprint

      public int getRequiredFingerprint()
      Get a fingerprint that all nodes (of the specified node kind) must have if they are to satisfy the predicate.
      Specified by:
      getRequiredFingerprint in interface NamedXNodePredicate
      Returns:
      the fingerprint of the name that a node must have if it is to satisfy the predicate
    • getMatchingNodeName

      public StructuredQName getMatchingNodeName()
      Get the corresponding StructuredQName: the name that all nodes must have if they are to satisfy the predicate
      Specified by:
      getMatchingNodeName in interface NamedXNodePredicate
      Returns:
      the name that a node must have if it is to satisfy the predicate
    • isFingerprintSufficient

      public boolean isFingerprintSufficient()
      Ask whether having the required fingerprint and node kind is a sufficient condition for a node to satisfy the predicate, or whether other conditions (such as type annotation or nillability) must also be satisfied.
      Specified by:
      isFingerprintSufficient in interface NamedXNodePredicate
      Returns:
      true if matching the fingerprint is a sufficient condition.
    • matches

      public boolean matches(Item item)
      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:
      matches in interface ItemType
      Specified by:
      matches in class GNodeType
      Parameters:
      item - the item to be matched
      Returns:
      true if the item is an instance of this type; false otherwise
    • getDefaultPriority

      public final double getDefaultPriority()
      Determine the default priority of this node test when used on its own as a Pattern
      Specified by:
      getDefaultPriority in interface ItemType
      Specified by:
      getDefaultPriority in interface NodeTest
      Returns:
      the default priority
    • 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)
      Overrides:
      equals in class Object
    • getBasicAlphaCode

      public String getBasicAlphaCode()
      Description copied from interface: ItemType
      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.
      Specified by:
      getBasicAlphaCode in interface ItemType
      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".
    • 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