jdk.internal.util.xml.XMLStreamException Java Examples

The following examples show how to use jdk.internal.util.xml.XMLStreamException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XMLStreamWriterImpl.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public XMLStreamWriterImpl(OutputStream os, String encoding)
    throws XMLStreamException
{
    Charset cs = null;
    if (encoding == null) {
        _encoding = XMLStreamWriter.DEFAULT_ENCODING;
    } else {
        try {
            cs = getCharset(encoding);
        } catch (UnsupportedEncodingException e) {
            throw new XMLStreamException(e);
        }

        this._encoding = encoding;
    }

    _writer = new XMLWriter(os, encoding, cs);
}
 
Example #2
Source File: XMLStreamWriterImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public XMLStreamWriterImpl(OutputStream os, String encoding)
    throws XMLStreamException
{
    Charset cs = null;
    if (encoding == null) {
        _encoding = XMLStreamWriter.DEFAULT_ENCODING;
    } else {
        try {
            cs = getCharset(encoding);
        } catch (UnsupportedEncodingException e) {
            throw new XMLStreamException(e);
        }

        this._encoding = encoding;
    }

    _writer = new XMLWriter(os, encoding, cs);
}
 
Example #3
Source File: XMLStreamWriterImpl.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public void writeEndElement() throws XMLStreamException {
    if (_currentEle != null && _currentEle.getState() == ELEMENT_STARTTAG_OPEN) {
        closeStartTag();
    }

    if (_currentEle == null) {
        throw new XMLStreamException("No element was found to write");
    }

    if (_currentEle.isEmpty()) {
        return;
    }

    _writer.write(OPEN_END_TAG);
    _writer.write(_currentEle.getLocalName());
    _writer.write(CLOSE_END_TAG);
    writeLineSeparator();

    _currentEle = _currentEle.getParent();
}
 
Example #4
Source File: XMLStreamWriterImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void writeEndElement() throws XMLStreamException {
    if (_currentEle != null && _currentEle.getState() == ELEMENT_STARTTAG_OPEN) {
        closeStartTag();
    }

    if (_currentEle == null) {
        throw new XMLStreamException("No element was found to write");
    }

    if (_currentEle.isEmpty()) {
        return;
    }

    _writer.write(OPEN_END_TAG);
    _writer.write(_currentEle.getLocalName());
    _writer.write(CLOSE_END_TAG);
    writeLineSeparator();

    _currentEle = _currentEle.getParent();
}
 
Example #5
Source File: XMLStreamWriterImpl.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Writes a start tag to the output.
 * @param localName local name of the tag, may not be null
 * @throws XMLStreamException
 */
public void writeStartElement(String localName) throws XMLStreamException {
    if (localName == null || localName.length() == 0) {
        throw new XMLStreamException("Local Name cannot be null or empty");
    }

    _state = STATE_ELEMENT;
    if (_currentEle != null && _currentEle.getState() == ELEMENT_STARTTAG_OPEN) {
        closeStartTag();
    }

    _currentEle = new Element(_currentEle, localName, false);
    openStartTag();

    _writer.write(localName);
}
 
Example #6
Source File: XMLStreamWriterImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void writeEndDocument() throws XMLStreamException {
    if (_currentEle != null && _currentEle.getState() == ELEMENT_STARTTAG_OPEN) {
        closeStartTag();
    }

    /**
     * close unclosed elements if any
     */
    while (_currentEle != null) {

        if (!_currentEle.isEmpty()) {
            _writer.write(OPEN_END_TAG);
            _writer.write(_currentEle.getLocalName());
            _writer.write(CLOSE_END_TAG);
        }

        _currentEle = _currentEle.getParent();
    }
}
 
Example #7
Source File: XMLStreamWriterImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void writeEndDocument() throws XMLStreamException {
    if (_currentEle != null && _currentEle.getState() == ELEMENT_STARTTAG_OPEN) {
        closeStartTag();
    }

    /**
     * close unclosed elements if any
     */
    while (_currentEle != null) {

        if (!_currentEle.isEmpty()) {
            _writer.write(OPEN_END_TAG);
            _writer.write(_currentEle.getLocalName());
            _writer.write(CLOSE_END_TAG);
        }

        _currentEle = _currentEle.getParent();
    }
}
 
