Top Description Fields Constructors Methods
org.h2.jdbc

public final Class JdbcSQLXML

extends JdbcLob
implements SQLXML
Class Inheritance
All Implemented Interfaces
java.sql.SQLXML
Imports
java.io.BufferedOutputStream, .Closeable, .IOException, .InputStream, .OutputStream, .Reader, .StringReader, .StringWriter, .Writer, java.sql.SQLException, .SQLXML, java.util.HashMap, .Map, javax.xml.XMLConstants, javax.xml.parsers.DocumentBuilder, .DocumentBuilderFactory, .SAXParserFactory, javax.xml.stream.XMLInputFactory, .XMLOutputFactory, javax.xml.transform.Result, .Source, .Transformer, .TransformerFactory, .URIResolver, javax.xml.transform.dom.DOMResult, .DOMSource, javax.xml.transform.sax.SAXResult, .SAXSource, .SAXTransformerFactory, .TransformerHandler, javax.xml.transform.stax.StAXResult, .StAXSource, javax.xml.transform.stream.StreamResult, .StreamSource, org.h2.message.DbException, .TraceObject, org.h2.value.Value, org.w3c.dom.Node, org.xml.sax.EntityResolver, .InputSource, .XMLReader, org.xml.sax.helpers.DefaultHandler

Represents a SQLXML value.

Field Summary

Modifier and TypeField and Description
private Closeable
closable

Underlying stream for SAXResult, StAXResult, and StreamResult.

private DOMResult
private static final EntityResolver
private static final URIResolver
private static final Map<String, Boolean>
Inherited from org.h2.jdbc.JdbcLob:
connstatevalue

Constructor Summary

AccessConstructor and Description
public
JdbcSQLXML(JdbcConnection
to use
conn
,
Value
for this JdbcSQLXML
value
,
JdbcLob.State
of the LOB
state
,
int
of the trace object
id
)

INTERNAL

Method Summary

Modifier and TypeMethod and Description
pack-priv void
checkReadable()

Overrides org.h2.jdbc.JdbcLob.checkReadable.

Check the state of the LOB and throws the exception when check failed (the LOB must be set completely before read).

public InputStream
getBinaryStream()

Overrides org.h2.jdbc.JdbcLob.getBinaryStream.

Implements java.sql.SQLXML.getBinaryStream.

Retrieves the XML value designated by this SQLXML instance as a stream.

public Reader
getCharacterStream()

Overrides org.h2.jdbc.JdbcLob.getCharacterStream.

Implements java.sql.SQLXML.getCharacterStream.

Retrieves the XML value designated by this SQLXML instance as a java.io.Reader object.

public <T extends Source> T
getSource(Class<T>
The class of the source, or null. If the class is null, a vendor specific Source implementation will be returned. The following classes are supported at a minimum:
  javax.xml.transform.dom.DOMSource - returns a DOMSource
  javax.xml.transform.sax.SAXSource - returns a SAXSource
  javax.xml.transform.stax.StAXSource - returns a StAXSource
  javax.xml.transform.stream.StreamSource - returns a StreamSource
sourceClass
)

Implements java.sql.SQLXML.getSource.

Returns a Source for reading the XML value designated by this SQLXML instance.

public String
getString()

Implements java.sql.SQLXML.getString.

Returns a string representation of the XML value designated by this SQLXML instance.

public OutputStream
setBinaryStream()

Implements java.sql.SQLXML.setBinaryStream.

Retrieves a stream that can be used to write the XML value that this SQLXML instance represents.

public Writer
setCharacterStream()

Implements java.sql.SQLXML.setCharacterStream.

Retrieves a stream to be used to write the XML value that this SQLXML instance represents.

public <T extends Result> T
setResult(Class<T>
The class of the result, or null. If resultClass is null, a vendor specific Result implementation will be returned. The following classes are supported at a minimum:
  javax.xml.transform.dom.DOMResult - returns a DOMResult
  javax.xml.transform.sax.SAXResult - returns a SAXResult
  javax.xml.transform.stax.StAXResult - returns a StAXResult
  javax.xml.transform.stream.StreamResult - returns a StreamResult
resultClass
)

Implements java.sql.SQLXML.setResult.

Returns a Result for setting the XML value designated by this SQLXML instance.

public void
setString(String
the XML value
value
)

Implements java.sql.SQLXML.setString.

Sets the XML value designated by this SQLXML instance to the given String representation.

Inherited from org.h2.jdbc.JdbcLob:
checkClosedcheckEditablecompleteWritefreesetCharacterStreamImplsetClobOutputStreamImpltoString

Field Detail

closableback to summary
private Closeable closable

Underlying stream for SAXResult, StAXResult, and StreamResult.

domResultback to summary
private DOMResult domResult
NOOP_ENTITY_RESOLVERback to summary
private static final EntityResolver NOOP_ENTITY_RESOLVER
NOOP_URI_RESOLVERback to summary
private static final URIResolver NOOP_URI_RESOLVER
secureFeatureMapback to summary
private static final Map<String, Boolean> secureFeatureMap

