Top Inners Fields Constructors Methods
com.mysql.cj.jdbc

public Class MysqlSQLXML

extends Object
implements SQLXML
Class Inheritance
All Implemented Interfaces
java.sql.SQLXML
Imports
java.io.ByteArrayInputStream, .ByteArrayOutputStream, .IOException, .InputStream, .OutputStream, .Reader, .StringReader, .StringWriter, .UnsupportedEncodingException, .Writer, java.sql.SQLException, .SQLXML, java.util.concurrent.locks.Lock, .ReentrantLock, javax.xml.XMLConstants, javax.xml.parsers.DocumentBuilder, .DocumentBuilderFactory, javax.xml.stream.XMLInputFactory, .XMLOutputFactory, .XMLStreamConstants, .XMLStreamException, .XMLStreamReader, javax.xml.transform.Result, .Source, .Transformer, .TransformerFactory, javax.xml.transform.dom.DOMResult, .DOMSource, javax.xml.transform.sax.SAXResult, .SAXSource, javax.xml.transform.stax.StAXResult, .StAXSource, javax.xml.transform.stream.StreamResult, .StreamSource, org.xml.sax.Attributes, .InputSource, .SAXException, .XMLReader, org.xml.sax.helpers.DefaultHandler, .XMLReaderFactory, com.mysql.cj.Messages, com.mysql.cj.exceptions.ExceptionInterceptor, .MysqlErrorNumbers, com.mysql.cj.jdbc.exceptions.SQLError, com.mysql.cj.jdbc.result.ResultSetInternalMethods

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class

Field Summary

Modifier and TypeField and Description
private ByteArrayOutputStream
private DOMResult
private SAXResult
private StringWriter
private int
private ExceptionInterceptor
private boolean
private XMLInputFactory
private boolean
private final Lock
private XMLOutputFactory
private ResultSetInternalMethods
private MysqlSQLXML.SimpleSaxToReader
private String
private boolean

Constructor Summary

AccessConstructor and Description
public
MysqlSQLXML(ResultSetInternalMethods owner, int index, ExceptionInterceptor exceptionInterceptor)

public
MysqlSQLXML(ExceptionInterceptor exceptionInterceptor)

Method Summary

Modifier and TypeMethod and Description
private Reader
private void
private void
protected String
public void
free()

Implements java.sql.SQLXML.free.

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

public InputStream
getBinaryStream()

Implements java.sql.SQLXML.getBinaryStream.

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

public 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> 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
clazz
)

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 boolean
protected String
protected Reader
protected String
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.

private OutputStream
public Writer
setCharacterStream()

Implements java.sql.SQLXML.setCharacterStream.

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

private Writer
private static void
setFeature(Object factory, String name, boolean value)

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
clazz
)

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
str
)

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

asByteArrayOutputStreamback to summary
private ByteArrayOutputStream asByteArrayOutputStream
asDOMResultback to summary
private DOMResult asDOMResult
asSAXResultback to summary
private SAXResult asSAXResult
asStringWriterback to summary
private StringWriter asStringWriter
columnIndexOfXmlback to summary
private int columnIndexOfXml
exceptionInterceptorback to summary
private ExceptionInterceptor exceptionInterceptor
fromResultSetback to summary
private boolean fromResultSet
inputFactoryback to summary
private XMLInputFactory inputFactory
isClosedback to summary
private boolean isClosed
lockback to summary
private final Lock lock
outputFactoryback to summary
private XMLOutputFactory outputFactory
owningResultSetback to summary
private ResultSetInternalMethods owningResultSet
saxToReaderConverterback to summary
private MysqlSQLXML.SimpleSaxToReader saxToReaderConverter
stringRepback to summary
private String stringRep
workingWithResultback to summary
private boolean workingWithResult

Constructor Detail

MysqlSQLXMLback to summary
public MysqlSQLXML(ResultSetInternalMethods owner, int index, ExceptionInterceptor exceptionInterceptor)
MysqlSQLXMLback to summary
public MysqlSQLXML(ExceptionInterceptor exceptionInterceptor)

