Package com.saxonica.xqj
Class SaxonXQItemType
- java.lang.Object
-
- com.saxonica.xqj.SaxonXQItemType
-
- All Implemented Interfaces:
XQItemType,XQSequenceType
public class SaxonXQItemType extends java.lang.Object implements XQItemType
Saxon implementation of the XQJ XQItemType interface
-
-
Field Summary
-
Fields inherited from interface javax.xml.xquery.XQItemType
XQBASETYPE_ANYATOMICTYPE, XQBASETYPE_ANYSIMPLETYPE, XQBASETYPE_ANYTYPE, XQBASETYPE_ANYURI, XQBASETYPE_BASE64BINARY, XQBASETYPE_BOOLEAN, XQBASETYPE_BYTE, XQBASETYPE_DATE, XQBASETYPE_DATETIME, XQBASETYPE_DAYTIMEDURATION, XQBASETYPE_DECIMAL, XQBASETYPE_DOUBLE, XQBASETYPE_DURATION, XQBASETYPE_ENTITIES, XQBASETYPE_ENTITY, XQBASETYPE_FLOAT, XQBASETYPE_GDAY, XQBASETYPE_GMONTH, XQBASETYPE_GMONTHDAY, XQBASETYPE_GYEAR, XQBASETYPE_GYEARMONTH, XQBASETYPE_HEXBINARY, XQBASETYPE_ID, XQBASETYPE_IDREF, XQBASETYPE_IDREFS, XQBASETYPE_INT, XQBASETYPE_INTEGER, XQBASETYPE_LANGUAGE, XQBASETYPE_LONG, XQBASETYPE_NAME, XQBASETYPE_NCNAME, XQBASETYPE_NEGATIVE_INTEGER, XQBASETYPE_NMTOKEN, XQBASETYPE_NMTOKENS, XQBASETYPE_NONNEGATIVE_INTEGER, XQBASETYPE_NONPOSITIVE_INTEGER, XQBASETYPE_NORMALIZED_STRING, XQBASETYPE_NOTATION, XQBASETYPE_POSITIVE_INTEGER, XQBASETYPE_QNAME, XQBASETYPE_SHORT, XQBASETYPE_STRING, XQBASETYPE_TIME, XQBASETYPE_TOKEN, XQBASETYPE_UNSIGNED_BYTE, XQBASETYPE_UNSIGNED_INT, XQBASETYPE_UNSIGNED_LONG, XQBASETYPE_UNSIGNED_SHORT, XQBASETYPE_UNTYPED, XQBASETYPE_UNTYPEDATOMIC, XQBASETYPE_YEARMONTHDURATION, XQITEMKIND_ATOMIC, XQITEMKIND_ATTRIBUTE, XQITEMKIND_COMMENT, XQITEMKIND_DOCUMENT, XQITEMKIND_DOCUMENT_ELEMENT, XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT, XQITEMKIND_ELEMENT, XQITEMKIND_ITEM, XQITEMKIND_NODE, XQITEMKIND_PI, XQITEMKIND_SCHEMA_ATTRIBUTE, XQITEMKIND_SCHEMA_ELEMENT, XQITEMKIND_TEXT
-
Fields inherited from interface javax.xml.xquery.XQSequenceType
OCC_EMPTY, OCC_EXACTLY_ONE, OCC_ONE_OR_MORE, OCC_ZERO_OR_MORE, OCC_ZERO_OR_ONE
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedSaxonXQItemType(NodeInfo node)protectedSaxonXQItemType(ItemType itemType, Configuration config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)Compares the specified object with this item type for equality.intgetBaseType()Returns the base type of the item.intgetItemKind()Returns the kind of the item.intgetItemOccurrence()Returns the occurrence indicator for the item type.XQItemTypegetItemType()Returns the type of the item in the sequence type.javax.xml.namespace.QNamegetNodeName()Returns the name of the node in case the item kind is anXQITEMKIND_DOCUMENT_ELEMENT,XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT,XQITEMKIND_ELEMENT,XQITEMKIND_SCHEMA_ELEMENT,XQITEMKIND_ATTRIBUTE, orXQITEMKIND_SCHEMA_ATTRIBUTE.java.lang.StringgetPIName()Returns the name of the processing instruction type.java.net.URIgetSchemaURI()Returns the schema location URI of the schema that contains the item's element or type definition.javax.xml.namespace.QNamegetTypeName()Represents a type name (global or local).inthashCode()Returns a hash code consistent with the definition of the equals method.booleanisAnonymousType()Represents whether the item type is an anonymous type in the schema.booleanisElementNillable()Returns whether the element type is nillable or not.java.lang.StringtoString()Returns a human-readable implementation-defined string representation of the item type.
-
-
-
Constructor Detail
-
SaxonXQItemType
protected SaxonXQItemType(ItemType itemType, Configuration config)
-
SaxonXQItemType
protected SaxonXQItemType(NodeInfo node)
-
-
Method Detail
-
getBaseType
public int getBaseType() throws XQExceptionDescription copied from interface:XQItemTypeReturns the base type of the item. One of theXQBASETYPE_*constants.
XQJ defines a constant for each of the built-in schema types defined in XML Schema. For atomic types this is the closest matching built-in XML Schema type, for element and attributes the closest matching built-in XML Schema type this node is based on.- Specified by:
getBaseTypein interfaceXQItemType- Returns:
- int one of the
XQBASETYPE_*constants indicating the basic type of the item - Throws:
XQException- if the item kind is not one of:XQITEMKIND_DOCUMENT_ELEMENT,XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT,XQITEMKIND_ELEMENT,XQITEMKIND_SCHEMA_ELEMENT,XQITEMKIND_ATTRIBUTE,XQITEMKIND_SCHEMA_ATTRIBUTE, orXQITEMKIND_ATOMIC
-
getItemKind
public int getItemKind()
Description copied from interface:XQItemTypeReturns the kind of the item. One of theXQITEMKIND_*constants.- Specified by:
getItemKindin interfaceXQItemType- Returns:
- int one of the
XQITEMKIND_*constants indicating the basic kind of the item
-
getItemOccurrence
public int getItemOccurrence()
Description copied from interface:XQItemTypeReturns the occurrence indicator for the item type. This method will always return the valueXQSequenceType.OCC_EXACTLY_ONE.- Specified by:
getItemOccurrencein interfaceXQItemType- Specified by:
getItemOccurrencein interfaceXQSequenceType- Returns:
- int indicating the occurrence indicator
-
getNodeName
public javax.xml.namespace.QName getNodeName() throws XQExceptionDescription copied from interface:XQItemTypeReturns the name of the node in case the item kind is anXQITEMKIND_DOCUMENT_ELEMENT,XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT,XQITEMKIND_ELEMENT,XQITEMKIND_SCHEMA_ELEMENT,XQITEMKIND_ATTRIBUTE, orXQITEMKIND_SCHEMA_ATTRIBUTE. For example, in the case of a type forelement "foo"this will return theQName foo. For wildcard entries anullvalue will be returned.- Specified by:
getNodeNamein interfaceXQItemType- Returns:
QNamefor the name of the element, attribute, or document element node.nullif it is a wildcard- Throws:
XQException- if the item kind is not one of:XQITEMKIND_DOCUMENT_ELEMENT,XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT,XQITEMKIND_ELEMENT,XQITEMKIND_SCHEMA_ELEMENT,XQITEMKIND_ATTRIBUTE, orXQITEMKIND_SCHEMA_ATTRIBUTE
-
getPIName
public java.lang.String getPIName() throws XQExceptionDescription copied from interface:XQItemTypeReturns the name of the processing instruction type. As such the item kind of thisXQItemTypemust beXQITEMKIND_PI.- Specified by:
getPINamein interfaceXQItemType- Returns:
- the name of the processing instruction type.
nullif it is a wildcard - Throws:
XQException- if the item kind is notXQITEMKIND_PI
-
getSchemaURI
public java.net.URI getSchemaURI()
Description copied from interface:XQItemTypeReturns the schema location URI of the schema that contains the item's element or type definition. This method is implementation-definied and an implementation will return anullvalue if it does not support retrieving the schema location URI. If the item corresponds to a validated global element in a schema, the result will be the schema location URI to the XMLSchema containing the element definition. Otherwise if the item is a schema validated node, the result will be the schema location URI of the XMLSchema containing the type definition of that node. If the item is not schema validated, the result isnull- Specified by:
getSchemaURIin interfaceXQItemType- Returns:
URIrepresenting the schema location URI of the XMLSchema containing the global element definition or the type definition of the current item.nullin case the item is not schema validated or if the implementation does not support retrieving the schema URI.
-
toString
public java.lang.String toString()
Description copied from interface:XQItemTypeReturns a human-readable implementation-defined string representation of the item type.- Specified by:
toStringin interfaceXQItemType- Specified by:
toStringin interfaceXQSequenceType- Overrides:
toStringin classjava.lang.Object- Returns:
- String a string representation of the item type
-
getTypeName
public javax.xml.namespace.QName getTypeName() throws XQExceptionDescription copied from interface:XQItemTypeRepresents a type name (global or local). This can be used to represent specific type name such as, element foo of type hatsize. The schema type name is represented as a singleQName. If the return type is an anonymous type, the actualQNamevalue returned is implementation defined.- Specified by:
getTypeNamein interfaceXQItemType- Returns:
- the
QNameof the schema type in case of a user defined or anonoymous types. For a built-in type, returns a predefined type name as QName (e.g.xs:anyType,xs:decimal, etc). Cannot benull - Throws:
XQException- if the item kind is not one of:XQITEMKIND_DOCUMENT_ELEMENT,XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT,XQITEMKIND_ATOMIC,XQITEMKIND_ELEMENT,XQITEMKIND_SCHEMA_ELEMENT,XQITEMKIND_ATTRIBUTE, orXQITEMKIND_SCHEMA_ATTRIBUTE
-
isAnonymousType
public boolean isAnonymousType()
Description copied from interface:XQItemTypeRepresents whether the item type is an anonymous type in the schema.- Specified by:
isAnonymousTypein interfaceXQItemType- Returns:
trueif the item type is an anonymous type in the schema,falseotherwise
-
isElementNillable
public boolean isElementNillable()
Description copied from interface:XQItemTypeReturns whether the element type is nillable or not.- Specified by:
isElementNillablein interfaceXQItemType- Returns:
trueif the element type is nillable,falseotherwise
-
getItemType
public XQItemType getItemType()
Description copied from interface:XQSequenceTypeReturns the type of the item in the sequence type.- Specified by:
getItemTypein interfaceXQSequenceType- Returns:
XQItemTyperepresenting the item type in the sequence.nullis returned in case of an empty sequence.
-
equals
public boolean equals(java.lang.Object obj)
Description copied from interface:XQItemTypeCompares the specified object with this item type for equality. The result istrueonly if the argument is an item type object which represents the same XQuery item type.
In order to comply with the general contract ofequalsandhashCodeacross different implementations the following algorithm must be used. Returntrueif and only if both objects areXQItemTypeand:getItemKind()is equal- if
getBaseType()is supported for the item kind, it must be equal - if
getNodeName()is supported for the item kind, it must be equal getSchemaURI()is equal- if
getTypeName()is supported for the item kind, it must be equal isAnonymousType()is equalisElementNillable()is equal- if
getPIName()is supported for the item kind, it must be equal
- Specified by:
equalsin interfaceXQItemType- Specified by:
equalsin interfaceXQSequenceType- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- anXQItemTypeobject representing an XQuery item type- Returns:
trueif the input item type object represents the same XQuery item type,falseotherwise
-
hashCode
public int hashCode()
Description copied from interface:XQItemTypeReturns a hash code consistent with the definition of the equals method.
In order to comply with the general contract ofequalsandhashCodeacross different implementations the following algorithm must be used:hashCode = this.getItemKind(); if this.getSchemaURI != null hashCode = 31*hashCode + this.getSchemaURI().hashCode(); if this.getBaseType() is supported for the item kind hashCode = 31*hashCode + this.getbaseType(); if this.getNodeName () is supported for the item kind and this.getNodeName() != null hashCode = 31*hashCode + this.getNodeName().hashCode() if this.getTypeName () is supported for the item kind hashCode = 31*hashCode + this.getTypeName().hashCode(); if this.getPIName () is supported for the item kind and this.getPIName () != null hashCode = 31*hashCode + this.getPIName().hashCode();- Specified by:
hashCodein interfaceXQItemType- Specified by:
hashCodein interfaceXQSequenceType- Overrides:
hashCodein classjava.lang.Object- Returns:
- hash code for this item type
-
-