Constructor Detail

JdbcSQLXMLback to summary
public JdbcSQLXML(JdbcConnection conn, Value value, JdbcLob.State state, int id)

INTERNAL

Parameters
conn:JdbcConnection

to use

value:Value

for this JdbcSQLXML

state:JdbcLob.State

of the LOB

id:int

of the trace object

Method Detail

checkReadableback to summary
pack-priv void checkReadable() throws SQLException, IOException

Overrides org.h2.jdbc.JdbcLob.checkReadable.

Doc from org.h2.jdbc.JdbcLob.checkReadable.

Check the state of the LOB and throws the exception when check failed (the LOB must be set completely before read).

Annotations
@Override
Exceptions
SQLException:
on SQL exception
IOException:
on I/O exception
getBinaryStreamback to summary
public InputStream getBinaryStream() throws SQLException

Overrides org.h2.jdbc.JdbcLob.getBinaryStream.

Implements java.sql.SQLXML.getBinaryStream.

Doc from java.sql.SQLXML.getBinaryStream.

Retrieves the XML value designated by this SQLXML instance as a stream. The bytes of the input stream are interpreted according to appendix F of the XML 1.0 specification. The behavior of this method is the same as ResultSet.getBinaryStream() when the designated column of the ResultSet has a type java.sql.Types of SQLXML.

The SQL XML object becomes not readable when this method is called and may also become not writable depending on implementation.

Returns:InputStream

a stream containing the XML data.

Annotations
@Override
Exceptions
SQLException:
if there is an error processing the XML value. An exception is thrown if the state is not readable.
getCharacterStreamback to summary
public Reader getCharacterStream() throws SQLException

Overrides org.h2.jdbc.JdbcLob.getCharacterStream.

Implements java.sql.SQLXML.getCharacterStream.

Doc from java.sql.SQLXML.getCharacterStream.

Retrieves the XML value designated by this SQLXML instance as a java.io.Reader object. The format of this stream is defined by org.xml.sax.InputSource, where the characters in the stream represent the unicode code points for XML according to section 2 and appendix B of the XML 1.0 specification. Although an encoding declaration other than unicode may be present, the encoding of the stream is unicode. The behavior of this method is the same as ResultSet.getCharacterStream() when the designated column of the ResultSet has a type java.sql.Types of SQLXML.

The SQL XML object becomes not readable when this method is called and may also become not writable depending on implementation.

Returns:Reader

a stream containing the XML data.

Annotations
@Override
Exceptions
SQLException:
if there is an error processing the XML value. The getCause() method of the exception may provide a more detailed exception, for example, if the stream does not contain valid characters. An exception is thrown if the state is not readable.
getSourceback to summary
public <T extends Source> T getSource(Class<T> sourceClass) throws SQLException

Implements java.sql.SQLXML.getSource.

Doc from java.sql.SQLXML.getSource.

Returns a Source for reading the XML value designated by this SQLXML instance. Sources are used as inputs to XML parsers and XSLT transformers.

Sources for XML parsers will have namespace processing on by default. The systemID of the Source is implementation dependent.

The SQL XML object becomes not readable when this method is called and may also become not writable depending on implementation.

Note that SAX is a callback architecture, so a returned SAXSource should then be set with a content handler that will receive the SAX events from parsing. The content handler will receive callbacks based on the contents of the XML.

  SAXSource saxSource = sqlxml.getSource(SAXSource.class);
  XMLReader xmlReader = saxSource.getXMLReader();
  xmlReader.setContentHandler(myHandler);
  xmlReader.parse(saxSource.getInputSource());
Parameters
<T>
the type of the class modeled by this Class object
sourceClass:Class<T>

The class of the source, or null. If the class is null, a vendor specific Source implementation will be returned. The following classes are supported at a minimum:

  javax.xml.transform.dom.DOMSource - returns a DOMSource
  javax.xml.transform.sax.SAXSource - returns a SAXSource
  javax.xml.transform.stax.StAXSource - returns a StAXSource
  javax.xml.transform.stream.StreamSource - returns a StreamSource
Returns:T

a Source for reading the XML value.

Annotations
@SuppressWarnings:unchecked
@Override
Exceptions
SQLException:
if there is an error processing the XML value or if this feature is not supported. The getCause() method of the exception may provide a more detailed exception, for example, if an XML parser exception occurs. An exception is thrown if the state is not readable.
getStringback to summary
public String getString() throws SQLException

Implements java.sql.SQLXML.getString.

Doc from java.sql.SQLXML.getString.

Returns a string representation of the XML value designated by this SQLXML instance. The format of this String is defined by org.xml.sax.InputSource, where the characters in the stream represent the unicode code points for XML according to section 2 and appendix B of the XML 1.0 specification. Although an encoding declaration other than unicode may be present, the encoding of the String is unicode. The behavior of this method is the same as ResultSet.getString() when the designated column of the ResultSet has a type java.sql.Types of SQLXML.