Example #8
Source File: XMLStreamWriterImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * marks close of start tag and writes the same into the writer.
 */
private void closeStartTag() throws XMLStreamException {
    if (_currentEle.isEmpty()) {
        _writer.write(CLOSE_EMPTY_ELEMENT);
    } else {
        _writer.write(CLOSE_START_TAG);

    }

    if (_currentEle.getParent() == null) {
        writeLineSeparator();
    }

    _currentEle.setState(ELEMENT_STARTTAG_CLOSE);

}
 
Example #9
Source File: XMLStreamWriterImpl.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public void writeEndDocument() throws XMLStreamException {
    if (_currentEle != null && _currentEle.getState() == ELEMENT_STARTTAG_OPEN) {
        closeStartTag();
    }

    /**
     * close unclosed elements if any
     */
    while (_currentEle != null) {

        if (!_currentEle.isEmpty()) {
            _writer.write(OPEN_END_TAG);
            _writer.write(_currentEle.getLocalName());
            _writer.write(CLOSE_END_TAG);
        }

        _currentEle = _currentEle.getParent();
    }
}
 
Example #10
Source File: XMLStreamWriterImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Writes an attribute to the output stream without a prefix.
 * @param localName the local name of the attribute
 * @param value the value of the attribute
 * @throws IllegalStateException if the current state does not allow Attribute writing
 * @throws XMLStreamException
 */
public void writeAttribute(String localName, String value) throws XMLStreamException {
    if (_currentEle.getState() != ELEMENT_STARTTAG_OPEN) {
        throw new XMLStreamException(
                "Attribute not associated with any element");
    }

    _writer.write(SPACE);
    _writer.write(localName);
    _writer.write("=\"");
    writeXMLContent(
            value,
            true, // true = escapeChars
            true);  // true = escapeDoubleQuotes
    _writer.write(DOUBLEQUOT);
}
 
Example #11
Source File: XMLStreamWriterImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Writes a start tag to the output.
 * @param localName local name of the tag, may not be null
 * @throws XMLStreamException
 */
public void writeStartElement(String localName) throws XMLStreamException {
    if (localName == null || localName.length() == 0) {
        throw new XMLStreamException("Local Name cannot be null or empty");
    }

    _state = STATE_ELEMENT;
    if (_currentEle != null && _currentEle.getState() == ELEMENT_STARTTAG_OPEN) {
        closeStartTag();
    }

    _currentEle = new Element(_currentEle, localName, false);
    openStartTag();

    _writer.write(localName);
}
 
Example #12
Source File: XMLStreamWriterImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void writeEndElement() throws XMLStreamException {
    if (_currentEle != null && _currentEle.getState() == ELEMENT_STARTTAG_OPEN) {
        closeStartTag();
    }

    if (_currentEle == null) {
        throw new XMLStreamException("No element was found to write");
    }

    if (_currentEle.isEmpty()) {
        return;
    }

    _writer.write(OPEN_END_TAG);
    _writer.write(_currentEle.getLocalName());
    _writer.write(CLOSE_END_TAG);
    writeLineSeparator();

    _currentEle = _currentEle.getParent();
}
 
Example #13
Source File: XMLStreamWriterImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Writes a start tag to the output.
 * @param localName local name of the tag, may not be null
 * @throws XMLStreamException
 */
public void writeStartElement(String localName) throws XMLStreamException {
    if (localName == null || localName.length() == 0) {
        throw new XMLStreamException("Local Name cannot be null or empty");
    }

    _state = STATE_ELEMENT;
    if (_currentEle != null && _currentEle.getState() == ELEMENT_STARTTAG_OPEN) {
        closeStartTag();
    }

    _currentEle = new Element(_currentEle, localName, false);
    openStartTag();

    _writer.write(localName);
}
 
