Constructor and Description |
---|
PgSQLXML(BaseConnection conn) |
PgSQLXML(BaseConnection conn,
String data) |
Modifier and Type | Method and Description |
---|---|
void |
free()
This method closes this object and releases the resources that it held.
|
InputStream |
getBinaryStream()
Retrieves the XML value designated by this SQLXML instance as a stream.
|
Reader |
getCharacterStream()
Retrieves the XML value designated by this SQLXML instance as a java.io.Reader object.
|
<T extends Source> |
getSource(Class<T> sourceClass)
Returns a Source for reading the XML value designated by this SQLXML instance.
|
String |
getString()
Returns a string representation of the XML value designated by this SQLXML instance.
|
OutputStream |
setBinaryStream()
Retrieves a stream that can be used to write the XML value that this SQLXML instance represents.
|
Writer |
setCharacterStream()
Retrieves a stream to be used to write the XML value that this SQLXML instance represents.
|
<T extends Result> |
setResult(Class<T> resultClass)
Returns a Result for setting the XML value designated by this SQLXML instance.
|
void |
setString(String value)
Sets the XML value designated by this SQLXML instance to the given String representation.
|
public PgSQLXML(BaseConnection conn)
public PgSQLXML(BaseConnection conn, String data)
public void free()
java.sql.SQLXML
free
has been called, any attempt to invoke a
method other than free
will result in a SQLException
being thrown. If free
is called multiple times, the subsequent
calls to free
are treated as a no-op.public InputStream getBinaryStream() throws SQLException
java.sql.SQLXML
The SQL XML object becomes not readable when this method is called and may also become not writable depending on implementation.
getBinaryStream
in interface SQLXML
SQLException
- if there is an error processing the XML value.
An exception is thrown if the state is not readable.SQLFeatureNotSupportedException
- if the JDBC driver does not support
this methodpublic Reader getCharacterStream() throws SQLException
java.sql.SQLXML
The SQL XML object becomes not readable when this method is called and may also become not writable depending on implementation.
getCharacterStream
in interface SQLXML
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.SQLFeatureNotSupportedException
- if the JDBC driver does not support
this methodpublic <T extends Source> T getSource(Class<T> sourceClass) throws SQLException
java.sql.SQLXML
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());
getSource
in interface SQLXML
T
- the type of the class modeled by this Class objectsourceClass
- 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
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.SQLFeatureNotSupportedException
- if the JDBC driver does not support
this methodpublic String getString() throws SQLException
java.sql.SQLXML
The SQL XML object becomes not readable when this method is called and may also become not writable depending on implementation.
getString
in interface SQLXML
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.SQLFeatureNotSupportedException
- if the JDBC driver does not support
this methodpublic OutputStream setBinaryStream() throws SQLException
java.sql.SQLXML
The SQL XML object becomes not writeable when this method is called and may also become not readable depending on implementation.
setBinaryStream
in interface SQLXML
SQLException
- if there is an error processing the XML value.
An exception is thrown if the state is not writable.SQLFeatureNotSupportedException
- if the JDBC driver does not support
this methodpublic Writer setCharacterStream() throws SQLException
java.sql.SQLXML
The SQL XML object becomes not writeable when this method is called and may also become not readable depending on implementation.
setCharacterStream
in interface SQLXML
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.SQLFeatureNotSupportedException
- if the JDBC driver does not support
this methodpublic <T extends Result> T setResult(Class<T> resultClass) throws SQLException
java.sql.SQLXML
The systemID of the Result is implementation dependent.
The SQL XML object becomes not writeable 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();
setResult
in interface SQLXML
T
- the type of the class modeled by this Class objectresultClass
- 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
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.SQLFeatureNotSupportedException
- if the JDBC driver does not support
this methodpublic void setString(String value) throws SQLException
java.sql.SQLXML
The SQL XML object becomes not writeable when this method is called and may also become not readable depending on implementation.
setString
in interface SQLXML
value
- the XML valueSQLException
- 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.SQLFeatureNotSupportedException
- if the JDBC driver does not support
this methodCopyright © 2019 PostgreSQL Global Development Group. All rights reserved.