net.sf.saxon.type
Class ListType

java.lang.Object
  |
  +--net.sf.saxon.type.SchemaType
        |
        +--net.sf.saxon.type.SimpleType
              |
              +--net.sf.saxon.type.ListType
All Implemented Interfaces:
MappingFunction, java.io.Serializable, javax.xml.transform.SourceLocator, TypeInfo

public class ListType
extends SimpleType
implements MappingFunction

Represents a SimpleType that is a list of a given SimpleType, known as its itemType. A ListType may be a restriction of another ListType; the itemType must either be an AtomicType or a UnionType whose members are not list types.

In the non-schema-aware product this class is used to implement the built-in list types NMTOKENS, ENTITIES, IDREFS. In the schema-aware product it is also used to support user-defined list types.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class net.sf.saxon.type.SchemaType
DERIVATION_EXTENSION, DERIVATION_LIST, DERIVATION_RESTRICTION, DERIVATION_UNION, DERIVE_BY_SUBSTITUTION, finalProhibitions, INVALID, UNVALIDATED, VALIDATED, VALIDATING, validationPhase
 
Constructor Summary
ListType(NamePool pool)
          Create a new ListType.
 
Method Summary
 java.lang.String applyWhitespaceNormalization(java.lang.String value)
          Apply the whitespace normalization rules for this simple type
 SimpleType getItemType()
          Returns the simpleType of the items in this ListType.
 SequenceIterator getTypedValue(java.lang.CharSequence value, NamespaceResolver resolver)
          Get the typed value of a given input string.
 boolean isDerivedFrom(java.lang.String typeNamespaceArg, java.lang.String typeNameArg, int derivationMethod)
          This method returns true if there is a derivation between the reference type definition, that is the TypeInfo on which the method is being called, and the other type definition, that is the one passed as parameters.
 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
 java.lang.Object map(Item item, XPathContext context, java.lang.Object info)
          The typed value of a list-valued node is obtained by tokenizing the string value and applying a mapping function to the sequence of tokens.
 int relationshipTo(SchemaType other)
          Determine the relationship of this schema type to another schema type.
 void setItemType(SimpleType type)
          Sets the itemType for this ListType (the type of item that instances of this list type contain).
 void validateContent(java.lang.CharSequence value, NamespaceResolver nsResolver)
          Check whether a given input string is valid according to this SimpleType
 
Methods inherited from class net.sf.saxon.type.SimpleType
applyWhitespaceNormalization, getBuiltInBaseType, getFacet, getFacetCollection, getFacets, getFacets, getTypedValue, getWhitespaceAction, isNamespaceSensitive, isSimpleType, isTypeDerivationOK, isUnionType, iterateMemberTypes, setFacetCollection, validate
 
Methods inherited from class net.sf.saxon.type.SchemaType
allowsDerivation, checkDerivation, containingDeclarationIsElement, getBaseType, getBaseTypeFingerprint, getBlock, getColumnNumber, getContainingDeclarationName, getDerivationMethod, getDescription, getDisplayName, getFingerprint, getLineNumber, getLocalName, getNamePool, getPublicId, getSystemId, getTypeName, getTypeNamespace, isComplexType, isSameType, setBaseType, setBaseTypeFingerprint, setContainingDeclaration, setDerivationMethod, setDerivationMethodName, setFinalProhibitions, setFingerprint, setLineNumber, setLocalName, setLocator, setNamePool, setSystemId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ListType

public ListType(NamePool pool)
Create a new ListType.

Method Detail

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

Overrides:
isListType in class SimpleType
Returns:
true if this is a list type

getItemType

public SimpleType getItemType()
Returns the simpleType of the items in this ListType.

Returns:
the simpleType of the items in this ListType.

isDerivedFrom

public boolean isDerivedFrom(java.lang.String typeNamespaceArg,
                             java.lang.String typeNameArg,
                             int derivationMethod)
This method returns true if there is a derivation between the reference type definition, that is the TypeInfo on which the method is being called, and the other type definition, that is the one passed as parameters. This method implements the DOM Level 3 TypeInfo interface.

Specified by:
isDerivedFrom in interface TypeInfo
Overrides:
isDerivedFrom in class SchemaType
Parameters:
typeNamespaceArg - the namespace of the "other" type
typeNameArg - the local name of the "other" type
derivationMethod - the derivation method: zero or more of TypeInfo.DERIVATION_RESTRICTION, TypeInfo.DERIVATION_EXTENSION, TypeInfo.DERIVATION_LIST, or TypeInfo.DERIVATION_UNION. Zero means derived by any possible route.

setItemType

public void setItemType(SimpleType type)
                 throws SchemaException
Sets the itemType for this ListType (the type of item that instances of this list type contain). For internal use only.

Parameters:
type - the SimpleType for this ListType.
SchemaException

relationshipTo

public int relationshipTo(SchemaType other)
Determine the relationship of this schema type to another schema type.

Specified by:
relationshipTo in class SchemaType
Parameters:
other - the other schema type
Returns:
Type.SAME_TYPE if the types are the same; Type.SUBSUMES if the first type subsumes the second (that is, all instances of the second type are also instances of the first); Type.SUBSUMED_BY if the second type subsumes the first; Type.OVERLAPS if the two types overlap (have a non-empty intersection); Type.DISJOINT if the two types are disjoint (have an empty intersection)

applyWhitespaceNormalization

public java.lang.String applyWhitespaceNormalization(java.lang.String value)
Apply the whitespace normalization rules for this simple type

Parameters:
value - the string before whitespace normalization
Returns:
the string after whitespace normalization

validateContent

public void validateContent(java.lang.CharSequence value,
                            NamespaceResolver nsResolver)
                     throws ValidationException
Check whether a given input string is valid according to this SimpleType

Specified by:
validateContent in class 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.
Throws:
ValidationException - if the content is invalid
java.lang.UnsupportedOperationException - if the type is namespace-sensitive and no namespace resolver is supplied

getTypedValue

public SequenceIterator getTypedValue(java.lang.CharSequence value,
                                      NamespaceResolver resolver)
                               throws ValidationException
Get the typed value of a given input string. This method assumes that the input value is valid according to this SimpleType

Specified by:
getTypedValue in class SimpleType
Parameters:
value - the string whose typed value is required
resolver -
Returns:
an iterator over the atomic sequence comprising the typed value. The objects returned by this SequenceIterator will all be of type AtomicValue
ValidationException

map

public java.lang.Object map(Item item,
                            XPathContext context,
                            java.lang.Object info)
                     throws XPathException
The typed value of a list-valued node is obtained by tokenizing the string value and applying a mapping function to the sequence of tokens. This method implements the mapping function. It is for internal use only. For details see MappingFunction

Specified by:
map in interface MappingFunction
Parameters:
item - The item to be mapped. If context is supplied, this must be the same as context.currentItem().
context - The processing context. This is supplied only for mapping constructs that set the context node, position, and size. Otherwise it is null.
info - Arbitrary information supplied by the creator of the MappingIterator. It must be read-only and immutable for the duration of the iteration.
Returns:
either (a) a SequenceIterator over the sequence of items that the supplied input item maps to, or (b) an Item if it maps to a single item, or (c) null if it maps to an empty sequence.
XPathException