|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.derby.iapi.types.DataType
org.apache.derby.iapi.types.XML
public class XML
This type implements the XMLDataValue interface and thus is the type on which all XML related operations are executed. The first and simplest XML store implementation is a UTF-8 based one--all XML data is stored on disk as a UTF-8 string, just like the other Derby string types. In order to make it possible for smarter XML implementations to exist in the future, this class always writes an "XML implementation id" to disk before writing the rest of its data. When reading the data, the impl id is read first and serves as an indicator of how the rest of the data should be read. So long as there's only one implementation (UTF-8) the impl id can be ignored; but when smarter implementations are written, the impl id will be the key to figuring out how an XML value should be read, written, and processed.
| Field Summary | |
|---|---|
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
|
| Fields inherited from interface org.apache.derby.iapi.types.DataValueDescriptor |
|---|
UNKNOWN_LOGICAL_LENGTH |
| Fields inherited from interface org.apache.derby.iapi.types.Orderable |
|---|
ORDER_OP_EQUALS, ORDER_OP_GREATEROREQUALS, ORDER_OP_GREATERTHAN, ORDER_OP_LESSOREQUALS, ORDER_OP_LESSTHAN |
| Constructor Summary | |
|---|---|
|
XML()
Default constructor. |
private |
XML(SQLChar val,
int xmlType,
boolean seqWithAttr,
boolean materialize)
Private constructor used for the cloneValue method. |
| Method Summary | |
|---|---|
private static java.lang.Object |
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(java.lang.Object domImpl)
Check if the supplied DOMImplementation object has
support for DOM Level 3 XPath. |
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. |
| Methods inherited from class org.apache.derby.iapi.types.DataType |
|---|
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 |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.apache.derby.iapi.types.DataValueDescriptor |
|---|
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 |
| Field Detail |
|---|
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
| Constructor Detail |
|---|
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 data| Method Detail |
|---|
public 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 DataValueDescriptorforceMaterialization - 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 DataValueDescriptorDataValueDescriptor.getNewNull()public java.lang.String getTypeName()
DataValueDescriptor
getTypeName in interface DataValueDescriptorDataValueDescriptor.getTypeName()public int typePrecedence()
DataType
typePrecedence in interface DataValueDescriptortypePrecedence in class DataTypeDataValueDescriptor.typePrecedence()
public java.lang.String getString()
throws StandardException
DataValueDescriptor
getString in interface DataValueDescriptorStandardException - Thrown on errorDataValueDescriptor.getString()
public int getLength()
throws StandardException
DataValueDescriptor
getLength in interface DataValueDescriptorStandardException - On errorDataValueDescriptor.getLength()public int estimateMemoryUsage()
DataValueDescriptor
estimateMemoryUsage in interface DataValueDescriptorDataValueDescriptor.estimateMemoryUsage()
public void readExternalFromArray(ArrayInputStream in)
throws java.io.IOException
DataTypereadExternal(), 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 DataValueDescriptorreadExternalFromArray in class DataTypein - 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 DataTypetheValue - The DataValueDescriptor that holds the value to
which we want to set this DataValueDescriptor's value.
StandardExceptionDataType.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 DataValueDescriptorresultSet - 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 DataValueDescriptorother - 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 DataValueDescriptornormalize in class DataTypedesiredType - The type to normalize the source column tosource - The value to normalize
StandardException - Thrown if source is not
XML_DOC_ANY.public int getTypeFormatId()
TypedFormat
getTypeFormatId in interface TypedFormatFrom the engine's perspective, all XML implementations share
the same format id.public boolean isNull()
Storable
isNull in interface StorableStorable.isNull()public void restoreToNull()
Storable
restoreToNull in interface StorableStorable.restoreToNull()
public void readExternal(java.io.ObjectInput in)
throws java.io.IOException
readExternal in interface java.io.Externalizablein - 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.Externalizableout - The stream to which we're writing.
java.io.IOExceptionpublic java.io.InputStream returnStream()
StreamStorable
returnStream in interface StreamStorableStreamStorable.returnStream()public void setStream(java.io.InputStream newStream)
StreamStorable
setStream in interface StreamStorableStreamStorable.setStream(java.io.InputStream)
public void loadStream()
throws StandardException
StreamStorable
loadStream in interface StreamStorableStandardException - on errorStreamStorable.loadStream()
public XMLDataValue XMLParse(StringDataValue stringValue,
boolean preserveWS,
SqlXmlUtil sqlxUtil)
throws StandardException
XMLParse in interface XMLDataValuestringValue - 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
operations
StandardException - Thrown on error.
public StringDataValue XMLSerialize(StringDataValue result,
int targetType,
int targetWidth,
int targetCollationType)
throws StandardException
XMLSerialize in interface XMLDataValueresult - 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 error
public BooleanDataValue XMLExists(SqlXmlUtil sqlxUtil)
throws StandardException
XMLExists in interface XMLDataValuesqlxUtil - Contains SQL/XML objects and util
methods that facilitate execution of XML-related
operations
StandardException - Thrown on error
public XMLDataValue XMLQuery(SqlXmlUtil sqlxUtil,
XMLDataValue result)
throws StandardException
XMLQuery in interface XMLDataValuesqlxUtil - 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.
java.lang.Exception - thrown on error (and turned into a
StandardException by the caller).
StandardExceptionpublic void setXType(int xtype)
setXType in interface XMLDataValuepublic int getXType()
getXType in interface XMLDataValuepublic void markAsHavingTopLevelAttr()
markAsHavingTopLevelAttr in interface XMLDataValuepublic 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 java.lang.Object checkJAXPRequirement()
DOMImplementation object retrieved from the
JAXP implementation, if one is installed, or null if an
implementation couldn't be foundprivate static boolean checkXPathRequirement(java.lang.Object domImpl)
DOMImplementation object has
support for DOM Level 3 XPath.
domImpl - the DOMImplementation instance to check
true if the required XPath level is supported,
false otherwise
|
Built on Wed 2013-06-12 15:21:56+0000, from revision ??? | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||