Package net.sf.saxon.type
Class TypeHierarchy
java.lang.Object
net.sf.saxon.type.TypeHierarchy
- Direct Known Subclasses:
SubsumptionEE
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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTypeHierarchy(Configuration config) Create the type hierarchy cache for a configuration -
Method Summary
Modifier and TypeMethodDescriptionGet the Saxon configuration to which this type hierarchy belongsstatic SchemaTypeGet the nearest named type in the type hierarchy, that is, the nearest type that is not anonymous.booleanDetermine whether type A is type B or one of its subtypes, recursively.static ItemTypeReplace an item type, where necessary, by one that can safely be stored in the cache without causing garbage collection problems.relationship(ItemType t1, ItemType t2) Determine the relationship of one item type to another.static <X> Set<X> Convert a collection to a set
-
Field Details
-
config
-
-
Constructor Details
-
TypeHierarchy
Create the type hierarchy cache for a configuration- Parameters:
config- the configuration
-
-
Method Details
-
getNearestNamedType
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
Get the Saxon configuration to which this type hierarchy belongs- Returns:
- the configuration
-
isSubType
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 typesupertype- identifies the second type- Returns:
- true if the first type is the second type or is subsumed by the second type
-
relationship
Determine the relationship of one item type to another.- Parameters:
t1- the first item typet2- the second item type- Returns:
- One of:
Affinity.SAME_TYPEif the types are the same;Affinity.SUBSUMESif the first type subsumes the second (that is, all instances of the second type are also instances of the first);Affinity.SUBSUMED_BYif the second type subsumes the first;Affinity.OVERLAPSif the two types overlap (have a non-empty intersection, but neither subsumes the other);Affinity.DISJOINTif the two types are disjoint (have an empty intersection)
-
normalizeItemType
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
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
-