Method Detail

binaryInputStreamStreamToReaderback to summary
private Reader binaryInputStreamStreamToReader(ByteArrayOutputStream out)
checkClosedback to summary
private void checkClosed() throws SQLException
checkWorkingWithResultback to summary
private void checkWorkingWithResult() throws SQLException
domSourceToStringback to summary
protected String domSourceToString() throws SQLException
freeback to summary
public void free() throws SQLException

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
Exceptions
SQLException:
if there is an error freeing the XML value.
getBinaryStreamback to summary
public 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: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

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> clazz) 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
clazz: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.
isEmptyback to summary
public boolean isEmpty() throws SQLException
readerToStringback to summary
protected String readerToString(Reader reader) throws SQLException
serializeAsCharacterStreamback to summary
protected Reader serializeAsCharacterStream() throws SQLException
serializeAsStringback to summary
protected String serializeAsString() 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.
setBinaryStreamInternalback to summary
private OutputStream setBinaryStreamInternal() throws SQLException
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.
setCharacterStreamInternalback to summary
private Writer setCharacterStreamInternal() throws SQLException
setFeatureback to summary
private static void setFeature(Object factory, String name, boolean value)
setResultback to summary
public <T extends Result> T setResult(Class<T> clazz) 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
clazz: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 str) 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
str: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.
com.mysql.cj.jdbc back to summary

pack-priv Class MysqlSQLXML.SimpleSaxToReader

extends DefaultHandler
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv StringBuilder
private boolean

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
characters(char[]
The characters.
buffer
,
int
The start position in the character array.
offset
,
int
The number of characters to use from the character array.
len
)

Overrides org.xml.sax.helpers.DefaultHandler.characters.

Implements org.xml.sax.ContentHandler.characters.

Receive notification of character data inside an element.

public void
comment(char[] ch, int start, int length)

public void
public void
endDocument()

Overrides org.xml.sax.helpers.DefaultHandler.endDocument.

Implements org.xml.sax.ContentHandler.endDocument.

Receive notification of the end of the document.

private void
escapeCharsForXml(String str, boolean isAttributeData)

private void
escapeCharsForXml(char[] buffer, int offset, int len, boolean isAttributeData)

private void
escapeCharsForXml(char c, boolean isAttributeData)

public void
ignorableWhitespace(char[]
The whitespace characters.
ch
,
int
The start position in the character array.
start
,
int
The number of characters to use from the character array.
length
)

Overrides org.xml.sax.helpers.DefaultHandler.ignorableWhitespace.

Implements org.xml.sax.ContentHandler.ignorableWhitespace.

Receive notification of ignorable whitespace in element content.

public void
public void
startDocument()

Overrides org.xml.sax.helpers.DefaultHandler.startDocument.

Implements org.xml.sax.ContentHandler.startDocument.

Receive notification of the beginning of the document.

public void
startElement(String
The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
namespaceURI
,
String
The local name (without prefix), or the empty string if Namespace processing is not being performed.
sName
,
String
The qualified name (with prefix), or the empty string if qualified names are not available.
qName
,
Attributes
The attributes attached to the element. If there are no attributes, it shall be an empty Attributes object.
attrs
)

Overrides org.xml.sax.helpers.DefaultHandler.startElement.

Implements org.xml.sax.ContentHandler.startElement.

Receive notification of the start of an element.

pack-priv Reader
Inherited from org.xml.sax.helpers.DefaultHandler:
endElementendPrefixMappingerrorfatalErrornotationDeclprocessingInstructionresolveEntitysetDocumentLocatorskippedEntitystartPrefixMappingunparsedEntityDeclwarning

Field Detail

bufback to summary
pack-priv StringBuilder buf
inCDATAback to summary
private boolean inCDATA

Constructor Detail

SimpleSaxToReaderback to summary
pack-priv SimpleSaxToReader()

Method Detail

