Package net.sf.saxon.type
Interface AtomicType
-
- All Superinterfaces:
CastingTarget
,HyperType
,ItemType
,PlainType
,SchemaComponent
,SchemaType
,SimpleType
- All Known Implementing Classes:
BuiltInAtomicType
,EnumerationType
,ErrorType
,UserAtomicType
public interface AtomicType extends SimpleType, PlainType, CastingTarget
Interface for atomic types (these are either built-in atomic types or user-defined atomic types). An AtomicType is both an ItemType (a possible type for items in a sequence) and a SchemaType (a possible type for validating and annotating nodes).
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default java.util.Optional<java.lang.String>
explainMismatch(Item item, TypeHierarchy th)
Get extra diagnostic information about why a supplied item does not conform to this item type, if available.default double
getDefaultPriority()
Get the default priority when this ItemType is used as an XSLT pattern.default Genre
getGenre()
Determine the Genre (top-level classification) of this typedefault BuiltInAtomicType
getPrimitiveAtomicType()
Get the primitive base type.StringConverter
getStringConverter(ConversionRules rules)
Get a StringConverter, an object which converts strings in the lexical space of this data type to instances (in the value space) of the data type.StructuredQName
getTypeName()
Get the name of this type as a StructuredQName, unless the type is anonymous, in which case return nullboolean
isAbstract()
Determine whether the type is abstract, that is, whether it cannot have instances that are not also instances of some concrete subtypeboolean
isBuiltInType()
Determine whether the atomic type is a built-in type.boolean
isIdRefType()
Ask whether this type is an IDREF or IDREFS type.boolean
isIdType()
Ask whether this type is an ID type.boolean
isOrdered(boolean optimistic)
Determine whether the atomic type is ordered, that is, whether less-than and greater-than comparisons are permittedboolean
isPrimitiveType()
Determine whether the atomic type is a primitive type.ValidationFailure
validate(AtomicValue primValue, UnicodeString lexicalValue, ConversionRules rules)
Validate that a primitive atomic value is a valid instance of a type derived from the same primitive type.-
Methods inherited from interface net.sf.saxon.type.HyperType
isNamespaceSensitive
-
Methods inherited from interface net.sf.saxon.type.ItemType
getAtomizedItemType, getBasicAlphaCode, getFullAlphaCode, getNormalizedDefaultPriority, getPrimitiveType, getUType, isAtomicType, isAtomizable, isPlainType, toExportString
-
Methods inherited from interface net.sf.saxon.type.PlainType
getPlainMemberTypes, getPrimitiveItemType, matches
-
Methods inherited from interface net.sf.saxon.type.SchemaComponent
getComponentAsFunction, getRedefinitionLevel, getValidationStatus
-
Methods inherited from interface net.sf.saxon.type.SchemaType
allowsDerivation, analyzeContentExpression, atomize, checkTypeDerivationIsOK, getBaseType, getBlock, getDerivationMethod, getDescription, getDisplayName, getEQName, getFinalProhibitions, getFingerprint, getName, getStructuredQName, getSystemId, getTargetNamespace, isAnonymousType, isComplexType, isSameType, isSimpleType
-
Methods inherited from interface net.sf.saxon.type.SimpleType
getBuiltInBaseType, getTypedValue, getWhitespaceAction, isAtomicType, isListType, isUnionType, postprocess, preprocess, validateContent
-
-
-
-
Method Detail
-
getGenre
default Genre getGenre()
Determine the Genre (top-level classification) of this type- Specified by:
getGenre
in interfaceItemType
- Returns:
- the Genre to which this type belongs, specifically
Genre.ATOMIC
-
validate
ValidationFailure validate(AtomicValue primValue, UnicodeString lexicalValue, ConversionRules rules)
Validate that a primitive atomic value is a valid instance of a type derived from the same primitive type.- 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 is used. This value is checked against the pattern facet (if any)rules
- the conversion rules for this configuration- Returns:
- null if the value is valid; otherwise, a ValidationFailure object indicating the nature of the error.
- Throws:
java.lang.UnsupportedOperationException
- in the case of an external object type
-
isOrdered
boolean isOrdered(boolean optimistic)
Determine whether the atomic type is ordered, that is, whether less-than and greater-than comparisons are permitted- Parameters:
optimistic
- if true, the function takes an optimistic view, returning true if ordering comparisons are available for some subtype. This mainly affects xs:duration, where the function returns true if optimistic is true, false if it is false.- Returns:
- true if ordering operations are permitted
-
isAbstract
boolean isAbstract()
Determine whether the type is abstract, that is, whether it cannot have instances that are not also instances of some concrete subtype- Returns:
- true if the type is abstract
-
isPrimitiveType
boolean isPrimitiveType()
Determine whether the atomic type is a primitive type. The primitive types are the 19 primitive types of XML Schema, plus xs:integer, xs:dayTimeDuration and xs:yearMonthDuration; xs:untypedAtomic; and all supertypes of these (xs:anyAtomicType, ...)- Returns:
- true if the type is considered primitive under the above rules
-
getPrimitiveAtomicType
default BuiltInAtomicType getPrimitiveAtomicType()
Get the primitive base type. The primitive types are the 19 primitive types of XML Schema, plus xs:integer, xs:dayTimeDuration and xs:yearMonthDuration; xs:untypedAtomic; and all supertypes of these (xs:anyAtomicType, ...)
-
isIdType
boolean isIdType()
Ask whether this type is an ID type. This is defined to be any simple type who typed value may contain atomic values of type xs:ID: that is, it includes types derived from ID by restriction, list, or union. Note that for a node to be treated as an ID, its typed value must be a *single* atomic value of type ID; the type of the node, however, can still allow a list.- Specified by:
isIdType
in interfaceSchemaType
- Returns:
- true if this type is an ID type
-
isIdRefType
boolean isIdRefType()
Ask whether this type is an IDREF or IDREFS type. This is defined to be any simple type who typed value may contain atomic values of type xs:IDREF: that is, it includes types derived from IDREF or IDREFS by restriction, list, or union- Specified by:
isIdRefType
in interfaceSchemaType
- Returns:
- true if this type is an IDREF type
-
isBuiltInType
boolean isBuiltInType()
Determine whether the atomic type is a built-in type. The built-in atomic types are the 41 atomic types defined in XML Schema, plus xs:dayTimeDuration and xs:yearMonthDuration, xs:untypedAtomic, and all supertypes of these (xs:anyAtomicType, xs:numeric, ...)- Specified by:
isBuiltInType
in interfaceSimpleType
- Returns:
- true if this is a built-in type
-
getTypeName
StructuredQName getTypeName()
Get the name of this type as a StructuredQName, unless the type is anonymous, in which case return null- Specified by:
getTypeName
in interfacePlainType
- Returns:
- the name of the atomic type, or null if the type is anonymous.
-
getStringConverter
StringConverter getStringConverter(ConversionRules rules)
Get a StringConverter, an object which converts strings in the lexical space of this data type to instances (in the value space) of the data type.- Parameters:
rules
- the conversion rules to be used- Returns:
- a StringConverter to do the conversion, or null if no built-in converter is available.
-
explainMismatch
default java.util.Optional<java.lang.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 interfaceItemType
- 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
-
getDefaultPriority
default double getDefaultPriority()
Get the default priority when this ItemType is used as an XSLT pattern.- Specified by:
getDefaultPriority
in interfaceItemType
- Returns:
- the default priority. For an atomic type this is 1 minus 0.5^N, where N is the depth of the type in the type hierarchy. The result is 0 for xs:anyAtomicType, 0.5 for a primitive type such as xs:date, and between 0.5 and 1.0 for derived atomic types.
-
-