public class XmlValue
extends java.lang.Object
STRING
, DOUBLE
, and BOOLEAN
, as well as a constructor to make an XmlValue from XmlDocument
.
The XmlValue class provides several constructors, each of which maps a Java type or Berkeley DB XML class onto an appropriate XmlValue type. The following table lists the constructor parameter mappings.
This object is not thread-safe, and can only be safely used by one thread at a time in an application.
Modifier and Type | Field and Description |
---|---|
static int |
ANY_SIMPLE_TYPE |
static int |
ANY_URI |
static int |
ATTRIBUTE_NODE
Node type returned by
getNodeType() . |
static int |
BASE_64_BINARY |
static int |
BOOLEAN |
static int |
CDATA_SECTION_NODE
Node type returned by
getNodeType() . |
static int |
COMMENT_NODE
Node type returned by
getNodeType() . |
static int |
DATE |
static int |
DATE_TIME |
static int |
DAY_TIME_DURATION |
static int |
DECIMAL |
static int |
DOCUMENT_FRAGMENT_NODE
Node type returned by
getNodeType() . |
static int |
DOCUMENT_NODE
Node type returned by
getNodeType() . |
static int |
DOCUMENT_TYPE_NODE
Node type returned by
getNodeType() . |
static int |
DOUBLE |
static int |
DURATION |
static int |
ELEMENT_NODE
Node type returned by
getNodeType() . |
static int |
ENTITY_NODE
Node type returned by
getNodeType() . |
static int |
ENTITY_REFERENCE_NODE
Node type returned by
getNodeType() . |
static int |
FLOAT |
static int |
G_DAY |
static int |
G_MONTH |
static int |
G_MONTH_DAY |
static int |
G_YEAR |
static int |
G_YEAR_MONTH |
static int |
HEX_BINARY |
static int |
NODE |
static int |
NONE |
static int |
NOTATION |
static int |
NOTATION_NODE
Node type returned by
getNodeType() . |
static int |
PROCESSING_INSTRUCTION_NODE
Node type returned by
getNodeType() . |
static int |
QNAME |
static int |
STRING |
static int |
TEXT_NODE
Node type returned by
getNodeType() . |
static int |
TIME |
static int |
UNTYPED_ATOMIC |
static int |
YEAR_MONTH_DURATION |
Constructor and Description |
---|
XmlValue()
Public constructor.
|
XmlValue(boolean v)
Construct a value from a boolean.
|
XmlValue(double v)
Construct a value from a double.
|
XmlValue(int type,
byte[] dbt)
Construct a typed value from a byte array.
|
XmlValue(int type,
java.lang.String v)
Construct a typed value from a string.
|
XmlValue(java.lang.String v)
Construct a value from a string.
|
XmlValue(java.lang.String typeURI,
java.lang.String typeName,
java.lang.String v)
Construct a typed value, where the type is defined by a URI and name, from a string.
|
XmlValue(XmlDocument document)
Construct a value from a document.
|
XmlValue(XmlValue other)
Copy constructor.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
asBinary()
Returns the value as a byte array.
|
boolean |
asBoolean()
Returns the value as a
BOOLEAN . |
XmlDocument |
asDocument()
Returns the value as an
XmlDocument . |
XmlEventReader |
asEventReader()
Returns the value as an
XmlEventReader . |
double |
asNumber()
Returns the value as a
DOUBLE . |
java.lang.String |
asString()
Returns the value as a
STRING . |
boolean |
equals(XmlValue value)
Determines if two
XmlValue objects represent the same value. |
XmlResults |
getAttributes()
Returns returns a
XmlResults that contains all of the attributes
appearing on this node. |
XmlValue |
getFirstChild()
Returns current node's first child node.
|
XmlValue |
getLastChild()
Returns current node's last child node.
|
java.lang.String |
getLocalName()
Returns the node's local name.
|
java.lang.String |
getNamespaceURI()
Returns the URI used for the node's namespace.
|
XmlValue |
getNextSibling()
Returns the sibling node immediately following this node in the
document.
|
java.lang.String |
getNodeHandle()
Returns a String handle that can be used to directly reference
nodes within a document by using
XmlContainer.getNode(java.lang.String) |
java.lang.String |
getNodeName()
Returns the name of the node contained in this XmlValue.
|
short |
getNodeType()
Returns the short value for this node's node type (e.g.
|
java.lang.String |
getNodeValue()
Returns the node's value.
|
XmlValue |
getOwnerElement()
If the current node is an attribute node, returns the document element
node that contains this attribute node.
|
XmlValue |
getParentNode()
Returns current node's parent.
|
java.lang.String |
getPrefix()
Returns the prefix set for the node's namespace.
|
XmlValue |
getPreviousSibling()
Returns the sibling node immediately preceding this node in the
document.
|
XmlResults |
getResults()
Returns the
XmlResults that is associated with this XmlValue , or null if there is none. |
int |
getType()
|
java.lang.String |
getTypeName()
Returns the type name of the
XmlValue |
java.lang.String |
getTypeURI()
Returns the type URI of the
XmlValue |
boolean |
isBoolean()
|
boolean |
isNode()
|
boolean |
isNull()
|
boolean |
isNumber()
|
boolean |
isString()
|
boolean |
isType(int type)
Indicates whether the
XmlValue is of the specified type. |
static void |
setValue(XmlValue to,
XmlValue from)
Assigns a new value to an existing one.
|
public static final int ELEMENT_NODE
getNodeType()
.public static final int ATTRIBUTE_NODE
getNodeType()
.public static final int TEXT_NODE
getNodeType()
.public static final int CDATA_SECTION_NODE
getNodeType()
.public static final int ENTITY_REFERENCE_NODE
getNodeType()
.public static final int ENTITY_NODE
getNodeType()
.public static final int PROCESSING_INSTRUCTION_NODE
getNodeType()
.public static final int COMMENT_NODE
getNodeType()
.public static final int DOCUMENT_NODE
getNodeType()
.public static final int DOCUMENT_TYPE_NODE
getNodeType()
.public static final int DOCUMENT_FRAGMENT_NODE
getNodeType()
.public static final int NOTATION_NODE
getNodeType()
.public static final int NONE
public static final int NODE
public static final int ANY_SIMPLE_TYPE
public static final int ANY_URI
public static final int BASE_64_BINARY
public static final int BOOLEAN
public static final int DATE
public static final int DATE_TIME
public static final int DAY_TIME_DURATION
public static final int DECIMAL
public static final int DOUBLE
public static final int DURATION
public static final int FLOAT
public static final int G_DAY
public static final int G_MONTH
public static final int G_MONTH_DAY
public static final int G_YEAR
public static final int G_YEAR_MONTH
public static final int HEX_BINARY
public static final int NOTATION
public static final int QNAME
public static final int STRING
public static final int TIME
public static final int YEAR_MONTH_DURATION
public static final int UNTYPED_ATOMIC
public XmlValue() throws XmlException
XmlException
public XmlValue(XmlValue other) throws XmlException
XmlException
public XmlValue(java.lang.String v) throws XmlException
XmlException
public XmlValue(double v) throws XmlException
XmlException
public XmlValue(boolean v) throws XmlException
XmlException
public XmlValue(XmlDocument document) throws XmlException
XmlException
public XmlValue(int type, java.lang.String v) throws XmlException
XmlException
public XmlValue(java.lang.String typeURI, java.lang.String typeName, java.lang.String v) throws XmlException
XmlException
public XmlValue(int type, byte[] dbt) throws XmlException
XmlException
public int getType() throws XmlException
XmlException
public java.lang.String getTypeURI() throws XmlException
XmlValue
XmlException
public java.lang.String getTypeName() throws XmlException
XmlValue
XmlException
public java.lang.String getNodeHandle() throws XmlException
XmlContainer.getNode(java.lang.String)
If the type of the XmlValue
is not NODE
, an
exception is thrown.
XmlException
public boolean isNull() throws XmlException
XmlException
public boolean isType(int type) throws XmlException
XmlValue
is of the specified type.XmlException
public boolean isNumber() throws XmlException
XmlException
public boolean isString() throws XmlException
XmlException
public boolean isBoolean() throws XmlException
XmlException
public boolean isNode() throws XmlException
XmlException
public byte[] asBinary() throws XmlException
XmlException
public double asNumber() throws XmlException
DOUBLE
.XmlException
public java.lang.String asString() throws XmlException
STRING
.XmlException
public boolean asBoolean() throws XmlException
BOOLEAN
.XmlException
public XmlDocument asDocument() throws XmlException
XmlDocument
.XmlException
public XmlEventReader asEventReader() throws XmlException
XmlEventReader
. This operation is
only valid if the XmlValue
is of type NODE
. The ownership of the
XmlEventReader
belongs to the caller, and its resources must
be released using XmlEventReader.close()
.XmlException
public boolean equals(XmlValue value) throws XmlException
XmlValue
objects represent the same value. It returns
true if the two XmlValue
objects represent the same value.XmlException
public java.lang.String getNodeName() throws XmlException
NODE
, an XmlException
is thrown.XmlException
public java.lang.String getNodeValue() throws XmlException
NODE
, an XmlException
is thrown.XmlException
public java.lang.String getNamespaceURI() throws XmlException
NODE
, an XmlException
is thrown.XmlException
public java.lang.String getPrefix() throws XmlException
NODE
, an XmlException
is thrown.XmlException
public java.lang.String getLocalName() throws XmlException
NODE
, an XmlException
is thrown.XmlException
public short getNodeType() throws XmlException
ELEMENT_NODE
)
If the node type is not NODE
, an XmlException
is thrown.XmlException
public XmlValue getParentNode() throws XmlException
NONE
is
returned. If the node type is not NODE
, an
XmlException
is thrown.
This function cannot be used on values that were created from an
XmlDocument
that was created using XmlManager.createDocument()
and never placed in a container, an XmlException is thrown if this
happens.XmlException
public XmlValue getFirstChild() throws XmlException
NONE
is returned. If the node type is not NODE
, an
XmlException
is thrown.
This function cannot be used on values that were created from an
XmlDocument
that was created using
XmlManager.createDocument()
and never placed in a container, an XmlException
is thrown if this
happens.XmlException
public XmlValue getLastChild() throws XmlException
NONE
is returned.
If the node type is not NODE
, an XmlException
is thrown.
This function cannot be used on values that were created from an
XmlDocument
that was created using
XmlManager.createDocument()
and never placed in a container, an XmlException
is thrown if this
happens.XmlException
public XmlValue getPreviousSibling() throws XmlException
NONE
is returned.
If the node type is not NODE
, an XmlException
is thrown.
This function cannot be used on values that were created from an
XmlDocument
that was created using
XmlManager.createDocument()
and never placed in a container, an XmlException
is thrown if this
happens.XmlException
public XmlValue getNextSibling() throws XmlException
NONE
is returned.
If the node type is not NODE
, an
XmlException
is thrown.
This function cannot be used on values that were created from an
XmlDocument
that was created using
XmlManager.createDocument()
and never placed in a container, an XmlException
is thrown if this
happens.XmlException
public XmlResults getAttributes() throws XmlException
XmlResults
that contains all of the attributes
appearing on this node. If the node type is not NODE
, an
XmlException
is thrown.
This function cannot be used on values that were created from an
XmlDocument
that was created using
XmlManager.createDocument()
and never placed in a container, anXmlException
is thrown if this
happens.XmlException
public XmlValue getOwnerElement() throws XmlException
XmlException
is thrown.
This function cannot be used on values that were created from an
XmlDocument
that was created using
XmlManager.createDocument()
and never placed in a container, an XmlException
is thrown if this
happens.XmlException
public static void setValue(XmlValue to, XmlValue from) throws XmlException
to
- The value to be overwritten.from
- The value to copy.XmlException
public XmlResults getResults()
XmlResults
that is associated with this XmlValue
, or null if there is none. This function exists to make it easier to call XmlResults.delete()
when the value is no longer needed.Copyright (c) 2004,2014 Oracle. All rights reserved.