Package net.sf.saxon.value
Class SequenceType
- java.lang.Object
-
- net.sf.saxon.value.SequenceType
-
public final class SequenceType extends java.lang.ObjectSequenceType: a sequence type consists of a primary type, which indicates the type of item, and a cardinality, which indicates the number of occurrences permitted. Where the primary type is element or attribute, there may also be a content type, indicating the required type annotation on the element or attribute content.
-
-
Field Summary
Fields Modifier and Type Field Description static SequenceTypeANY_SEQUENCEA type that allows any sequence of itemsstatic SequenceTypeATOMIC_SEQUENCEstatic SequenceTypeEMPTY_SEQUENCEA type that only permits the empty sequencestatic SequenceTypeFUNCTION_ITEM_SEQUENCEA type that allows a sequence of zero or mode function itemsstatic SequenceTypeNODE_SEQUENCEA type that allows a sequence of zero or more nodesstatic SequenceTypeNON_EMPTY_SEQUENCEA type that only permits a non-empty sequencestatic SequenceTypeOPTIONAL_ANY_URIA type that allows a single optional anyURIstatic SequenceTypeOPTIONAL_ATOMICA type that allows zero or one atomic valuesstatic SequenceTypeOPTIONAL_BASE64_BINARYA type that allows a single optional xs:Base64Binarystatic SequenceTypeOPTIONAL_BOOLEANA type that allows a single optional booleanstatic SequenceTypeOPTIONAL_BYTEA type that allows a single optional bytestatic SequenceTypeOPTIONAL_DATEA type that allows a single optional datestatic SequenceTypeOPTIONAL_DATE_TIMEA type that allows a single optional dateTimestatic SequenceTypeOPTIONAL_DAY_TIME_DURATIONA type that allows a single optional dayTimeDurationstatic SequenceTypeOPTIONAL_DECIMALA type that allows a single optional decimalstatic SequenceTypeOPTIONAL_DOCUMENT_NODEA type that allows a single document nodestatic SequenceTypeOPTIONAL_DOUBLEA type that allows a single optional doublestatic SequenceTypeOPTIONAL_DURATIONA type that allows a single optional durationstatic SequenceTypeOPTIONAL_FLOATA type that allows a single optional floatstatic SequenceTypeOPTIONAL_FUNCTION_ITEMA type that allows a sequence of zero or one function itemsstatic SequenceTypeOPTIONAL_G_DAYA type that allows a single optional gDaystatic SequenceTypeOPTIONAL_G_MONTHA type that allows a single optional gMonthstatic SequenceTypeOPTIONAL_G_MONTH_DAYA type that allows a single optional gMonthDaystatic SequenceTypeOPTIONAL_G_YEARA type that allows a single optional gYearstatic SequenceTypeOPTIONAL_G_YEAR_MONTHA type that allows a single optional gYearMonthstatic SequenceTypeOPTIONAL_HEX_BINARYA type that allows a single optional xs:hexBinarystatic SequenceTypeOPTIONAL_INTEGERA type that allows a single optional integerstatic SequenceTypeOPTIONAL_ITEMA type that allows zero or one items, of any kindstatic SequenceTypeOPTIONAL_NODEA type that allows zero or one nodesstatic SequenceTypeOPTIONAL_NOTATIONA type that allows a single optional xs:NOTATIONstatic SequenceTypeOPTIONAL_NUMERICA type that allows an optional numeric valuestatic SequenceTypeOPTIONAL_QNAMEA type that allows a single optional xs:QNamestatic SequenceTypeOPTIONAL_SHORTA type that allows a single optional shortstatic SequenceTypeOPTIONAL_STRINGA type that allows a single optional stringstatic SequenceTypeOPTIONAL_TIMEA type that allows a single optional timestatic SequenceTypeOPTIONAL_YEAR_MONTH_DURATIONA type that allows a single optional yearMonthDurationstatic SequenceTypeSINGLE_ATOMICA type that allows exactly one atomic valuestatic SequenceTypeSINGLE_BOOLEANA type that allows a single booleanstatic SequenceTypeSINGLE_BYTEA type that allows a single shortstatic SequenceTypeSINGLE_DECIMALA type that allows a single decimalstatic SequenceTypeSINGLE_DOUBLEA type that allows a single doublestatic SequenceTypeSINGLE_FLOATA type that allows a single floatstatic SequenceTypeSINGLE_FUNCTIONA type that allows a single function itemstatic SequenceTypeSINGLE_INTEGERA type that allows a single integerstatic SequenceTypeSINGLE_ITEMA type that allows exactly one item, of any kindstatic SequenceTypeSINGLE_NODEA type that allows a single nodestatic SequenceTypeSINGLE_NUMERICstatic SequenceTypeSINGLE_QNAMEA type that allows a single xs:QNamestatic SequenceTypeSINGLE_SHORTA type that allows a single shortstatic SequenceTypeSINGLE_STRINGA type that allows a single stringstatic SequenceTypeSINGLE_UNTYPED_ATOMICA type that allows a single untyped atomicstatic SequenceTypeSTRING_SEQUENCEA type that allows a sequence of zero or more string valuesstatic SequenceTypeVOIDA type that has no instances
-
Constructor Summary
Constructors Constructor Description SequenceType(ItemType primaryType, int cardinality)Construct an instance of SequenceType.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)Indicates whether some other object is "equal to" this one.java.util.Optional<java.lang.String>explainMismatch(GroundedValue value, TypeHierarchy th)Get extra diagnostic information about why a supplied item does not conform to this item type, if available.intgetCardinality()Get the cardinality component of this SequenceType.ItemTypegetPrimaryType()Get the "primary" part of this required type.inthashCode()Returns a hash code value for the object.booleanisSameType(SequenceType other, TypeHierarchy th)static SequenceTypemakeSequenceType(ItemType primaryType, int cardinality)Construct an instance of SequenceType.booleanmatches(Sequence value, TypeHierarchy th)Determine whether a given value is a valid instance of this SequenceTypejava.lang.StringtoAlphaCode()java.lang.StringtoExportString()Return a string representation of this SequenceType suitable for use in stylesheet export files.java.lang.StringtoString()Return a string representation of this SequenceType
-
-
-
Field Detail
-
ANY_SEQUENCE
public static final SequenceType ANY_SEQUENCE
A type that allows any sequence of items
-
SINGLE_ITEM
public static final SequenceType SINGLE_ITEM
A type that allows exactly one item, of any kind
-
OPTIONAL_ITEM
public static final SequenceType OPTIONAL_ITEM
A type that allows zero or one items, of any kind
-
SINGLE_ATOMIC
public static final SequenceType SINGLE_ATOMIC
A type that allows exactly one atomic value
-
OPTIONAL_ATOMIC
public static final SequenceType OPTIONAL_ATOMIC
A type that allows zero or one atomic values
-
ATOMIC_SEQUENCE
public static final SequenceType ATOMIC_SEQUENCE
-
SINGLE_STRING
public static final SequenceType SINGLE_STRING
A type that allows a single string
-
SINGLE_UNTYPED_ATOMIC
public static final SequenceType SINGLE_UNTYPED_ATOMIC
A type that allows a single untyped atomic
-
OPTIONAL_STRING
public static final SequenceType OPTIONAL_STRING
A type that allows a single optional string
-
SINGLE_BOOLEAN
public static final SequenceType SINGLE_BOOLEAN
A type that allows a single boolean
-
OPTIONAL_BOOLEAN
public static final SequenceType OPTIONAL_BOOLEAN
A type that allows a single optional boolean
-
SINGLE_INTEGER
public static final SequenceType SINGLE_INTEGER
A type that allows a single integer
-
SINGLE_DECIMAL
public static final SequenceType SINGLE_DECIMAL
A type that allows a single decimal
-
OPTIONAL_INTEGER
public static final SequenceType OPTIONAL_INTEGER
A type that allows a single optional integer
-
SINGLE_SHORT
public static final SequenceType SINGLE_SHORT
A type that allows a single short
-
OPTIONAL_SHORT
public static final SequenceType OPTIONAL_SHORT
A type that allows a single optional short
-
SINGLE_BYTE
public static final SequenceType SINGLE_BYTE
A type that allows a single short
-
OPTIONAL_BYTE
public static final SequenceType OPTIONAL_BYTE
A type that allows a single optional byte
-
SINGLE_DOUBLE
public static final SequenceType SINGLE_DOUBLE
A type that allows a single double
-
OPTIONAL_DOUBLE
public static final SequenceType OPTIONAL_DOUBLE
A type that allows a single optional double
-
SINGLE_FLOAT
public static final SequenceType SINGLE_FLOAT
A type that allows a single float
-
OPTIONAL_FLOAT
public static final SequenceType OPTIONAL_FLOAT
A type that allows a single optional float
-
OPTIONAL_DECIMAL
public static final SequenceType OPTIONAL_DECIMAL
A type that allows a single optional decimal
-
OPTIONAL_ANY_URI
public static final SequenceType OPTIONAL_ANY_URI
A type that allows a single optional anyURI
-
OPTIONAL_DATE
public static final SequenceType OPTIONAL_DATE
A type that allows a single optional date
-
OPTIONAL_TIME
public static final SequenceType OPTIONAL_TIME
A type that allows a single optional time
-
OPTIONAL_G_YEAR
public static final SequenceType OPTIONAL_G_YEAR
A type that allows a single optional gYear
-
OPTIONAL_G_YEAR_MONTH
public static final SequenceType OPTIONAL_G_YEAR_MONTH
A type that allows a single optional gYearMonth
-
OPTIONAL_G_MONTH
public static final SequenceType OPTIONAL_G_MONTH
A type that allows a single optional gMonth
-
OPTIONAL_G_MONTH_DAY
public static final SequenceType OPTIONAL_G_MONTH_DAY
A type that allows a single optional gMonthDay
-
OPTIONAL_G_DAY
public static final SequenceType OPTIONAL_G_DAY
A type that allows a single optional gDay
-
OPTIONAL_DATE_TIME
public static final SequenceType OPTIONAL_DATE_TIME
A type that allows a single optional dateTime
-
OPTIONAL_DURATION
public static final SequenceType OPTIONAL_DURATION
A type that allows a single optional duration
-
OPTIONAL_YEAR_MONTH_DURATION
public static final SequenceType OPTIONAL_YEAR_MONTH_DURATION
A type that allows a single optional yearMonthDuration
-
OPTIONAL_DAY_TIME_DURATION
public static final SequenceType OPTIONAL_DAY_TIME_DURATION
A type that allows a single optional dayTimeDuration
-
SINGLE_QNAME
public static final SequenceType SINGLE_QNAME
A type that allows a single xs:QName
-
OPTIONAL_QNAME
public static final SequenceType OPTIONAL_QNAME
A type that allows a single optional xs:QName
-
OPTIONAL_NOTATION
public static final SequenceType OPTIONAL_NOTATION
A type that allows a single optional xs:NOTATION
-
OPTIONAL_BASE64_BINARY
public static final SequenceType OPTIONAL_BASE64_BINARY
A type that allows a single optional xs:Base64Binary
-
OPTIONAL_HEX_BINARY
public static final SequenceType OPTIONAL_HEX_BINARY
A type that allows a single optional xs:hexBinary
-
OPTIONAL_NUMERIC
public static final SequenceType OPTIONAL_NUMERIC
A type that allows an optional numeric value
-
SINGLE_NUMERIC
public static final SequenceType SINGLE_NUMERIC
-
OPTIONAL_NODE
public static final SequenceType OPTIONAL_NODE
A type that allows zero or one nodes
-
SINGLE_NODE
public static final SequenceType SINGLE_NODE
A type that allows a single node
-
OPTIONAL_DOCUMENT_NODE
public static final SequenceType OPTIONAL_DOCUMENT_NODE
A type that allows a single document node
-
NODE_SEQUENCE
public static final SequenceType NODE_SEQUENCE
A type that allows a sequence of zero or more nodes
-
STRING_SEQUENCE
public static final SequenceType STRING_SEQUENCE
A type that allows a sequence of zero or more string values
-
SINGLE_FUNCTION
public static final SequenceType SINGLE_FUNCTION
A type that allows a single function item
-
OPTIONAL_FUNCTION_ITEM
public static final SequenceType OPTIONAL_FUNCTION_ITEM
A type that allows a sequence of zero or one function items
-
FUNCTION_ITEM_SEQUENCE
public static final SequenceType FUNCTION_ITEM_SEQUENCE
A type that allows a sequence of zero or mode function items
-
EMPTY_SEQUENCE
public static final SequenceType EMPTY_SEQUENCE
A type that only permits the empty sequence
-
NON_EMPTY_SEQUENCE
public static final SequenceType NON_EMPTY_SEQUENCE
A type that only permits a non-empty sequence
-
VOID
public static final SequenceType VOID
A type that has no instances
-
-
Constructor Detail
-
SequenceType
public SequenceType(ItemType primaryType, int cardinality)
Construct an instance of SequenceType.- Parameters:
primaryType- The item typecardinality- The required cardinality
-
-
Method Detail
-
makeSequenceType
public static SequenceType makeSequenceType(ItemType primaryType, int cardinality)
Construct an instance of SequenceType. This is a factory method: it maintains a pool of SequenceType objects to reduce the amount of object creation.- Parameters:
primaryType- The item typecardinality- The required cardinality. This must be one of the constantsStaticProperty.EXACTLY_ONE,StaticProperty.ALLOWS_ONE_OR_MORE, etc- Returns:
- the SequenceType (either a newly created object, or an existing one from the cache)
-
getPrimaryType
public ItemType getPrimaryType()
Get the "primary" part of this required type. E.g. for type element(*, xs:date) the "primary type" is element()- Returns:
- The item type code of the primary type
-
getCardinality
public int getCardinality()
Get the cardinality component of this SequenceType. This is one of the constantsStaticProperty.EXACTLY_ONE,StaticProperty.ALLOWS_ONE_OR_MORE, etc- Returns:
- the required cardinality
- See Also:
Cardinality
-
matches
public boolean matches(Sequence value, TypeHierarchy th) throws XPathException
Determine whether a given value is a valid instance of this SequenceType- Parameters:
value- the value to be testedth- the type hierarchy cache- Returns:
- true if the value is a valid instance of this type
- Throws:
XPathException- if a dynamic error occurs while evaluating the Sequence (this won't happen if the sequence is grounded)
-
explainMismatch
public java.util.Optional<java.lang.String> explainMismatch(GroundedValue value, 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.- Parameters:
value- the value which has been found not to match this sequence typeth- the TypeHierarchy cache
-
toString
public java.lang.String toString()
Return a string representation of this SequenceType- Overrides:
toStringin classjava.lang.Object- Returns:
- the string representation as an instance of the XPath SequenceType construct
-
toExportString
public java.lang.String toExportString()
Return a string representation of this SequenceType suitable for use in stylesheet export files. This differs from the result of toString() in that it will not contain any references to anonymous types. Note that it may also use the Saxon extended syntax for union types and tuple types.- Returns:
- the string representation as an instance of the XPath SequenceType construct
-
toAlphaCode
public java.lang.String toAlphaCode()
-
hashCode
public int hashCode()
Returns a hash code value for the object.- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
Indicates whether some other object is "equal to" this one.- Overrides:
equalsin classjava.lang.Object
-
isSameType
public boolean isSameType(SequenceType other, TypeHierarchy th)
-
-