Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
net.sf.saxon.value.Value
net.sf.saxon.value.AtomicValue
Field Summary | |
protected AtomicType |
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 |
Method Summary | |
AtomicValue |
|
void |
|
ConversionResult |
|
AtomicValue |
|
protected abstract ConversionResult |
|
abstract AtomicValue |
|
boolean |
|
abstract boolean |
|
int |
|
AtomicValue |
|
ItemType |
|
int |
|
abstract BuiltInAtomicType |
|
abstract Comparable |
|
abstract String |
|
CharSequence |
|
AtomicType |
|
SequenceIterator |
|
abstract Object |
|
boolean |
|
Item |
|
SequenceIterator |
|
void |
|
void |
|
GroundedValue |
|
String |
|
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 |
public 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. 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.
- Specified by:
- asAtomic in interface ConversionResult
- Returns:
- the atomic value that results from the conversion if the conversion was successful
public void checkPermittedContents(SchemaType parentType, StaticContext env, boolean whole) throws XPathException
Check statically that the results of the expression are capable of constructing the content of a given schema type.
- Overrides:
- checkPermittedContents in interface Value
- Parameters:
parentType
- The schema typeenv
- the static contextwhole
- true if this atomic value accounts for the entire content of the containing node
- Throws:
XPathException
- if the expression doesn't match the required content type
public final ConversionResult convert(AtomicType targetType, boolean validate, XPathContext context)
Convert the value to a given type. The result of the conversion will be an atomic value of the required type. This method works where the target type is a built-in atomic type and also where it is a user-defined atomic type.
- Parameters:
targetType
- the type to which the value is to be convertedvalidate
- true if validation is required, false if the caller already knows that the value is validcontext
- 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.
public final AtomicValue convert(AtomicType schemaType, XPathContext context) throws XPathException
Convert the value to a given type. The result of the conversion will be an atomic value of the required type. This method works only where the target type is a built-in type.
- Parameters:
schemaType
- the required atomic typecontext
- 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
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.
- 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.
public abstract AtomicValue copyAsSubType(AtomicType typeLabel)
Create a copy of this atomic value, with a different type label
- 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
public boolean effectiveBooleanValue() throws XPathException
Get the effective boolean value of the value
- Overrides:
- effectiveBooleanValue in interface Value
- Returns:
- true, unless the value is boolean false, numeric zero, or zero-length string
public 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. When the other operand is not an atomic value, the result is undefined (may be false, may be an exception). When the other operand is an atomic value that cannot be compared with this one, the method must throw a ClassCastException. 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
public final int getCardinality()
Determine the static cardinality
- Overrides:
- getCardinality in interface Value
- Returns:
- code identifying the cardinality
- See Also:
Cardinality
public AtomicValue getComponent(int component) throws XPathException
Method to extract components of a value. Implemented by some subclasses, but defined at this level for convenience
- Parameters:
component
- identifies the required component, as a constant defined in classComponent
, for exampleComponent.HOURS
- Returns:
- the value of the requested component of this value
public ItemType getItemType(TypeHierarchy th)
Determine the data type of the items in the expression, if possible
- Overrides:
- getItemType in interface 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)
public final int getLength()
Get the length of the sequence
- Returns:
- always 1 for an atomic value
public abstract BuiltInAtomicType getPrimitiveType()
Determine the primitive type of the value. This delivers the same answer as getItemType().getPrimitiveItemType(). The primitive types are the 19 primitive types of XML Schema, plus xs:integer, xs:dayTimeDuration and xs:yearMonthDuration, and xs:untypedAtomic. For external objects, the result is xs:anyAtomicType.
- Returns:
- the primitive type
public abstract Comparable getSchemaComparable()
Get a Comparable value that implements the XML Schema ordering comparison semantics for this value. An implementation must be provided for all atomic types. In the case of data types that are partially ordered, the returned Comparable extends the standard semantics of the compareTo() method by returning the valueValue.INDETERMINATE_ORDERING
when there is no defined order relationship between two given values. This value is also returned when two values of different types are compared.
- Overrides:
- getSchemaComparable in interface Value
- Returns:
- a Comparable that follows XML Schema comparison rules
public abstract String getStringValue()
Convert the value to a string, using the serialization rules. For atomic values this is the same as a cast; for sequence values it gives a space-separated list. This method is refined for AtomicValues so that it never throws an Exception.
- Specified by:
- getStringValue in interface Item
- getStringValue in interface ValueRepresentation
- Overrides:
- getStringValue in interface Value
public CharSequence getStringValueCS()
Get the value of the item as a CharSequence. This is in some cases more efficient than the version of the method that returns a String.
- Specified by:
- getStringValueCS in interface Item
- getStringValueCS in interface ValueRepresentation
- Overrides:
- getStringValueCS in interface Value
public AtomicType getTypeLabel()
Determine the data type of the value. This delivers the same answer asgetItemType(TypeHierarchy)
, except in the case of external objects (instances ofObjectValue
, where the method may deliver a less specific type.
- Returns:
- for the default implementation: AnyItemType (not known)
public final SequenceIterator getTypedValue()
Get the typed value of this item
- Specified by:
- getTypedValue in interface Item
- Returns:
- the typed value of the expression (which is this value)
public abstract Object getXPathComparable(boolean ordered, StringCollator collator, XPathContext context) throws NoDynamicContextException
Get an object value that implements the XPath equality and ordering comparison semantics for this value. If the ordered parameter is set to true, the result will be a Comparable and will support a compareTo() method with the semantics of the XPath lt/gt operator, provided that the other operand is also obtained using the getXPathComparable() method. In all cases the result will support equals() and hashCode() methods that support the semantics of the XPath eq operator, again provided that the other operand is also obtained using the getXPathComparable() method. A context argument is supplied for use in cases where the comparison semantics are context-sensitive, for example where they depend on the implicit timezone or the default collation.
- 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 stringscontext
- 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
public boolean isNaN()
Test whether the value is the double/float value NaN
- Returns:
- true if the value is float NaN or double NaN; otherwise false
public final Item itemAt(int n)
Get the n'th item in the sequence (starting from 0). This is defined for all Values, but its real benefits come for a sequence Value stored extensionally (or for a MemoClosure, once all the values have been read)
- Specified by:
- itemAt in interface GroundedValue
- 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.
public final SequenceIterator iterate()
Iterate over the (single) item in the sequence
- Returns:
- a SequenceIterator that iterates over the single item in this value
public void process(XPathContext context) throws XPathException
Process the instruction, without returning any tail calls
- Parameters:
context
- The dynamic context, giving access to the current node, the current variables, etc.
public void setTypeLabel(AtomicType type)
Set the type label on this atomic value. Note that this modifies the value, so it must only called if the caller is confident that the value is not shared. In other cases, usecopyAsSubType(AtomicType)
- Parameters:
type
- the type label to be set
public GroundedValue subsequence(int start, int length)
Get a subsequence of the value
- Specified by:
- subsequence in interface GroundedValue
- 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 returnedlength
- 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