Example #14
Source File: XMLStreamWriterImpl.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * marks close of start tag and writes the same into the writer.
 */
private void closeStartTag() throws XMLStreamException {
    if (_currentEle.isEmpty()) {
        _writer.write(CLOSE_EMPTY_ELEMENT);
    } else {
        _writer.write(CLOSE_START_TAG);

    }

    if (_currentEle.getParent() == null) {
        writeLineSeparator();
    }

    _currentEle.setState(ELEMENT_STARTTAG_CLOSE);

}
 
Example #15
Source File: XMLStreamWriterImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Writes an attribute to the output stream without a prefix.
 * @param localName the local name of the attribute
 * @param value the value of the attribute
 * @throws IllegalStateException if the current state does not allow Attribute writing
 * @throws XMLStreamException
 */
public void writeAttribute(String localName, String value) throws XMLStreamException {
    if (_currentEle.getState() != ELEMENT_STARTTAG_OPEN) {
        throw new XMLStreamException(
                "Attribute not associated with any element");
    }

    _writer.write(SPACE);
    _writer.write(localName);
    _writer.write("=\"");
    writeXMLContent(
            value,
            true, // true = escapeChars
            true);  // true = escapeDoubleQuotes
    _writer.write(DOUBLEQUOT);
}
 
Example #16
Source File: XMLStreamWriterImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * marks close of start tag and writes the same into the writer.
 */
private void closeStartTag() throws XMLStreamException {
    if (_currentEle.isEmpty()) {
        _writer.write(CLOSE_EMPTY_ELEMENT);
    } else {
        _writer.write(CLOSE_START_TAG);

    }

    if (_currentEle.getParent() == null) {
        writeLineSeparator();
    }

    _currentEle.setState(ELEMENT_STARTTAG_CLOSE);

}
 
Example #17
Source File: XMLStreamWriterImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void writeEndElement() throws XMLStreamException {
    if (_currentEle != null && _currentEle.getState() == ELEMENT_STARTTAG_OPEN) {
        closeStartTag();
    }

    if (_currentEle == null) {
        throw new XMLStreamException("No element was found to write");
    }

    if (_currentEle.isEmpty()) {
        return;
    }

    _writer.write(OPEN_END_TAG);
    _writer.write(_currentEle.getLocalName());
    _writer.write(CLOSE_END_TAG);
    writeLineSeparator();

    _currentEle = _currentEle.getParent();
}
 
Example #18
Source File: XMLStreamWriterImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void writeEndDocument() throws XMLStreamException {
    if (_currentEle != null && _currentEle.getState() == ELEMENT_STARTTAG_OPEN) {
        closeStartTag();
    }

    /**
     * close unclosed elements if any
     */
    while (_currentEle != null) {

        if (!_currentEle.isEmpty()) {
            _writer.write(OPEN_END_TAG);
            _writer.write(_currentEle.getLocalName());
            _writer.write(CLOSE_END_TAG);
        }

        _currentEle = _currentEle.getParent();
    }
}
 
Example #19
Source File: XMLStreamWriterImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Writes an attribute to the output stream without a prefix.
 * @param localName the local name of the attribute
 * @param value the value of the attribute
 * @throws IllegalStateException if the current state does not allow Attribute writing
 * @throws XMLStreamException
 */
public void writeAttribute(String localName, String value) throws XMLStreamException {
    if (_currentEle.getState() != ELEMENT_STARTTAG_OPEN) {
        throw new XMLStreamException(
                "Attribute not associated with any element");
    }

    _writer.write(SPACE);
    _writer.write(localName);
    _writer.write("=\"");
    writeXMLContent(
            value,
            true, // true = escapeChars
            true);  // true = escapeDoubleQuotes
    _writer.write(DOUBLEQUOT);
}
 
