public class SqlXmlUtil
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private class |
SqlXmlUtil.XMLErrorHandler |
Modifier and Type | Field and Description |
---|---|
private javax.xml.parsers.DocumentBuilder |
dBuilder |
private java.lang.String |
opName |
private org.w3c.dom.xpath.XPathExpression |
query |
private java.lang.String |
queryExpr |
private boolean |
recompileQuery |
private javax.xml.transform.Transformer |
serializer |
private static java.lang.reflect.Method |
TO_PLAIN_STRING
An object representing the
BigDecimal.toPlainString() method
if it's available on the platform. |
Constructor and Description |
---|
SqlXmlUtil()
Constructor: Initializes objects required for parsing
and serializing XML values.
|
Modifier and Type | Method and Description |
---|---|
void |
compileXQExpr(java.lang.String queryExpr,
java.lang.String opName)
Take the received string, which is an XML query expression,
compile it, and store the compiled query locally.
|
protected java.util.List |
evalXQExpression(XMLDataValue xmlContext,
boolean returnResults,
int[] resultXType)
Evaluate this object's compiled XML query expression against
the received xmlContext.
|
private void |
loadSerializer()
Create an instance of Xalan serializer for the sake of
serializing an XML value according the SQL/XML specification
for serialization.
|
private static java.lang.String |
numberToString(double d)
Convert a number returned by an XPath query to a string, following the
rules for the
XPath string function.
|
protected java.lang.String |
serializeToString(java.util.List items,
XMLDataValue xmlVal)
Take an array list (sequence) of XML nodes and/or string values
and serialize that entire list according to SQL/XML serialization
rules, which ultimately point to XML serialization rules as
defined by w3c.
|
protected java.lang.String |
serializeToString(java.lang.String xmlAsText)
Take a string representing an XML value and serialize it
according SQL/XML serialization rules.
|
private javax.xml.parsers.DocumentBuilder dBuilder
private javax.xml.transform.Transformer serializer
private org.w3c.dom.xpath.XPathExpression query
private java.lang.String queryExpr
private java.lang.String opName
private boolean recompileQuery
private static final java.lang.reflect.Method TO_PLAIN_STRING
An object representing the BigDecimal.toPlainString()
method
if it's available on the platform. If it's not available, this field
will be initialized to null
, and in that case the
BigDecimal.toString()
method should be used instead without
reflection.
The behaviour of the toString()
method changed when
toPlainString()
was introduced in Java SE 5. On older
platforms, it behaves just like toPlainString()
does on
newer platforms. So when toPlainString()
is not
available, it is safe to fall back to toString()
. It
behaves differently on newer platforms, so we need to use
toPlainString()
when it is available in order to get
consistent behaviour across all platforms.
numberToString(double)
public SqlXmlUtil() throws StandardException
StandardException
public void compileXQExpr(java.lang.String queryExpr, java.lang.String opName) throws StandardException
queryExpr
- The XPath expression to compileStandardException
protected java.lang.String serializeToString(java.lang.String xmlAsText) throws java.lang.Exception
xmlAsText
- String version of XML on which to perform
serialization.java.lang.Exception
protected java.lang.String serializeToString(java.util.List items, XMLDataValue xmlVal) throws javax.xml.transform.TransformerException
items
- List of items to serializexmlVal
- XMLDataValue into which the serialized string
returned by this method is ultimately going to be stored.
This is used for keeping track of XML values that represent
sequences having top-level (parentless) attribute nodes.javax.xml.transform.TransformerException
protected java.util.List evalXQExpression(XMLDataValue xmlContext, boolean returnResults, int[] resultXType) throws java.lang.Exception
xmlContext
- The XML value against which to evaluate
the stored (compiled) query expressionreturnResults
- Whether or not to return the actual
results of the queryresultXType
- The qualified XML type of the result
of evaluating the expression, if returnResults is true.
If the result is a sequence of exactly one Document node
then this will be XML(DOCUMENT(ANY)); else it will be
XML(SEQUENCE). If returnResults is false, this value
is ignored.java.lang.Exception
- thrown on error (and turned into a
StandardException by the caller).private void loadSerializer() throws javax.xml.transform.TransformerConfigurationException
javax.xml.transform.TransformerConfigurationException
private static java.lang.String numberToString(double d) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
d
- double
representation of the numberString
representation of the numberjava.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
Apache Derby V10.10 Internals - Copyright © 2004,2014 The Apache Software Foundation. All Rights Reserved.