Class ObjectValue<T>
- All Implemented Interfaces:
GroundedValue
,Item
,Sequence
,AnyExternalObject
- Direct Known Subclasses:
Bindery.FailureValue
,MemoFunction.NodeSurrogate
,Tuple
Until Saxon 9.4, ObjectValue was a subclass of AtomicValue, and external Java objects were considered to be atomic. From 9.5, this has been changed so that an ObjectValue is another kind of Item: a fourth kind, at the same level as nodes, atomic values, and function items.
In the same way as ObjectValue is a wrapper around a Java instance object, the type of the value is a wrapper around the corresponding Java class. These types have subtype-supertype relationships that correspond to the Java class hierarchy. The top type in this branch of the class hierarchy, which wraps the Java class "Object", has item() as its superclass. These types can be referred to in the SequenceType syntax using QNames of the form jt:full.package.name.ClassName, where the conventional prefix jt maps to the namespace URI http://saxon.sf.net/java-type.
An ObjectValue is no longer permitted to wrap a Java null. An empty sequence should be used in this situation.
The effective boolean value of a wrapped Java object, like that of a node, is always true.
Atomizing a wrapped Java object, or applying the fn:string()
function, returns
an xs:string
whose value is the result of calling toString()
on the wrapped
Java object.
-
Constructor Summary
ConstructorsConstructorDescriptionObjectValue
(T object) ConstructorObjectValue
(T object, Class<? extends T> theInterface) -
Method Summary
Modifier and TypeMethodDescriptionatomize()
Atomize the item.static String
displayTypeName
(Object value) Display the type name for use in error messagesboolean
Get the effective boolean value of the valueboolean
Determine if two ObjectValues are equalgetGenre()
Get the genre of this itemDetermine the data type of the items in the expression, if possibleGet the encapsulated objectGet the value of the item as a string.Get the encapsulated object.int
hashCode()
Provide a short string showing the contents of the item, suitable for use in error messagesMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.sf.saxon.om.GroundedValue
asIterable, concatenate, containsNode, materialize
Methods inherited from interface net.sf.saxon.om.Item
getLength, getStringValue, head, isStreamed, itemAt, iterate, reduce, subsequence
Methods inherited from interface net.sf.saxon.om.Sequence
makeRepeatable
-
Constructor Details
-
Method Details
-
getInterface
-
getGenre
Get the genre of this item -
getUnicodeStringValue
Get the value of the item as a string. For nodes, this is the string value of the node as defined in the XPath 2.0 data model, except that all nodes are treated as being untyped: it is not an error to get the string value of a node with a complex type. For atomic values, the method returns the result of casting the atomic value to a string.- Specified by:
getUnicodeStringValue
in interfaceGroundedValue
- Specified by:
getUnicodeStringValue
in interfaceItem
- Returns:
- the string value of the item
- Throws:
UnsupportedOperationException
- if the item is a function item (an unchecked exception is used here to avoid introducing exception handling to a large number of paths where it is not needed)- Since:
- 8.4
-
atomize
Atomize the item. -
getItemType
Determine the data type of the items in the expression, if possible- Specified by:
getItemType
in interfaceAnyExternalObject
- Parameters:
th
- The TypeHierarchy.- Returns:
- for the default implementation: AnyItemType (not known)
-
displayTypeName
Display the type name for use in error messages- Parameters:
value
- a Java object- Returns:
- the type name. This will be in the form "java-type:" followed by the full class name of the wrapped Java object.
-
effectiveBooleanValue
public boolean effectiveBooleanValue()Get the effective boolean value of the value- Specified by:
effectiveBooleanValue
in interfaceGroundedValue
- Returns:
- true (always)
-
getObject
Get the encapsulated object- Returns:
- the Java object that this external object wraps
-
getWrappedObject
Get the encapsulated object. This version of the method does not use generics, enabling it to work the same way in Java and C#.- Specified by:
getWrappedObject
in interfaceAnyExternalObject
- Returns:
- the Java object that this external object wraps
-
equals
Determine if two ObjectValues are equal -
hashCode
public int hashCode() -
toShortString
Description copied from interface:Item
Provide a short string showing the contents of the item, suitable for use in error messages- Specified by:
toShortString
in interfaceGroundedValue
- Specified by:
toShortString
in interfaceItem
- Returns:
- a depiction of the item suitable for use in error messages
-