net.sf.saxon.type

Class ExternalObjectType

public class ExternalObjectType extends Object implements AtomicType, Serializable

This class represents the type of an external Java object returned by an extension function, or supplied as an external variable/parameter.
Field Summary
intbaseFingerprint
intfingerprint
static ExternalObjectTypeGENERAL_EXTERNAL_OBJECT_TYPE
Constructor Summary
ExternalObjectType(Class javaClass)
Method Summary
booleanallowsDerivation(int derivation)
Determines whether derivation (of a particular kind) from this type is allowed, based on the "final" property
voidanalyzeContentExpression(Expression expression, int kind, StaticContext env)
Analyze an expression to see whether the expression is capable of delivering a value of this type.
static voidanalyzeContentExpression(SimpleType simpleType, Expression expression, StaticContext env, int kind)
Analyze an expression to see whether the expression is capable of delivering a value of this type.
CharSequenceapplyWhitespaceNormalization(CharSequence value)
Apply the whitespace normalization rules for this simple type
Valueatomize(NodeInfo node)
Get the typed value of a node that is annotated with this schema type.
AtomicTypegetAtomizedItemType()
Get the item type of the atomic values that will be produced when an item of this type is atomized
SchemaTypegetBaseType()
Returns the base type that this type inherits from.
intgetBlock()
Returns the value of the 'block' attribute for this type, as a bit-signnificant integer with fields such as DERIVATION_LIST and DERIVATION_EXTENSION
SchemaTypegetBuiltInBaseType()
Returns the built-in base type this type is derived from.
AtomicTypegetCommonAtomicType()
Get the most specific possible atomic type that all items in this SimpleType belong to
intgetDerivationMethod()
Gets the integer code of the derivation method used to derive this type from its parent.
StringgetDescription()
StringgetDisplayName()
intgetFingerprint()
ClassgetJavaClass()
SchemaTypegetKnownBaseType()
Returns the base type that this type inherits from.
intgetNameCode()
Get the namecode of the name of this type.
ItemTypegetPrimitiveItemType()
Get the primitive item type corresponding to this item type.
intgetPrimitiveType()
Get the primitive type corresponding to this item type.
ItemTypegetSuperType(TypeHierarchy th)
SequenceIteratorgetTypedValue(NodeInfo node)
Get the typed value of a node that is annotated with this schema type
SequenceIteratorgetTypedValue(CharSequence value, NamespaceResolver resolver, NameChecker nameChecker)
Get the typed value corresponding to a given string value, assuming it is valid against this type
intgetValidationStatus()
Get the validation status - always valid
intgetWhitespaceAction(TypeHierarchy th)
Determine the whitespace normalization required for values of this type
booleanisAtomicType()
Test whether this Simple Type is an atomic type
booleanisBuiltIn()
booleanisComplexType()
Test whether this SchemaType is a complex type
booleanisListType()
Returns true if this type is derived by list, or if it is derived by restriction from a list type, or if it is a union that contains a list as one of its members
booleanisNamespaceSensitive()
Test whether this simple type is namespace-sensitive, that is, whether it is derived from xs:QName or xs:NOTATION
booleanisSameType(SchemaType other)
Test whether this is the same type as another type.
booleanisSimpleType()
Returns true if this SchemaType is a SimpleType
voidisTypeDerivationOK(SchemaType type, int block)
Check that this type is validly derived from a given type
booleanisUnionType()
Return true if this type is a union type (that is, if its variety is union)
AtomicValuemakeDerivedValue(AtomicValue primValue, CharSequence lexicalValue, boolean validate)
Factory method to create values of a derived atomic type.
booleanmatchesItem(Item item, XPathContext context, boolean allowURIPromotion)
StringtoString(NamePool pool)
Produce a representation of this type name for use in error messages.
StringtoString()
ValidationExceptionvalidateContent(CharSequence value, NamespaceResolver nsResolver, NameChecker nameChecker)
Check whether a given input string is valid according to this SimpleType

Field Detail

