net.sf.saxon.value

Class AnyURIValue

Implemented Interfaces:
ConversionResult, GroundedValue, Item, PullEvent, Serializable, SequenceIterable, Serializable, ValueRepresentation

public final class AnyURIValue
extends StringValue

An XPath value of type xs:anyURI.

This is implemented as a subtype of StringValue even though xs:anyURI is not a subtype of xs:string in the XPath type hierarchy. This enables type promotion from URI to String to happen automatically in most cases where it is appropriate.

This implementation of xs:anyURI allows any string to be contained in the value space. It is possible to validate that the string is a "valid URI" in the sense of XML Schema Part 2 (which refers to the XLink specification and to RFC 2396); however, this validation is optional, and is not carried out by default. In particular, there is no constraint that namespace URIs, collation URIs, and the like should be valid URIs. However, casting from strings to xs:anyURI does invoke validation.

Nested Class Summary

Nested classes/interfaces inherited from class net.sf.saxon.value.StringValue

StringValue.CharacterIterator

Field Summary

static AnyURIValue
EMPTY_URI

Fields inherited from class net.sf.saxon.value.StringValue

EMPTY_STRING, FALSE, SINGLE_SPACE, TRUE, length, value

Fields inherited from class net.sf.saxon.value.AtomicValue

typeLabel

Fields inherited from class net.sf.saxon.value.Value

EMPTY_CLASS_ARRAY, INDETERMINATE_ORDERING

Fields inherited from interface net.sf.saxon.om.ValueRepresentation

EMPTY_VALUE_ARRAY

Constructor Summary

AnyURIValue(CharSequence value)
Constructor
AnyURIValue(CharSequence value, AtomicType type)
Constructor for a user-defined subtype of anyURI

Method Summary

ConversionResult
convertPrimitive(BuiltInAtomicType requiredType, boolean validate, XPathContext context)
Convert to target data type
Object
convertToJava(Class target, XPathContext context)
Convert to Java object (for passing to external functions)
AtomicValue
copyAsSubType(AtomicType typeLabel)
Create a copy of this atomic value, with a different type label
BuiltInAtomicType
getPrimitiveType()
static boolean
isValidURI(CharSequence value)
Check whether a string consititutes a valid URI

Methods inherited from class net.sf.saxon.value.StringValue

codepointEquals, containsSurrogatePairs, contract, convertPrimitive, convertStringToAtomicType, convertStringToBuiltInType, convertToJava, copyAsSubType, diagnosticDisplay, effectiveBooleanValue, equals, expand, expand, getPrimitiveType, getSchemaComparable, getStringLength, getStringLength, getStringValue, getStringValueCS, getXPathComparable, isZeroLength, iterateCharacters, makeRestrictedString, makeStringValue, setStringValueCS, toString, validate

Methods inherited from class net.sf.saxon.value.AtomicValue

asAtomic, checkPermittedContents, convert, convert, convertPrimitive, copyAsSubType, effectiveBooleanValue, equals, getCardinality, getComponent, getItemType, getLength, getPrimitiveType, getSchemaComparable, getStringValue, getStringValueCS, getTypeLabel, getTypedValue, getXPathComparable, isNaN, itemAt, iterate, process, setTypeLabel, subsequence, toString

Methods inherited from class net.sf.saxon.value.Value

asItem, asItem, asIterator, asValue, checkPermittedContents, convertJavaObjectToXPath, convertToJava, convertToJava, effectiveBooleanValue, equals, fromItem, getCanonicalLexicalRepresentation, getCardinality, getItemType, getIterator, getLength, getSchemaComparable, getStringValue, getStringValueCS, itemAt, iterate, iterate, makeQNameValue, process, reduce, stringToNumber, toString

Field Details

EMPTY_URI

public static final AnyURIValue EMPTY_URI

Constructor Details

AnyURIValue

public AnyURIValue(CharSequence value)
Constructor
Parameters:
value - the String value. Null is taken as equivalent to "". This constructor does not check that the value is a valid anyURI instance.

AnyURIValue

public AnyURIValue(CharSequence value,
                   AtomicType type)
Constructor for a user-defined subtype of anyURI
Parameters:
value - the String value. Null is taken as equivalent to "".
type - a user-defined subtype of anyURI. It is the caller's responsibility to ensure that this is actually a subtype of anyURI, and that the value conforms to the definition of this type.

Method Details

convertPrimitive

public ConversionResult convertPrimitive(BuiltInAtomicType requiredType,
                                         boolean validate,
                                         XPathContext context)
Convert to target data type
Overrides:
convertPrimitive in interface StringValue
Parameters:
requiredType - integer code representing the item type required
context - the XPath dynamic evaluation context
Returns:
the result of the conversion, or an ErrorValue

convertToJava

public Object convertToJava(Class target,
                            XPathContext context)
            throws XPathException
Convert to Java object (for passing to external functions)
Overrides:
convertToJava in interface StringValue
Parameters:
target - the Java class to which conversion is required
Returns:
the result of the conversion
Throws:
XPathException - if conversion to this target type is not possible

copyAsSubType

public AtomicValue copyAsSubType(AtomicType typeLabel)
Create a copy of this atomic value, with a different type label
Overrides:
copyAsSubType in interface StringValue
Parameters:
typeLabel - the type label of the new copy. The caller is responsible for checking that the value actually conforms to this type.

getPrimitiveType

public BuiltInAtomicType getPrimitiveType()
Overrides:
getPrimitiveType in interface StringValue

isValidURI

public static boolean isValidURI(CharSequence value)
Check whether a string consititutes a valid URI
Parameters:
value - the string to be tested
Returns:
true if the string is a valid URI