The SQL XML object becomes not readable when this method is called and may also become not writable depending on implementation.

Returns:String

a string representation of the XML value designated by this SQLXML instance.

Annotations
@Override
Exceptions
SQLException:
if there is an error processing the XML value. The getCause() method of the exception may provide a more detailed exception, for example, if the stream does not contain valid characters. An exception is thrown if the state is not readable.
setBinaryStreamback to summary
public OutputStream setBinaryStream() throws SQLException

Implements java.sql.SQLXML.setBinaryStream.

Doc from java.sql.SQLXML.setBinaryStream.

Retrieves a stream that can be used to write the XML value that this SQLXML instance represents. The stream begins at position 0. The bytes of the stream are interpreted according to appendix F of the XML 1.0 specification The behavior of this method is the same as ResultSet.updateBinaryStream() when the designated column of the ResultSet has a type java.sql.Types of SQLXML.

The SQL XML object becomes not writable when this method is called and may also become not readable depending on implementation.

Returns:OutputStream

a stream to which data can be written.

Annotations
@Override
Exceptions
SQLException:
if there is an error processing the XML value. An exception is thrown if the state is not writable.
setCharacterStreamback to summary
public Writer setCharacterStream() throws SQLException

Implements java.sql.SQLXML.setCharacterStream.

Doc from java.sql.SQLXML.setCharacterStream.

Retrieves a stream to be used to write the XML value that this SQLXML instance represents. The format of this stream is defined by org.xml.sax.InputSource, where the characters in the stream represent the unicode code points for XML according to section 2 and appendix B of the XML 1.0 specification. Although an encoding declaration other than unicode may be present, the encoding of the stream is unicode. The behavior of this method is the same as ResultSet.updateCharacterStream() when the designated column of the ResultSet has a type java.sql.Types of SQLXML.

The SQL XML object becomes not writable when this method is called and may also become not readable depending on implementation.

Returns:Writer

a stream to which data can be written.

Annotations
@Override
Exceptions
SQLException:
if there is an error processing the XML value. The getCause() method of the exception may provide a more detailed exception, for example, if the stream does not contain valid characters. An exception is thrown if the state is not writable.
setResultback to summary
public <T extends Result> T setResult(Class<T> resultClass) throws SQLException

Implements java.sql.SQLXML.setResult.

Doc from java.sql.SQLXML.setResult.

Returns a Result for setting the XML value designated by this SQLXML instance.

The systemID of the Result is implementation dependent.

The SQL XML object becomes not writable when this method is called and may also become not readable depending on implementation.

Note that SAX is a callback architecture and the returned SAXResult has a content handler assigned that will receive the SAX events based on the contents of the XML. Call the content handler with the contents of the XML document to assign the values.

  SAXResult saxResult = sqlxml.setResult(SAXResult.class);
  ContentHandler contentHandler = saxResult.getXMLReader().getContentHandler();
  contentHandler.startDocument();
  // set the XML elements and attributes into the result
  contentHandler.endDocument();
Parameters
<T>
the type of the class modeled by this Class object
resultClass:Class<T>

The class of the result, or null. If resultClass is null, a vendor specific Result implementation will be returned. The following classes are supported at a minimum:

  javax.xml.transform.dom.DOMResult - returns a DOMResult
  javax.xml.transform.sax.SAXResult - returns a SAXResult
  javax.xml.transform.stax.StAXResult - returns a StAXResult
  javax.xml.transform.stream.StreamResult - returns a StreamResult
Returns:T

Returns a Result for setting the XML value.

Annotations
@SuppressWarnings:unchecked
@Override
Exceptions
SQLException:
if there is an error processing the XML value or if this feature is not supported. The getCause() method of the exception may provide a more detailed exception, for example, if an XML parser exception occurs. An exception is thrown if the state is not writable.
setStringback to summary
public void setString(String value) throws SQLException

Implements java.sql.SQLXML.setString.

Doc from java.sql.SQLXML.setString.

Sets the XML value designated by this SQLXML instance to the given String representation. The format of this String is defined by org.xml.sax.InputSource, where the characters in the stream represent the unicode code points for XML according to section 2 and appendix B of the XML 1.0 specification. Although an encoding declaration other than unicode may be present, the encoding of the String is unicode. The behavior of this method is the same as ResultSet.updateString() when the designated column of the ResultSet has a type java.sql.Types of SQLXML.

The SQL XML object becomes not writable when this method is called and may also become not readable depending on implementation.

Parameters
value:String

the XML value

Annotations
@Override
Exceptions
SQLException:
if there is an error processing the XML value. The getCause() method of the exception may provide a more detailed exception, for example, if the stream does not contain valid characters. An exception is thrown if the state is not writable.