baseFingerprint

int baseFingerprint

fingerprint

int fingerprint

GENERAL_EXTERNAL_OBJECT_TYPE

public static final ExternalObjectType GENERAL_EXTERNAL_OBJECT_TYPE

Constructor Detail

ExternalObjectType

public ExternalObjectType(Class javaClass)

Method Detail

allowsDerivation

public final boolean allowsDerivation(int derivation)
Determines whether derivation (of a particular kind) from this type is allowed, based on the "final" property

Parameters: derivation the kind of derivation, for example DERIVATION_LIST

Returns: true if this kind of derivation is allowed

analyzeContentExpression

public void analyzeContentExpression(Expression expression, int kind, StaticContext env)
Analyze an expression to see whether the expression is capable of delivering a value of this type.

Parameters: expression the expression that delivers the content kind the node kind whose content is being delivered: ELEMENT, ATTRIBUTE, or DOCUMENT env

Throws: net.sf.saxon.trans.XPathException if the expression will never deliver a value of the correct type

analyzeContentExpression

public static void analyzeContentExpression(SimpleType simpleType, Expression expression, StaticContext env, int kind)
Analyze an expression to see whether the expression is capable of delivering a value of this type.

Parameters: simpleType the simple type against which the expression is to be checked expression the expression that delivers the content kind the node kind whose content is being delivered: ELEMENT, ATTRIBUTE, or DOCUMENT

Throws: net.sf.saxon.trans.XPathException if the expression will never deliver a value of the correct type

applyWhitespaceNormalization

public CharSequence applyWhitespaceNormalization(CharSequence value)
Apply the whitespace normalization rules for this simple type

Parameters: value the string before whitespace normalization

Returns: the string after whitespace normalization

atomize

public Value atomize(NodeInfo node)
Get the typed value of a node that is annotated with this schema type. The result of this method will always be consistent with the method ExternalObjectType. However, this method is often more convenient and may be more efficient, especially in the common case where the value is expected to be a singleton.

Parameters: node the node whose typed value is required

Returns: the typed value.

Since: 8.5

getAtomizedItemType

public AtomicType getAtomizedItemType()
Get the item type of the atomic values that will be produced when an item of this type is atomized

getBaseType

public final SchemaType getBaseType()
Returns the base type that this type inherits from. This method can be used to get the base type of a type that is known to be valid. If this type is a Simpletype that is a built in primitive type then null is returned.

Returns: the base type.

Throws: IllegalStateException if this type is not valid.

getBlock

public final int getBlock()
Returns the value of the 'block' attribute for this type, as a bit-signnificant integer with fields such as DERIVATION_LIST and DERIVATION_EXTENSION

Returns: the value of the 'block' attribute for this type

getBuiltInBaseType

public SchemaType getBuiltInBaseType()
Returns the built-in base type this type is derived from.

Returns: the first built-in type found when searching up the type hierarchy

getCommonAtomicType

public AtomicType getCommonAtomicType()
Get the most specific possible atomic type that all items in this SimpleType belong to

Returns: the lowest common supertype of all member types

getDerivationMethod

public final int getDerivationMethod()
Gets the integer code of the derivation method used to derive this type from its parent. Returns zero for primitive types.

Returns: a numeric code representing the derivation method, for example DERIVATION_RESTRICTION

getDescription

public String getDescription()

getDisplayName

public String getDisplayName()

getFingerprint

public int getFingerprint()

getJavaClass

public Class getJavaClass()

getKnownBaseType

public SchemaType getKnownBaseType()
Returns the base type that this type inherits from. This method can be used to get the base type of a type that is known to be valid. If this type is a Simpletype that is a built in primitive type then null is returned.

Returns: the base type.

Throws: IllegalStateException if this type is not valid.

getNameCode

public int getNameCode()
Get the namecode of the name of this type. This includes the prefix from the original type declaration: in the case of built-in types, there may be a conventional prefix or there may be no prefix.

getPrimitiveItemType

public ItemType 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 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 is considered to be a 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 Type.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.

