public class XML extends DataType implements XMLDataValue, StreamStorable
Modifier and Type | Field and Description |
---|---|
private static int |
BASE_MEMORY_USAGE |
private boolean |
containsTopLevelAttr |
private SqlXmlUtil |
tmpUtil |
protected static short |
UTF8_IMPL_ID |
static int |
XML_DOC_ANY |
static int |
XML_SEQUENCE |
private static java.lang.String |
xmlReqCheck |
private SQLChar |
xmlStringValue |
static short |
XQ_EMPTY_ON_EMPTY |
static short |
XQ_NULL_ON_EMPTY |
static short |
XQ_PASS_BY_REF |
static short |
XQ_PASS_BY_VALUE |
static short |
XQ_RETURN_CONTENT |
static short |
XQ_RETURN_SEQUENCE |
private int |
xType |
UNKNOWN_LOGICAL_LENGTH
ORDER_OP_EQUALS, ORDER_OP_GREATEROREQUALS, ORDER_OP_GREATERTHAN, ORDER_OP_LESSOREQUALS, ORDER_OP_LESSTHAN
Modifier | Constructor and Description |
---|---|
|
XML()
Default constructor.
|
private |
XML(SQLChar val,
int xmlType,
boolean seqWithAttr,
boolean materialize)
Private constructor used for the
cloneValue method. |
Modifier and Type | Method and Description |
---|---|
private static boolean |
checkJAXPRequirement()
Check if we have a JAXP implementation installed.
|
static void |
checkXMLRequirements()
See if the required JAXP and Xalan classes are in the
user's classpath.
|
private static boolean |
checkXPathRequirement()
Check if XPath is supported on this platform.
|
DataValueDescriptor |
cloneValue(boolean forceMaterialization)
Clone this DataValueDescriptor.
|
int |
compare(DataValueDescriptor other)
Compare two XML DataValueDescriptors.
|
int |
estimateMemoryUsage()
Estimate the memory usage in bytes of the data value and the overhead of the class.
|
int |
getLength()
Gets the length of the data value.
|
DataValueDescriptor |
getNewNull()
Get a new null value of the same type as this data value.
|
java.lang.String |
getString()
Gets the value in the data value descriptor as a String.
|
int |
getTypeFormatId()
Get a universally unique identifier for the type of
this object.
|
java.lang.String |
getTypeName()
Get the SQL name of the datatype
|
int |
getXType()
Retrieve this XML value's qualified type.
|
boolean |
hasTopLevelAttr()
Return whether or not this XML value represents a sequence
that has one or more top-level attribute nodes.
|
boolean |
isNull()
Return whether the value is null or not.
|
void |
loadStream()
Set the value by reading the stream and
converting it to an object form.
|
void |
markAsHavingTopLevelAttr()
Take note of the fact this XML value represents an XML
sequence that has one or more top-level attribute nodes.
|
void |
normalize(DataTypeDescriptor desiredType,
DataValueDescriptor source)
Normalization method - this method will always be called when
storing an XML value into an XML column, for example, when
inserting/updating.
|
void |
readExternal(java.io.ObjectInput in)
Read an XML value from an input stream.
|
void |
readExternalFromArray(ArrayInputStream in)
Read the DataValueDescriptor from the stream.
|
void |
restoreToNull()
Restore this object to its (SQL)null value.
|
java.io.InputStream |
returnStream()
Return the on-disk stream state of the object.
|
protected void |
setFrom(DataValueDescriptor theValue)
Set the value of this DataValueDescriptor based on the value
of the specified DataValueDescriptor.
|
void |
setStream(java.io.InputStream newStream)
sets the on-disk stream state for the object.
|
void |
setValueFromResultSet(java.sql.ResultSet resultSet,
int colNumber,
boolean isNullable)
Set the value based on the value for the specified DataValueDescriptor
from the specified ResultSet.
|
void |
setXType(int xtype)
Set this XML value's qualified type.
|
int |
typePrecedence()
Each built-in type in JSQL has a precedence.
|
void |
writeExternal(java.io.ObjectOutput out)
Write an XML value.
|
BooleanDataValue |
XMLExists(SqlXmlUtil sqlxUtil)
The SQL/XML XMLExists operator.
|
XMLDataValue |
XMLParse(StringDataValue stringValue,
boolean preserveWS,
SqlXmlUtil sqlxUtil)
Method to parse an XML string and, if it's valid,
store the _serialized_ version locally and then return
this XMLDataValue.
|
XMLDataValue |
XMLQuery(SqlXmlUtil sqlxUtil,
XMLDataValue result)
Evaluate the XML query expression contained within the received
util object against this XML value and store the results into
the received XMLDataValue "result" param (assuming "result" is
non-null; else create a new XMLDataValue).
|
StringDataValue |
XMLSerialize(StringDataValue result,
int targetType,
int targetWidth,
int targetCollationType)
The SQL/XML XMLSerialize operator.
|
checkHostVariable, cloneHolder, coalesce, compare, compare, compare, compareTo, dataTypeConversion, equals, equals, flip, genericSetObject, getBoolean, getByte, getBytes, getDate, getDouble, getFloat, getInt, getLong, getObject, getShort, getStream, getTime, getTimestamp, getTraceString, getTypeName, greaterOrEquals, greaterThan, hasStream, in, invalidFormat, isNotNull, isNullOp, lessOrEquals, lessThan, notEquals, outOfRange, recycle, setBigDecimal, setInto, setInto, setObject, setObjectForCast, setToNull, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, throwLangSetMismatch, throwLangSetMismatch, typeToBigDecimal
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
checkHostVariable, cloneHolder, coalesce, compare, compare, compare, equals, getBoolean, getByte, getBytes, getDate, getDouble, getFloat, getInt, getLong, getObject, getShort, getStream, getTime, getTimestamp, getTraceString, greaterOrEquals, greaterThan, hasStream, in, isNotNull, isNullOp, lessOrEquals, lessThan, notEquals, recycle, setBigDecimal, setInto, setInto, setObjectForCast, setToNull, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, typeToBigDecimal
protected static final short UTF8_IMPL_ID
private static final int BASE_MEMORY_USAGE
public static final short XQ_PASS_BY_REF
public static final short XQ_PASS_BY_VALUE
public static final short XQ_RETURN_SEQUENCE
public static final short XQ_RETURN_CONTENT
public static final short XQ_EMPTY_ON_EMPTY
public static final short XQ_NULL_ON_EMPTY
public static final int XML_DOC_ANY
public static final int XML_SEQUENCE
private int xType
private SQLChar xmlStringValue
private static java.lang.String xmlReqCheck
private boolean containsTopLevelAttr
private SqlXmlUtil tmpUtil
public XML()
private XML(SQLChar val, int xmlType, boolean seqWithAttr, boolean materialize)
cloneValue
method.
Returns a new instance of XML whose fields are clones
of the values received.val
- A SQLChar instance to clone and use for
this XML value.xmlType
- Qualified XML type for "val"seqWithAttr
- Whether or not "val" corresponds to
sequence with one or more top-level attribute nodes.materialize
- whether or not to force materialization of the
underlying source datapublic DataValueDescriptor cloneValue(boolean forceMaterialization)
DataValueDescriptor
Even though the objects can be modified independently regardless of the
value of forceMaterialization
, both the clone and the
original may be dependent on the store state if
forceMaterialization
is set to false
. An example is if
you need to access the value you just read using cloneValue
after the current transaction has ended, or after the source result set
has been closed.
cloneValue
in interface DataValueDescriptor
forceMaterialization
- any streams representing the data value will
be materialized if true
, the data value will be kept as a
stream if possible if false
DataValueDescriptor
with the same initial
value as this.DataValueDescriptor.cloneValue(boolean)
public DataValueDescriptor getNewNull()
DataValueDescriptor
getNewNull
in interface DataValueDescriptor
DataValueDescriptor.getNewNull()
public java.lang.String getTypeName()
DataValueDescriptor
getTypeName
in interface DataValueDescriptor
DataValueDescriptor.getTypeName()
public int typePrecedence()
DataType
typePrecedence
in interface DataValueDescriptor
typePrecedence
in class DataType
DataValueDescriptor.typePrecedence()
public java.lang.String getString() throws StandardException
DataValueDescriptor
getString
in interface DataValueDescriptor
StandardException
- Thrown on errorDataValueDescriptor.getString()
public int getLength() throws StandardException
DataValueDescriptor
getLength
in interface DataValueDescriptor
StandardException
- On errorDataValueDescriptor.getLength()
public int estimateMemoryUsage()
DataValueDescriptor
estimateMemoryUsage
in interface DataValueDescriptor
DataValueDescriptor.estimateMemoryUsage()
public void readExternalFromArray(ArrayInputStream in) throws java.io.IOException
DataType
readExternal()
, which accesses the ArrayInputStream
as a generic stream. If sub-classes can implement it more efficiently
by accessing the array, they should override this method.readExternalFromArray
in interface DataValueDescriptor
readExternalFromArray
in class DataType
in
- The array stream positioned at the beginning of the
byte stream to read from.java.io.IOException
- Usual error is if you try to read
past limit on the stream.DataValueDescriptor.readExternalFromArray(org.apache.derby.iapi.services.io.ArrayInputStream)
protected void setFrom(DataValueDescriptor theValue) throws StandardException
DataType
setFrom
in class DataType
theValue
- The DataValueDescriptor that holds the value to
which we want to set this DataValueDescriptor's value.StandardException
DataType.setFrom(org.apache.derby.iapi.types.DataValueDescriptor)
public final void setValueFromResultSet(java.sql.ResultSet resultSet, int colNumber, boolean isNullable) throws java.sql.SQLException
DataValueDescriptor
setValueFromResultSet
in interface DataValueDescriptor
resultSet
- The specified ResultSet.colNumber
- The 1-based column # into the resultSet.isNullable
- Whether or not the column is nullable
(No need to call wasNull() if not)java.sql.SQLException
- Error accessing the result setDataValueDescriptor.setValueFromResultSet(java.sql.ResultSet, int, boolean)
public int compare(DataValueDescriptor other) throws StandardException
compare
in interface DataValueDescriptor
other
- The Orderable to compare this one to.StandardException
- Thrown on errorDataValueDescriptor.compare(org.apache.derby.iapi.types.DataValueDescriptor)
public void normalize(DataTypeDescriptor desiredType, DataValueDescriptor source) throws StandardException
normalize
in interface DataValueDescriptor
normalize
in class DataType
desiredType
- The type to normalize the source column tosource
- The value to normalizeStandardException
- Thrown if source is not
XML_DOC_ANY.public int getTypeFormatId()
TypedFormat
getTypeFormatId
in interface TypedFormat
From the engine's perspective, all XML implementations share
the same format id.
public boolean isNull()
Storable
isNull
in interface Storable
Storable.isNull()
public void restoreToNull()
Storable
restoreToNull
in interface Storable
Storable.restoreToNull()
public void readExternal(java.io.ObjectInput in) throws java.io.IOException
readExternal
in interface java.io.Externalizable
in
- The stream from which we're reading.java.io.IOException
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
out
- The stream to which we're writing.java.io.IOException
public java.io.InputStream returnStream()
StreamStorable
returnStream
in interface StreamStorable
StreamStorable.returnStream()
public void setStream(java.io.InputStream newStream)
StreamStorable
setStream
in interface StreamStorable
StreamStorable.setStream(java.io.InputStream)
public void loadStream() throws StandardException
StreamStorable
loadStream
in interface StreamStorable
StandardException
- on errorStreamStorable.loadStream()
public XMLDataValue XMLParse(StringDataValue stringValue, boolean preserveWS, SqlXmlUtil sqlxUtil) throws StandardException
XMLParse
in interface XMLDataValue
stringValue
- The string value to check.preserveWS
- Whether or not to preserve
ignorable whitespace.sqlxUtil
- Contains SQL/XML objects and util
methods that facilitate execution of XML-related
operationsStandardException
- Thrown on error.public StringDataValue XMLSerialize(StringDataValue result, int targetType, int targetWidth, int targetCollationType) throws StandardException
XMLSerialize
in interface XMLDataValue
result
- The result of a previous call to this method,
null if not called yet.targetType
- The string type to which we want to serialize.targetWidth
- The width of the target type.targetCollationType
- The collation type of the target type.StandardException
- Thrown on errorpublic BooleanDataValue XMLExists(SqlXmlUtil sqlxUtil) throws StandardException
XMLExists
in interface XMLDataValue
sqlxUtil
- Contains SQL/XML objects and util
methods that facilitate execution of XML-related
operationsStandardException
- Thrown on errorpublic XMLDataValue XMLQuery(SqlXmlUtil sqlxUtil, XMLDataValue result) throws StandardException
XMLQuery
in interface XMLDataValue
sqlxUtil
- Contains SQL/XML objects and util methods that
facilitate execution of XML-related operationsresult
- The result of a previous call to this method; null
if not called yet.StandardException
- thrown on errorpublic void setXType(int xtype)
setXType
in interface XMLDataValue
public int getXType()
getXType
in interface XMLDataValue
public void markAsHavingTopLevelAttr()
markAsHavingTopLevelAttr
in interface XMLDataValue
public boolean hasTopLevelAttr()
hasTopLevelAttr
in interface XMLDataValue
public static void checkXMLRequirements() throws StandardException
StandardException
- thrown if the required
classes cannot be located in the classpath.private static boolean checkJAXPRequirement()
true
if JAXP is installed, or false
otherwiseprivate static boolean checkXPathRequirement()
true
if XPath is supported, or false
otherwiseApache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.