Example #20
Source File: XMLStreamWriterImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public XMLStreamWriterImpl(OutputStream os, String encoding)
    throws XMLStreamException
{
    Charset cs = null;
    if (encoding == null) {
        _encoding = XMLStreamWriter.DEFAULT_ENCODING;
    } else {
        try {
            cs = getCharset(encoding);
        } catch (UnsupportedEncodingException e) {
            throw new XMLStreamException(e);
        }

        this._encoding = encoding;
    }

    _writer = new XMLWriter(os, encoding, cs);
}
 
Example #21
Source File: XMLWriter.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
void close() throws XMLStreamException {
    try {
        _writer.close();
    } catch (IOException ex) {
        throw new XMLStreamException(ex);
    }
}
 
Example #22
Source File: XMLWriter.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a writer for the specified encoding based on an output stream.
 *
 * @param output The output stream
 * @param encoding The encoding
 * @return A suitable writer
 * @throws UnsupportedEncodingException There is no convertor to support
 * this encoding
 */
private Writer getWriter(OutputStream output, String encoding, Charset cs)
    throws XMLStreamException, UnsupportedEncodingException
{
    if (cs != null) {
        return (new OutputStreamWriter(new BufferedOutputStream(output), cs));
    }

    return new OutputStreamWriter(new BufferedOutputStream(output), encoding);
}
 
Example #23
Source File: XMLWriter.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void write(String str, int off, int len)
        throws XMLStreamException {
    try {
        _writer.write(str, off, len);
    } catch (IOException e) {
        throw new XMLStreamException("I/O error", e);
    }

}
 
Example #24
Source File: XMLStreamWriterImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void writeCharacters(String data) throws XMLStreamException {
    if (_currentEle != null && _currentEle.getState() == ELEMENT_STARTTAG_OPEN) {
        closeStartTag();
    }

    writeXMLContent(data);
}
 
Example #25
Source File: XMLStreamWriterImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void writeCData(String cdata) throws XMLStreamException {
    if (cdata == null) {
        throw new XMLStreamException("cdata cannot be null");
    }

    if (_currentEle != null && _currentEle.getState() == ELEMENT_STARTTAG_OPEN) {
        closeStartTag();
    }

    _writer.write(START_CDATA);
    _writer.write(cdata);
    _writer.write(END_CDATA);
}
 
Example #26
Source File: XMLStreamWriterImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void writeCharacters(char[] data, int start, int len)
        throws XMLStreamException {
    if (_currentEle != null && _currentEle.getState() == ELEMENT_STARTTAG_OPEN) {
        closeStartTag();
    }

    writeXMLContent(data, start, len, _escapeCharacters);
}
 
Example #27
Source File: XMLStreamWriterImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Writes an empty element tag to the output
 * @param localName local name of the tag, may not be null
 * @throws XMLStreamException
 */
public void writeEmptyElement(String localName) throws XMLStreamException {
    if (_currentEle != null && _currentEle.getState() == ELEMENT_STARTTAG_OPEN) {
        closeStartTag();
    }

    _currentEle = new Element(_currentEle, localName, true);

    openStartTag();
    _writer.write(localName);
}
 
Example #28
Source File: XMLStreamWriterImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Close this XMLStreamWriter by closing underlying writer.
 */
public void close() throws XMLStreamException {
    if (_writer != null) {
        _writer.close();
    }
    _writer = null;
    _currentEle = null;
    _state = 0;
}
 
Example #29
Source File: XMLStreamWriterImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Write a DTD section.  This string represents the entire doctypedecl production
 * from the XML 1.0 specification.
 *
 * @param dtd the DTD to be written
 * @throws XMLStreamException
 */
public void writeDTD(String dtd) throws XMLStreamException {
    if (_currentEle != null && _currentEle.getState() == ELEMENT_STARTTAG_OPEN) {
        closeStartTag();
    }
    _writer.write(dtd);
    writeLineSeparator();
}
 
Example #30
Source File: XMLWriter.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
void close() throws XMLStreamException {
    try {
        _writer.close();
    } catch (IOException ex) {
        throw new XMLStreamException(ex);
    }
}