Package net.sf.saxon.value
Class ObjectValue
java.lang.Object
net.sf.saxon.value.Value
net.sf.saxon.value.AtomicValue
net.sf.saxon.value.ObjectValue
- All Implemented Interfaces:
Serializable
,Expression
,Item
,ValueRepresentation
- Direct Known Subclasses:
ValidationErrorValue
An XPath value that encapsulates a Java object. Such a value can only be obtained by
calling an extension function that returns it.
- See Also:
-
Field Summary
Fields inherited from class net.sf.saxon.value.Value
EMPTY_CLASS_ARRAY
Fields inherited from interface net.sf.saxon.expr.Expression
EVALUATE_METHOD, ITERATE_METHOD, PROCESS_METHOD
Fields inherited from interface net.sf.saxon.om.ValueRepresentation
EMPTY_VALUE_ARRAY
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor for use in subclassesObjectValue
(Object object) Constructor -
Method Summary
Modifier and TypeMethodDescriptionconvertPrimitive
(BuiltInAtomicType requiredType, boolean validate, XPathContext context) Convert to target data typeconvertToJava
(Class target, XPathContext context) Convert to Java object (for passing to external functions)boolean
effectiveBooleanValue
(XPathContext context) Get the effective boolean value of the valueboolean
Determine if two ObjectValues are equalDetermine the data type of the expressionGet the encapsulated objectGet the value as a Stringint
hashCode()
Return a hash code to support the equals() functionvoid
Set the value in this object valueMethods inherited from class net.sf.saxon.value.AtomicValue
checkPermittedContents, convert, convert, display, evaluateAsString, evaluateItem, getCardinality, getComponent, getImplementationMethod, getLength, getPrimitiveValue, getStringValueCS, getTypedValue, hasBuiltInType, iterate, process, toString
Methods inherited from class net.sf.saxon.value.Value
asItem, asIterator, asValue, convert, convertJavaObjectToXPath, getDependencies, getIterator, getParentExpression, getSpecialProperties, itemAt, iterateSubExpressions, makeQNameValue, optimize, promote, reduce, simplify, stringToNumber, typeCheck
-
Constructor Details
-
ObjectValue
public ObjectValue()Default constructor for use in subclasses -
ObjectValue
Constructor- Parameters:
object
- the object to be encapsulated
-
-
Method Details
-
setValue
Set the value in this object value -
convertPrimitive
public AtomicValue convertPrimitive(BuiltInAtomicType requiredType, boolean validate, XPathContext context) Convert to target data type- Specified by:
convertPrimitive
in classAtomicValue
- Parameters:
requiredType
- type code of the required atomic typevalidate
- 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 a date or time: it provides the implicit timezone.- Returns:
- the result of the conversion, if successful. If unsuccessful, the value returned will be a ValidationErrorValue. The caller must check for this condition. No exception is thrown, instead the exception will be encapsulated within the ValidationErrorValue.
-
getStringValue
Get the value as a String- Specified by:
getStringValue
in interfaceItem
- Specified by:
getStringValue
in interfaceValueRepresentation
- Specified by:
getStringValue
in classAtomicValue
- Returns:
- a String representation of the value
- See Also:
-
effectiveBooleanValue
Get the effective boolean value of the value- Specified by:
effectiveBooleanValue
in interfaceExpression
- Overrides:
effectiveBooleanValue
in classAtomicValue
- Parameters:
context
- the evaluation context (not used in this implementation)- Returns:
- true, unless the value is boolean false, numeric zero, or zero-length string
- Throws:
XPathException
- if any dynamic error occurs evaluating the expression
-
getItemType
Determine the data type of the expression- Specified by:
getItemType
in interfaceExpression
- Overrides:
getItemType
in classValue
- Parameters:
th
-- Returns:
- Type.OBJECT
-
getObject
Get the encapsulated object -
equals
Determine if two ObjectValues are equal- Overrides:
equals
in classValue
- Throws:
ClassCastException
- if they are not comparable
-
hashCode
public int hashCode()Description copied from class:Value
Return a hash code to support the equals() function -
convertToJava
Convert to Java object (for passing to external functions)- Overrides:
convertToJava
in classValue
- Throws:
XPathException
-