net.sf.saxon.value
public abstract class AtomicValue extends Value implements Item, GroundedValue, ConversionResult
Field Summary | |
---|---|
protected AtomicType | typeLabel |
Method Summary | |
---|---|
AtomicValue | asAtomic()
Calling this method on a ConversionResult returns the AtomicValue that results
from the conversion if the conversion was successful, and throws a ValidationException
explaining the conversion error otherwise.
|
void | checkPermittedContents(SchemaType parentType, StaticContext env, boolean whole)
Check statically that the results of the expression are capable of constructing the content
of a given schema type.
|
AtomicValue | convert(AtomicType schemaType, XPathContext context)
Convert the value to a given type. |
ConversionResult | convert(AtomicType targetType, boolean validate, XPathContext context)
Convert the value to a given type. |
protected abstract ConversionResult | convertPrimitive(BuiltInAtomicType requiredType, boolean validate, XPathContext context)
Convert a value to either (a) another primitive type, or (b) another built-in type derived
from the current primitive type, with control over how validation is
handled.
|
abstract AtomicValue | copyAsSubType(AtomicType typeLabel)
Create a copy of this atomic value, with a different type label
|
boolean | effectiveBooleanValue()
Get the effective boolean value of the value
|
abstract boolean | equals(Object o)
The equals() methods on atomic values is defined to follow the semantics of eq when applied
to two atomic values. |
int | getCardinality()
Determine the static cardinality
|
AtomicValue | getComponent(int component)
Method to extract components of a value. |
ItemType | getItemType(TypeHierarchy th)
Determine the data type of the items in the expression, if possible
|
int | getLength()
Get the length of the sequence
|
protected abstract CharSequence | getPrimitiveStringValue()
Convert the value to a string, using the serialization rules for the primitive type.
|
abstract BuiltInAtomicType | getPrimitiveType()
Determine the primitive type of the value. |
abstract Comparable | getSchemaComparable()
Get a Comparable value that implements the XML Schema ordering comparison semantics for this value.
|
String | getStringValue()
Convert the value to a string, using the serialization rules.
|
CharSequence | getStringValueCS()
Get the value of the item as a CharSequence. |
SequenceIterator | getTypedValue()
Get the typed value of this item
|
AtomicType | getTypeLabel()
Determine the data type of the value. |
abstract Object | getXPathComparable(boolean ordered, StringCollator collator, XPathContext context)
Get an object value that implements the XPath equality and ordering comparison semantics for this value.
|
boolean | isIdentical(Value v)
Determine whether two atomic values are identical, as determined by XML Schema rules. |
boolean | isNaN()
Test whether the value is the double/float value NaN |
Item | itemAt(int n)
Get the n'th item in the sequence (starting from 0). |
SequenceIterator | iterate()
Iterate over the (single) item in the sequence
|
void | process(XPathContext context)
Process the instruction, without returning any tail calls
|
void | setTypeLabel(AtomicType type)
Set the type label on this atomic value. |
GroundedValue | subsequence(int start, int length)
Get a subsequence of the value
|
String | toString()
Get string value. |
Use this method if you are calling a conversion method that returns a ConversionResult, and if you want to throw an exception if the conversion fails.
Returns: the atomic value that results from the conversion if the conversion was successful
Parameters: parentType The schema type env the static context whole true if this atomic value accounts for the entire content of the containing node
Throws: net.sf.saxon.trans.XPathException if the expression doesn't match the required content type
Parameters: schemaType the required atomic type. This must not be a namespace-sensitive type such as QName or NOTATION context the XPath dynamic context
Returns: the result of the conversion, if conversion was possible. This will always be an instance of the class corresponding to the type of value requested
Throws: XPathException if conversion is not allowed for this required type, or if the particular value cannot be converted
Parameters: targetType the type to which the value is to be converted. This must not be a namespace-sensitive type such as QName or NOTATION. validate true if validation is required, false if the caller already knows that the value is valid context provides access to conversion context
Returns: the value after conversion if successful; or a ValidationFailure if conversion failed. The caller must check for this condition. Validation may fail even if validation was not requested.
Parameters: requiredType the required atomic type. This must either be a primitive type, or a built-in type derived from the same primitive type as this atomic value. validate true if validation is required. If set to false, the caller guarantees that the value is valid for the target data type, and that further validation is therefore not required. Note that a validation failure may be reported even if validation was not requested. context The conversion context to be used. This is required at present only when converting to xs:Name or similar types: it determines the NameChecker to be used.
Returns: the result of the conversion, if successful. If unsuccessful, the value returned will be a ValidationFailure. The caller must check for this condition. No exception is thrown, instead the exception information will be encapsulated within the ValidationFailure.
Parameters: typeLabel the type label of the new copy. The caller is responsible for checking that the value actually conforms to this type.
Returns: the copied value
Returns: true, unless the value is boolean false, numeric zero, or zero-length string
The hashCode() method is consistent with equals().
Parameters: o the other value
Returns: true if the other operand is an atomic value and the two values are equal as defined by the XPath eq operator
Returns: code identifying the cardinality
See Also: Cardinality
Parameters: component identifies the required component, as a constant defined in class Component, for example HOURS
Returns: the value of the requested component of this value
Parameters: th The TypeHierarchy. Can be null if the target is an AtomicValue, except in the case where it is an external ObjectValue.
Returns: for the default implementation: AnyItemType (not known)
Returns: always 1 for an atomic value
Returns: the value converted to a string according to the rules for the primitive type
Returns: the primitive type
In the case of data types that are partially ordered, the returned Comparable extends the standard semantics of the compareTo() method by returning the value AtomicValue when there is no defined order relationship between two given values. This value is also returned when two values of different types are compared.
Returns: a Comparable that follows XML Schema comparison rules
Returns: the typed value of the expression (which is this value)
Returns: for the default implementation: AnyItemType (not known)
Parameters: ordered true if an ordered comparison is required. In this case the result is null if the type is unordered; in other cases the returned value will be a Comparable. collator the collation to be used when comparing strings context the XPath dynamic evaluation context, used in cases where the comparison is context sensitive
Returns: an Object whose equals() and hashCode() methods implement the XPath comparison semantics with respect to this atomic value. If ordered is specified, the result will either be null if no ordering is defined, or will be a Comparable
Throws: NoDynamicContextException if the comparison depends on dynamic context information that is not available, for example implicit timezone
Note that even this check ignores the type annotation of the value. The integer 3 and the short 3 are considered identical, even though they are not fully interchangeable. "Identical" means the same point in the value space, regardless of type annotation.
NaN is identical to itself.
Parameters: v the other value to be compared with this one
Returns: true if the two values are identical, false otherwise.
Returns: true if the value is float NaN or double NaN; otherwise false
Parameters: n position of the required item, counting from zero.
Returns: the n'th item in the sequence, where the first item in the sequence is numbered zero. If n is negative or >= the length of the sequence, returns null.
Returns: a SequenceIterator that iterates over the single item in this value
Parameters: context The dynamic context, giving access to the current node, the current variables, etc.
Parameters: type the type label to be set
Parameters: start the index of the first item to be included in the result, counting from zero. A negative value is taken as zero. If the value is beyond the end of the sequence, an empty sequence is returned length the number of items to be included in the result. Specify Integer.MAX_VALUE to get the subsequence up to the end of the base sequence. If the value is negative, an empty sequence is returned. If the value goes off the end of the sequence, the result returns items up to the end of the sequence
Returns: the required subsequence. If min is