getSuperType

public ItemType getSuperType(TypeHierarchy th)

getTypedValue

public final SequenceIterator getTypedValue(NodeInfo node)
Get the typed value of a node that is annotated with this schema type

Parameters: node the node whose typed value is required

Returns: an iterator over the items making up the typed value of this node. The objects returned by this SequenceIterator will all be of type AtomicValue

getTypedValue

public SequenceIterator getTypedValue(CharSequence value, NamespaceResolver resolver, NameChecker nameChecker)
Get the typed value corresponding to a given string value, assuming it is valid against this type

Parameters: value the string value resolver a namespace resolver used to resolve any namespace prefixes appearing in the content of values. Can supply null, in which case any namespace-sensitive content will be rejected. nameChecker

Returns: an iterator over the atomic sequence comprising the typed value. The objects returned by this SequenceIterator will all be of type AtomicValue

getValidationStatus

public final int getValidationStatus()
Get the validation status - always valid

getWhitespaceAction

public int getWhitespaceAction(TypeHierarchy th)
Determine the whitespace normalization required for values of this type

Parameters: th

Returns: one of PRESERVE, REPLACE, COLLAPSE

isAtomicType

public boolean isAtomicType()
Test whether this Simple Type is an atomic type

Returns: true, this is considered to be an atomic type

isBuiltIn

public boolean isBuiltIn()

isComplexType

public final boolean isComplexType()
Test whether this SchemaType is a complex type

Returns: true if this SchemaType is a complex type

isListType

public boolean isListType()
Returns true if this type is derived by list, or if it is derived by restriction from a list type, or if it is a union that contains a list as one of its members

Returns: true if this is a list type

isNamespaceSensitive

public boolean isNamespaceSensitive()
Test whether this simple type is namespace-sensitive, that is, whether it is derived from xs:QName or xs:NOTATION

Returns: true if this type is derived from xs:QName or xs:NOTATION

isSameType

public boolean isSameType(SchemaType other)
Test whether this is the same type as another type. They are considered to be the same type if they are derived from the same type definition in the original XML representation (which can happen when there are multiple includes of the same file)

isSimpleType

public final boolean isSimpleType()
Returns true if this SchemaType is a SimpleType

Returns: true (always)

isTypeDerivationOK

public void isTypeDerivationOK(SchemaType type, int block)
Check that this type is validly derived from a given type

Parameters: type the type from which this type is derived block the derivations that are blocked by the relevant element declaration

Throws: SchemaException if the derivation is not allowed

isUnionType

public boolean isUnionType()
Return true if this type is a union type (that is, if its variety is union)

Returns: true for a union type

makeDerivedValue

public AtomicValue makeDerivedValue(AtomicValue primValue, CharSequence lexicalValue, boolean validate)
Factory method to create values of a derived atomic type. This method is not used to create values of a built-in type, even one that is not primitive.

Parameters: primValue the value in the value space of the primitive type lexicalValue the value in the lexical space. If null, the string value of primValue validate true if the value is to be validated against the facets of the derived type; false if the caller knows that the value is already valid.

matchesItem

public boolean matchesItem(Item item, XPathContext context, boolean allowURIPromotion)

toString

public String toString(NamePool pool)
Produce a representation of this type name for use in error messages. Where this is a QName, it will use conventional prefixes

toString

public String toString()

validateContent

public ValidationException validateContent(CharSequence value, NamespaceResolver nsResolver, NameChecker nameChecker)
Check whether a given input string is valid according to this SimpleType

Parameters: value the input string to be checked nsResolver a namespace resolver used to resolve namespace prefixes if the type is namespace sensitive. The value supplied may be null; in this case any namespace-sensitive content will throw an UnsupportedOperationException. nameChecker

Returns: null if validation succeeds; return a ValidationException describing the validation failure if validation fails, unless throwException is true, in which case the exception is thrown rather than being returned.

Throws: UnsupportedOperationException if the type is namespace-sensitive and no namespace resolver is supplied