Top Fields Constructors Methods
org.postgresql.jdbc

public Class PgSQLXML

extends Object
implements SQLXML
Class Inheritance
All Implemented Interfaces
java.sql.SQLXML
Imports
org.postgresql.core.BaseConnection, org.postgresql.util.GT, .PSQLException, .PSQLState, org.postgresql.xml.DefaultPGXmlFactoryFactory, .PGXmlFactoryFactory, org.checkerframework.checker.nullness.qual.Nullable, org.xml.sax.InputSource, .XMLReader, java.io.ByteArrayInputStream, .ByteArrayOutputStream, .IOException, .InputStream, .OutputStream, .Reader, .StringReader, .StringWriter, .Writer, java.sql.SQLException, .SQLXML, javax.xml.parsers.DocumentBuilder, javax.xml.stream.XMLInputFactory, .XMLOutputFactory, .XMLStreamException, .XMLStreamReader, .XMLStreamWriter, javax.xml.transform.Result, .Source, .Transformer, .TransformerException, .TransformerFactory, 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

Field Summary

Modifier and TypeField and Description
private boolean
private @Nullable ByteArrayOutputStream
private final BaseConnection
private @Nullable String
private @Nullable DOMResult
private boolean
private boolean
private final ResourceLock
private @Nullable StringWriter

Constructor Summary

AccessConstructor and Description
public
public
private
PgSQLXML(BaseConnection conn, @Nullable String data, boolean initialized)

Method Summary

Modifier and TypeMethod and Description
private void
private void
public void
free()

Implements java.sql.SQLXML.free.

This method closes this object and releases the resources that it held.

public @Nullable InputStream
getBinaryStream()

Implements java.sql.SQLXML.getBinaryStream.

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

public @Nullable Reader
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> @Nullable T
getSource(@Nullable 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 @Nullable String
getString()

Implements java.sql.SQLXML.getString.

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

private PGXmlFactoryFactory
private void
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 java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

activeback to summary
private boolean active
byteArrayOutputStreamback to summary
private @Nullable ByteArrayOutputStream byteArrayOutputStream
connback to summary
private final BaseConnection conn
databack to summary
private @Nullable String data
domResultback to summary
private @Nullable DOMResult domResult
freedback to summary
private boolean freed
initializedback to summary
private boolean initialized
lockback to summary
private final ResourceLock lock
stringWriterback to summary
private @Nullable StringWriter stringWriter

Constructor Detail

PgSQLXMLback to summary
public PgSQLXML(BaseConnection conn)
PgSQLXMLback to summary
public PgSQLXML(BaseConnection conn, @Nullable String data)
PgSQLXMLback to summary
private PgSQLXML(BaseConnection conn, @Nullable String data, boolean initialized)

Method Detail

checkFreedback to summary
private void checkFreed() throws SQLException
ensureInitializedback to summary
private void ensureInitialized() throws SQLException
freeback to summary
public void free()

Implements java.sql.SQLXML.free.

Doc from java.sql.SQLXML.free.

This method closes this object and releases the resources that it held. The SQL XML object becomes invalid and neither readable or writable when this method is called. After 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.

Annotations
@Override
getBinaryStreamback to summary
public @Nullable InputStream getBinaryStream() throws SQLException

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:@Nullable 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 @Nullable Reader getCharacterStream() throws SQLException

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:@Nullable 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> @Nullable T getSource(@Nullable 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:@Nullable 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:@Nullable T

a Source for reading the XML value.

Annotations
@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 @Nullable 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:@Nullable 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.
getXmlFactoryFactoryback to summary
private PGXmlFactoryFactory getXmlFactoryFactory() throws SQLException
initializeback to summary
private void initialize() throws SQLException
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
@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.