charactersback to summary
public void characters(char[] buffer, int offset, int len) throws SAXException

Overrides org.xml.sax.helpers.DefaultHandler.characters.

Implements org.xml.sax.ContentHandler.characters.

Doc from org.xml.sax.helpers.DefaultHandler.characters.

Receive notification of character data inside an element.

By default, do nothing. Application writers may override this method to take specific actions for each chunk of character data (such as adding the data to a node or buffer, or printing it to a file).

Parameters
buffer:char[]

The characters.

offset:int

The start position in the character array.

len:int

The number of characters to use from the character array.

Annotations
@Override
Exceptions
SAXException:
Any SAX exception, possibly wrapping another exception.
commentback to summary
public void comment(char[] ch, int start, int length) throws SAXException
endCDATAback to summary
public void endCDATA() throws SAXException
endDocumentback to summary
public void endDocument() throws SAXException

Overrides org.xml.sax.helpers.DefaultHandler.endDocument.

Implements org.xml.sax.ContentHandler.endDocument.

Doc from org.xml.sax.helpers.DefaultHandler.endDocument.

Receive notification of the end of the document.

By default, do nothing. Application writers may override this method in a subclass to take specific actions at the end of a document (such as finalising a tree or closing an output file).

Annotations
@Override
Exceptions
SAXException:
Any SAX exception, possibly wrapping another exception.
escapeCharsForXmlback to summary
private void escapeCharsForXml(String str, boolean isAttributeData)
escapeCharsForXmlback to summary
private void escapeCharsForXml(char[] buffer, int offset, int len, boolean isAttributeData)
escapeCharsForXmlback to summary
private void escapeCharsForXml(char c, boolean isAttributeData)
ignorableWhitespaceback to summary
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException

Overrides org.xml.sax.helpers.DefaultHandler.ignorableWhitespace.

Implements org.xml.sax.ContentHandler.ignorableWhitespace.

Doc from org.xml.sax.helpers.DefaultHandler.ignorableWhitespace.

Receive notification of ignorable whitespace in element content.

By default, do nothing. Application writers may override this method to take specific actions for each chunk of ignorable whitespace (such as adding data to a node or buffer, or printing it to a file).

Parameters
ch:char[]

The whitespace characters.

start:int

The start position in the character array.

length:int

The number of characters to use from the character array.

Annotations
@Override
Exceptions
SAXException:
Any SAX exception, possibly wrapping another exception.
startCDATAback to summary
public void startCDATA() throws SAXException
startDocumentback to summary
public void startDocument() throws SAXException

Overrides org.xml.sax.helpers.DefaultHandler.startDocument.

Implements org.xml.sax.ContentHandler.startDocument.

Doc from org.xml.sax.helpers.DefaultHandler.startDocument.

Receive notification of the beginning of the document.

By default, do nothing. Application writers may override this method in a subclass to take specific actions at the beginning of a document (such as allocating the root node of a tree or creating an output file).

Annotations
@Override
Exceptions
SAXException:
Any SAX exception, possibly wrapping another exception.
startElementback to summary
public void startElement(String namespaceURI, String sName, String qName, Attributes attrs) throws SAXException

Overrides org.xml.sax.helpers.DefaultHandler.startElement.

Implements org.xml.sax.ContentHandler.startElement.

Doc from org.xml.sax.helpers.DefaultHandler.startElement.

Receive notification of the start of an element.

By default, do nothing. Application writers may override this method in a subclass to take specific actions at the start of each element (such as allocating a new tree node or writing output to a file).

Parameters
namespaceURI:String

The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.

sName:String

The local name (without prefix), or the empty string if Namespace processing is not being performed.

qName:String

The qualified name (with prefix), or the empty string if qualified names are not available.

attrs:Attributes

The attributes attached to the element. If there are no attributes, it shall be an empty Attributes object.

Annotations
@Override
Exceptions
SAXException:
Any SAX exception, possibly wrapping another exception.
toReaderback to summary
pack-priv Reader toReader()