Class TypeHierarchy

java.lang.Object
net.sf.saxon.type.TypeHierarchy
Direct Known Subclasses:
SubsumptionEE

public class TypeHierarchy extends Object
This class exists to provide answers to questions about the type hierarchy. Because such questions are potentially expensive, it caches the answers. There is one instance of this class for a Configuration. The actual logic for computing relationships (without any cache) is in class Subsumption.
  • Field Details

  • Constructor Details

    • TypeHierarchy

      public TypeHierarchy(Configuration config)
      Create the type hierarchy cache for a configuration
      Parameters:
      config - the configuration
  • Method Details

    • getNearestNamedType

      public static SchemaType getNearestNamedType(SchemaType type)
      Get the nearest named type in the type hierarchy, that is, the nearest type that is not anonymous. (In practice, since types cannot be derived from anonymous types, this will either the type itself, or its immediate base type).
      Returns:
      the nearest type, found by following the getBaseType() relation recursively, that is not an anonymous type
    • getConfiguration

      public Configuration getConfiguration()
      Get the Saxon configuration to which this type hierarchy belongs
      Returns:
      the configuration
    • isSubType

      public boolean isSubType(ItemType subtype, ItemType supertype)
      Determine whether type A is type B or one of its subtypes, recursively. "Subtype" here means a type that is subsumed, that is, a type whose instances are a subset of the instances of the other type.
      Parameters:
      subtype - identifies the first type
      supertype - identifies the second type
      Returns:
      true if the first type is the second type or is subsumed by the second type
    • relationship

      public Affinity relationship(ItemType t1, ItemType t2)
      Determine the relationship of one item type to another.
      Parameters:
      t1 - the first item type
      t2 - the second item type
      Returns:
      One of:
    • normalizeItemType

      public static ItemType normalizeItemType(ItemType in)
      Replace an item type, where necessary, by one that can safely be stored in the cache without causing garbage collection problems. Specifically, a SameNameTest cannot be stored in the cache because it contains a reference to a node in a document.
      Parameters:
      in - the supplied item type
      Returns:
      either the supplied item type, or an equivalent that can safely be cached.
    • toSet

      public static <X> Set<X> toSet(Iterable<X> in)
      Convert a collection to a set
      Type Parameters:
      X - the member type of the collection
      Parameters:
      in - the input collection
      Returns:
      a set with the same members as the supplied collection