Package net.sf.saxon.type.gnode
Class GNodeType
java.lang.Object
net.sf.saxon.type.gnode.GNodeType
- All Implemented Interfaces:
NodePredicate,NodeTest,ItemType,ItemTypeWithSequenceTypeCache
- Direct Known Subclasses:
AnyGNodeType,ErrorType,JNodeType,XNodeType
public abstract class GNodeType
extends Object
implements ItemTypeWithSequenceTypeCache, ItemType, NodeTest
Abstract superclass for all gnode types. In 4.0, node predicates (as used in axis steps)
are separated from node types (as item types). Subclasses of
GNodeType represent
item types whose instances are all nodes; they cannot be used directly as node predicates
in an axis step.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionexplainMismatch(Item item, TypeHierarchy th) Get extra diagnostic information about why a supplied item does not conform to this item type, if available.Get the item type of the atomic values that will be produced when an item of this type is atomizedgetCoercionPlan(int version) Get the coercion plan for use when this type is the required type for (say) coercion of arguments in a function callGet the allowed content type.getGenre()Determine the Genre (top-level classification) of this typeGet an item type that all matching nodes must satisfyGet the primitive item type corresponding to this item type.intGet the primitive type corresponding to this item type.Extract a QNameTest (the strongest one possible) that must be satisfied by a node if it is to satisfy this NodeTestgetUType()Get the correspondingUType.final booleanDetermine whether this item type is an atomic typebooleanAsk whether values of this type are atomizablefinal booleanDetermine whether this item type is a plain type (that is, whether it can ONLY match atomic values)abstract booleanTest whether a given item conforms to this typeone()Get a sequence type representing exactly one instance of this typeGet a sequence type representing one or more instances of this typefinal booleanTest whether a given item conforms to this type (to implementNodePredicate)Get a concise string representation of this node test for use in diagnosticsGet a sequence type representing one or more instances of this typeGet a sequence type representing zero or one instances of this typeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.sf.saxon.type.ItemType
asChoiceItemType, getBasicAlphaCode, getDefaultPriority, getNormalizedDefaultPriority, normalizeItemType, toExportStringMethods inherited from interface net.sf.saxon.pattern.nodetest.NodeTest
asXNodeTest, export, getDefaultPriority, isNillable
-
Constructor Details
-
GNodeType
public GNodeType()
-
-
Method Details
-
getGenre
Determine the Genre (top-level classification) of this type -
isAtomicType
public final boolean isAtomicType()Determine whether this item type is an atomic type- Specified by:
isAtomicTypein interfaceItemType- Returns:
- true if this is ANY_ATOMIC_TYPE or a subtype thereof
-
isPlainType
public final boolean isPlainType()Determine whether this item type is a plain type (that is, whether it can ONLY match atomic values)- Specified by:
isPlainTypein interfaceItemType- Returns:
- true if this is ANY_ATOMIC_TYPE or a subtype thereof, or a "plain" union type (that is, unions of atomic types that impose no further restrictions). Return false if this is a union type whose member types are not all known.
-
getContentType
Get the allowed content type. By default, this returns ANY_TYPE, allowing any content.- Returns:
- the allowed content type
-
getPrimitiveItemType
Get the primitive item type corresponding to this item type. For item(), this is Type.ITEM. For node(), it is Type.NODE. For specific node kinds, it is the value representing the node kind, for example Type.ELEMENT. For anyAtomicValue and union types it is Type.ATOMIC_VALUE. For numeric it is Type.NUMBER. For other atomic types it is the primitive type as defined in XML Schema, except that integer, xs:dayTimeDuration, and xs:yearMonthDuration are considered to be primitive types.- Specified by:
getPrimitiveItemTypein interfaceItemType- Returns:
- the corresponding primitive type
-
getPrimitiveType
public int getPrimitiveType()Get the primitive type corresponding to this item type. For item(), this is Type.ITEM. For node(), it is Type.NODE. For specific node kinds, it is the value representing the node kind, for example Type.ELEMENT. For anyAtomicValue it is BuiltInAtomicType.ANY_ATOMIC. For numeric it is Type.NUMBER. For other atomic types it is the primitive type as defined in XML Schema, except that INTEGER is considered to be a primitive type.- Specified by:
getPrimitiveTypein interfaceItemType- Returns:
- the integer fingerprint of the corresponding primitive type
-
matches
Test whether a given item conforms to this type -
test
Test whether a given item conforms to this type (to implementNodePredicate)- Specified by:
testin interfaceNodePredicate- Specified by:
testin interfaceNodeTest- Parameters:
node- The item to be tested- Returns:
- true if the item is an instance of this type; false otherwise
-
getUType
Get the correspondingUType. A UType is a union of primitive item types. -
getCoercionPlan
Get the coercion plan for use when this type is the required type for (say) coercion of arguments in a function call- Specified by:
getCoercionPlanin interfaceItemType- Parameters:
version- the XPath language version (40 or 31)
-
getAtomizedItemType
Get the item type of the atomic values that will be produced when an item of this type is atomized- Specified by:
getAtomizedItemTypein interfaceItemType- Returns:
- the best available item type of the atomic values that will be produced when an item of this type is atomized, or null if it is known that atomization will throw an error.
-
isAtomizable
Ask whether values of this type are atomizable- Specified by:
isAtomizablein interfaceItemType- Parameters:
th- the type hierarchy cache- Returns:
- true if some or all instances of this type can be successfully atomized; false if no instances of this type can be atomized
-
explainMismatch
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:
explainMismatchin interfaceItemType- Specified by:
explainMismatchin interfaceNodeTest- Parameters:
item- the item that doesn't match this typeth- the type hierarchy cache- Returns:
- optionally, a message explaining why the item does not match the type
-
getQNameTest
Extract a QNameTest (the strongest one possible) that must be satisfied by a node if it is to satisfy this NodeTest- Specified by:
getQNameTestin interfaceNodeTest- Returns:
- the strongest possible QNameTest
-
getItemType
Get an item type that all matching nodes must satisfy- Specified by:
getItemTypein interfaceNodeTest- Returns:
- an item type
-
toShortString
Get a concise string representation of this node test for use in diagnostics- Specified by:
toShortStringin interfaceNodeTest- Returns:
- a suitably abbreviated respresention of the node test
-
one
Get a sequence type representing exactly one instance of this type- Specified by:
onein interfaceItemTypeWithSequenceTypeCache- Returns:
- a sequence type representing exactly one instance of this type
-
zeroOrOne
Get a sequence type representing zero or one instances of this type- Specified by:
zeroOrOnein interfaceItemTypeWithSequenceTypeCache- Returns:
- a sequence type representing zero or one instances of this type
-
oneOrMore
Get a sequence type representing one or more instances of this type- Specified by:
oneOrMorein interfaceItemTypeWithSequenceTypeCache- Returns:
- a sequence type representing one or more instances of this type
-
zeroOrMore
Get a sequence type representing one or more instances of this type- Specified by:
zeroOrMorein interfaceItemTypeWithSequenceTypeCache- Returns:
- a sequence type representing one or more instances of this type
-