Java Code Examples for com.sun.xml.internal.fastinfoset.EncodingConstants#ELEMENT

The following examples show how to use com.sun.xml.internal.fastinfoset.EncodingConstants#ELEMENT . 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: FastInfosetStreamWriterOutput.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void beginStartTag(int prefix, String localName) throws IOException {
    fiout.writeLowLevelTerminationAndMark();

    int type = EncodingConstants.ELEMENT;
    if (nsContext.getCurrent().count() > 0) {
        final NamespaceContextImpl.Element nse = nsContext.getCurrent();

        fiout.writeLowLevelStartNamespaces();
        for (int i = nse.count() - 1; i >= 0; i--) {
            final String uri = nse.getNsUri(i);
            if (uri.length() == 0 && nse.getBase() == 1)
                continue;   // no point in definint xmlns='' on the root
            fiout.writeLowLevelNamespace(nse.getPrefix(i), uri);
        }
        fiout.writeLowLevelEndNamespaces();

        type= 0;
    }

    final boolean isIndexed = fiout.writeLowLevelStartElement(
            type,
            nsContext.getPrefix(prefix),
            localName,
            nsContext.getNamespaceURI(prefix));

    if (!isIndexed)
        tables.incrementMaxIndexValue();
}
 
Example 2
Source File: FastInfosetStreamWriterOutput.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void beginStartTag(int prefix, String localName) throws IOException {
    fiout.writeLowLevelTerminationAndMark();

    int type = EncodingConstants.ELEMENT;
    if (nsContext.getCurrent().count() > 0) {
        final NamespaceContextImpl.Element nse = nsContext.getCurrent();

        fiout.writeLowLevelStartNamespaces();
        for (int i = nse.count() - 1; i >= 0; i--) {
            final String uri = nse.getNsUri(i);
            if (uri.length() == 0 && nse.getBase() == 1)
                continue;   // no point in definint xmlns='' on the root
            fiout.writeLowLevelNamespace(nse.getPrefix(i), uri);
        }
        fiout.writeLowLevelEndNamespaces();

        type= 0;
    }

    final boolean isIndexed = fiout.writeLowLevelStartElement(
            type,
            nsContext.getPrefix(prefix),
            localName,
            nsContext.getNamespaceURI(prefix));

    if (!isIndexed)
        tables.incrementMaxIndexValue();
}
 
Example 3
Source File: FastInfosetStreamWriterOutput.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void beginStartTag(int prefix, String localName) throws IOException {
    fiout.writeLowLevelTerminationAndMark();

    int type = EncodingConstants.ELEMENT;
    if (nsContext.getCurrent().count() > 0) {
        final NamespaceContextImpl.Element nse = nsContext.getCurrent();

        fiout.writeLowLevelStartNamespaces();
        for (int i = nse.count() - 1; i >= 0; i--) {
            final String uri = nse.getNsUri(i);
            if (uri.length() == 0 && nse.getBase() == 1)
                continue;   // no point in definint xmlns='' on the root
            fiout.writeLowLevelNamespace(nse.getPrefix(i), uri);
        }
        fiout.writeLowLevelEndNamespaces();

        type= 0;
    }

    final boolean isIndexed = fiout.writeLowLevelStartElement(
            type,
            nsContext.getPrefix(prefix),
            localName,
            nsContext.getNamespaceURI(prefix));

    if (!isIndexed)
        tables.incrementMaxIndexValue();
}
 
Example 4
Source File: FastInfosetStreamWriterOutput.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void beginStartTag(int prefix, String localName) throws IOException {
    fiout.writeLowLevelTerminationAndMark();

    int type = EncodingConstants.ELEMENT;
    if (nsContext.getCurrent().count() > 0) {
        final NamespaceContextImpl.Element nse = nsContext.getCurrent();

        fiout.writeLowLevelStartNamespaces();
        for (int i = nse.count() - 1; i >= 0; i--) {
            final String uri = nse.getNsUri(i);
            if (uri.length() == 0 && nse.getBase() == 1)
                continue;   // no point in definint xmlns='' on the root
            fiout.writeLowLevelNamespace(nse.getPrefix(i), uri);
        }
        fiout.writeLowLevelEndNamespaces();

        type= 0;
    }

    final boolean isIndexed = fiout.writeLowLevelStartElement(
            type,
            nsContext.getPrefix(prefix),
            localName,
            nsContext.getNamespaceURI(prefix));

    if (!isIndexed)
        tables.incrementMaxIndexValue();
}
 
Example 5
Source File: FastInfosetStreamWriterOutput.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void beginStartTag(int prefix, String localName) throws IOException {
    fiout.writeLowLevelTerminationAndMark();

    int type = EncodingConstants.ELEMENT;
    if (nsContext.getCurrent().count() > 0) {
        final NamespaceContextImpl.Element nse = nsContext.getCurrent();

        fiout.writeLowLevelStartNamespaces();
        for (int i = nse.count() - 1; i >= 0; i--) {
            final String uri = nse.getNsUri(i);
            if (uri.length() == 0 && nse.getBase() == 1)
                continue;   // no point in definint xmlns='' on the root
            fiout.writeLowLevelNamespace(nse.getPrefix(i), uri);
        }
        fiout.writeLowLevelEndNamespaces();

        type= 0;
    }

    final boolean isIndexed = fiout.writeLowLevelStartElement(
            type,
            nsContext.getPrefix(prefix),
            localName,
            nsContext.getNamespaceURI(prefix));

    if (!isIndexed)
        tables.incrementMaxIndexValue();
}
 
Example 6
Source File: FastInfosetStreamWriterOutput.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void beginStartTag(int prefix, String localName) throws IOException {
    fiout.writeLowLevelTerminationAndMark();

    int type = EncodingConstants.ELEMENT;
    if (nsContext.getCurrent().count() > 0) {
        final NamespaceContextImpl.Element nse = nsContext.getCurrent();

        fiout.writeLowLevelStartNamespaces();
        for (int i = nse.count() - 1; i >= 0; i--) {
            final String uri = nse.getNsUri(i);
            if (uri.length() == 0 && nse.getBase() == 1)
                continue;   // no point in definint xmlns='' on the root
            fiout.writeLowLevelNamespace(nse.getPrefix(i), uri);
        }
        fiout.writeLowLevelEndNamespaces();

        type= 0;
    }

    final boolean isIndexed = fiout.writeLowLevelStartElement(
            type,
            nsContext.getPrefix(prefix),
            localName,
            nsContext.getNamespaceURI(prefix));

    if (!isIndexed)
        tables.incrementMaxIndexValue();
}
 
Example 7
Source File: FastInfosetStreamWriterOutput.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void beginStartTag(int prefix, String localName) throws IOException {
    fiout.writeLowLevelTerminationAndMark();

    int type = EncodingConstants.ELEMENT;
    if (nsContext.getCurrent().count() > 0) {
        final NamespaceContextImpl.Element nse = nsContext.getCurrent();

        fiout.writeLowLevelStartNamespaces();
        for (int i = nse.count() - 1; i >= 0; i--) {
            final String uri = nse.getNsUri(i);
            if (uri.length() == 0 && nse.getBase() == 1)
                continue;   // no point in definint xmlns='' on the root
            fiout.writeLowLevelNamespace(nse.getPrefix(i), uri);
        }
        fiout.writeLowLevelEndNamespaces();

        type= 0;
    }

    final boolean isIndexed = fiout.writeLowLevelStartElement(
            type,
            nsContext.getPrefix(prefix),
            localName,
            nsContext.getNamespaceURI(prefix));

    if (!isIndexed)
        tables.incrementMaxIndexValue();
}
 
Example 8
Source File: FastInfosetStreamWriterOutput.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void beginStartTag(int prefix, String localName) throws IOException {
    fiout.writeLowLevelTerminationAndMark();

    int type = EncodingConstants.ELEMENT;
    if (nsContext.getCurrent().count() > 0) {
        final NamespaceContextImpl.Element nse = nsContext.getCurrent();

        fiout.writeLowLevelStartNamespaces();
        for (int i = nse.count() - 1; i >= 0; i--) {
            final String uri = nse.getNsUri(i);
            if (uri.length() == 0 && nse.getBase() == 1)
                continue;   // no point in definint xmlns='' on the root
            fiout.writeLowLevelNamespace(nse.getPrefix(i), uri);
        }
        fiout.writeLowLevelEndNamespaces();

        type= 0;
    }

    final boolean isIndexed = fiout.writeLowLevelStartElement(
            type,
            nsContext.getPrefix(prefix),
            localName,
            nsContext.getNamespaceURI(prefix));

    if (!isIndexed)
        tables.incrementMaxIndexValue();
}
 
Example 9
Source File: StAXDocumentSerializer.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
protected void encodeTerminationAndCurrentElement(boolean terminateAfter) throws XMLStreamException {
    try {
        encodeTermination();

        if (_inStartElement) {

            _b = EncodingConstants.ELEMENT;
            if (_attributesArrayIndex > 0) {
                _b |= EncodingConstants.ELEMENT_ATTRIBUTE_FLAG;
            }

            // Encode namespace decls associated with this element
            if (_namespacesArrayIndex > 0) {
                write(_b | EncodingConstants.ELEMENT_NAMESPACES_FLAG);
                for (int i = 0; i < _namespacesArrayIndex;) {
                    encodeNamespaceAttribute(_namespacesArray[i++], _namespacesArray[i++]);
                }
                _namespacesArrayIndex = 0;

                write(EncodingConstants.TERMINATOR);

                _b = 0;
            }

            // If element's prefix is empty - apply default scope namespace
            if (_currentPrefix.length() == 0) {
                if (_currentUri.length() == 0) {
                    _currentUri = _nsContext.getNamespaceURI("");
                } else {
                    String tmpPrefix = getPrefix(_currentUri);
                    if (tmpPrefix != null) {
                        _currentPrefix = tmpPrefix;
                    }
                }
            }

            encodeElementQualifiedNameOnThirdBit(_currentUri, _currentPrefix, _currentLocalName);

            for (int i = 0; i < _attributesArrayIndex;) {
                encodeAttributeQualifiedNameOnSecondBit(
                        _attributesArray[i++], _attributesArray[i++], _attributesArray[i++]);

                final String value = _attributesArray[i];
                _attributesArray[i++] = null;
                final boolean addToTable = isAttributeValueLengthMatchesLimit(value.length());
                encodeNonIdentifyingStringOnFirstBit(value, _v.attributeValue, addToTable, false);

                _b = EncodingConstants.TERMINATOR;
                _terminate = true;
            }
            _attributesArrayIndex = 0;
            _inStartElement = false;

            if (_isEmptyElement) {
                encodeElementTermination();
                if (_nsSupportContextStack[_stackCount--] == true) {
                    _nsContext.popContext();
                }

                _isEmptyElement = false;
            }

            if (terminateAfter) {
                encodeTermination();
            }
        }
    } catch (IOException e) {
        throw new XMLStreamException(e);
    }
}
 
Example 10
Source File: StAXDocumentSerializer.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
protected void encodeTerminationAndCurrentElement(boolean terminateAfter) throws XMLStreamException {
    try {
        encodeTermination();

        if (_inStartElement) {

            _b = EncodingConstants.ELEMENT;
            if (_attributesArrayIndex > 0) {
                _b |= EncodingConstants.ELEMENT_ATTRIBUTE_FLAG;
            }

            // Encode namespace decls associated with this element
            if (_namespacesArrayIndex > 0) {
                write(_b | EncodingConstants.ELEMENT_NAMESPACES_FLAG);
                for (int i = 0; i < _namespacesArrayIndex;) {
                    encodeNamespaceAttribute(_namespacesArray[i++], _namespacesArray[i++]);
                }
                _namespacesArrayIndex = 0;

                write(EncodingConstants.TERMINATOR);

                _b = 0;
            }

            // If element's prefix is empty - apply default scope namespace
            if (_currentPrefix.length() == 0) {
                if (_currentUri.length() == 0) {
                    _currentUri = _nsContext.getNamespaceURI("");
                } else {
                    String tmpPrefix = getPrefix(_currentUri);
                    if (tmpPrefix != null) {
                        _currentPrefix = tmpPrefix;
                    }
                }
            }

            encodeElementQualifiedNameOnThirdBit(_currentUri, _currentPrefix, _currentLocalName);

            for (int i = 0; i < _attributesArrayIndex;) {
                encodeAttributeQualifiedNameOnSecondBit(
                        _attributesArray[i++], _attributesArray[i++], _attributesArray[i++]);

                final String value = _attributesArray[i];
                _attributesArray[i++] = null;
                final boolean addToTable = isAttributeValueLengthMatchesLimit(value.length());
                encodeNonIdentifyingStringOnFirstBit(value, _v.attributeValue, addToTable, false);

                _b = EncodingConstants.TERMINATOR;
                _terminate = true;
            }
            _attributesArrayIndex = 0;
            _inStartElement = false;

            if (_isEmptyElement) {
                encodeElementTermination();
                if (_nsSupportContextStack[_stackCount--] == true) {
                    _nsContext.popContext();
                }

                _isEmptyElement = false;
            }

            if (terminateAfter) {
                encodeTermination();
            }
        }
    } catch (IOException e) {
        throw new XMLStreamException(e);
    }
}
 
Example 11
Source File: StAXDocumentSerializer.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
protected void encodeTerminationAndCurrentElement(boolean terminateAfter) throws XMLStreamException {
    try {
        encodeTermination();

        if (_inStartElement) {

            _b = EncodingConstants.ELEMENT;
            if (_attributesArrayIndex > 0) {
                _b |= EncodingConstants.ELEMENT_ATTRIBUTE_FLAG;
            }

            // Encode namespace decls associated with this element
            if (_namespacesArrayIndex > 0) {
                write(_b | EncodingConstants.ELEMENT_NAMESPACES_FLAG);
                for (int i = 0; i < _namespacesArrayIndex;) {
                    encodeNamespaceAttribute(_namespacesArray[i++], _namespacesArray[i++]);
                }
                _namespacesArrayIndex = 0;

                write(EncodingConstants.TERMINATOR);

                _b = 0;
            }

            // If element's prefix is empty - apply default scope namespace
            if (_currentPrefix.length() == 0) {
                if (_currentUri.length() == 0) {
                    _currentUri = _nsContext.getNamespaceURI("");
                } else {
                    String tmpPrefix = getPrefix(_currentUri);
                    if (tmpPrefix != null) {
                        _currentPrefix = tmpPrefix;
                    }
                }
            }

            encodeElementQualifiedNameOnThirdBit(_currentUri, _currentPrefix, _currentLocalName);

            for (int i = 0; i < _attributesArrayIndex;) {
                encodeAttributeQualifiedNameOnSecondBit(
                        _attributesArray[i++], _attributesArray[i++], _attributesArray[i++]);

                final String value = _attributesArray[i];
                _attributesArray[i++] = null;
                final boolean addToTable = isAttributeValueLengthMatchesLimit(value.length());
                encodeNonIdentifyingStringOnFirstBit(value, _v.attributeValue, addToTable, false);

                _b = EncodingConstants.TERMINATOR;
                _terminate = true;
            }
            _attributesArrayIndex = 0;
            _inStartElement = false;

            if (_isEmptyElement) {
                encodeElementTermination();
                if (_nsSupportContextStack[_stackCount--] == true) {
                    _nsContext.popContext();
                }

                _isEmptyElement = false;
            }

            if (terminateAfter) {
                encodeTermination();
            }
        }
    } catch (IOException e) {
        throw new XMLStreamException(e);
    }
}
 
Example 12
Source File: StAXDocumentSerializer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
protected void encodeTerminationAndCurrentElement(boolean terminateAfter) throws XMLStreamException {
    try {
        encodeTermination();

        if (_inStartElement) {

            _b = EncodingConstants.ELEMENT;
            if (_attributesArrayIndex > 0) {
                _b |= EncodingConstants.ELEMENT_ATTRIBUTE_FLAG;
            }

            // Encode namespace decls associated with this element
            if (_namespacesArrayIndex > 0) {
                write(_b | EncodingConstants.ELEMENT_NAMESPACES_FLAG);
                for (int i = 0; i < _namespacesArrayIndex;) {
                    encodeNamespaceAttribute(_namespacesArray[i++], _namespacesArray[i++]);
                }
                _namespacesArrayIndex = 0;

                write(EncodingConstants.TERMINATOR);

                _b = 0;
            }

            // If element's prefix is empty - apply default scope namespace
            if (_currentPrefix.length() == 0) {
                if (_currentUri.length() == 0) {
                    _currentUri = _nsContext.getNamespaceURI("");
                } else {
                    String tmpPrefix = getPrefix(_currentUri);
                    if (tmpPrefix != null) {
                        _currentPrefix = tmpPrefix;
                    }
                }
            }

            encodeElementQualifiedNameOnThirdBit(_currentUri, _currentPrefix, _currentLocalName);

            for (int i = 0; i < _attributesArrayIndex;) {
                encodeAttributeQualifiedNameOnSecondBit(
                        _attributesArray[i++], _attributesArray[i++], _attributesArray[i++]);

                final String value = _attributesArray[i];
                _attributesArray[i++] = null;
                final boolean addToTable = isAttributeValueLengthMatchesLimit(value.length());
                encodeNonIdentifyingStringOnFirstBit(value, _v.attributeValue, addToTable, false);

                _b = EncodingConstants.TERMINATOR;
                _terminate = true;
            }
            _attributesArrayIndex = 0;
            _inStartElement = false;

            if (_isEmptyElement) {
                encodeElementTermination();
                if (_nsSupportContextStack[_stackCount--] == true) {
                    _nsContext.popContext();
                }

                _isEmptyElement = false;
            }

            if (terminateAfter) {
                encodeTermination();
            }
        }
    } catch (IOException e) {
        throw new XMLStreamException(e);
    }
}
 
Example 13
Source File: StAXDocumentSerializer.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
protected void encodeTerminationAndCurrentElement(boolean terminateAfter) throws XMLStreamException {
    try {
        encodeTermination();

        if (_inStartElement) {

            _b = EncodingConstants.ELEMENT;
            if (_attributesArrayIndex > 0) {
                _b |= EncodingConstants.ELEMENT_ATTRIBUTE_FLAG;
            }

            // Encode namespace decls associated with this element
            if (_namespacesArrayIndex > 0) {
                write(_b | EncodingConstants.ELEMENT_NAMESPACES_FLAG);
                for (int i = 0; i < _namespacesArrayIndex;) {
                    encodeNamespaceAttribute(_namespacesArray[i++], _namespacesArray[i++]);
                }
                _namespacesArrayIndex = 0;

                write(EncodingConstants.TERMINATOR);

                _b = 0;
            }

            // If element's prefix is empty - apply default scope namespace
            if (_currentPrefix.length() == 0) {
                if (_currentUri.length() == 0) {
                    _currentUri = _nsContext.getNamespaceURI("");
                } else {
                    String tmpPrefix = getPrefix(_currentUri);
                    if (tmpPrefix != null) {
                        _currentPrefix = tmpPrefix;
                    }
                }
            }

            encodeElementQualifiedNameOnThirdBit(_currentUri, _currentPrefix, _currentLocalName);

            for (int i = 0; i < _attributesArrayIndex;) {
                encodeAttributeQualifiedNameOnSecondBit(
                        _attributesArray[i++], _attributesArray[i++], _attributesArray[i++]);

                final String value = _attributesArray[i];
                _attributesArray[i++] = null;
                final boolean addToTable = isAttributeValueLengthMatchesLimit(value.length());
                encodeNonIdentifyingStringOnFirstBit(value, _v.attributeValue, addToTable, false);

                _b = EncodingConstants.TERMINATOR;
                _terminate = true;
            }
            _attributesArrayIndex = 0;
            _inStartElement = false;

            if (_isEmptyElement) {
                encodeElementTermination();
                if (_nsSupportContextStack[_stackCount--] == true) {
                    _nsContext.popContext();
                }

                _isEmptyElement = false;
            }

            if (terminateAfter) {
                encodeTermination();
            }
        }
    } catch (IOException e) {
        throw new XMLStreamException(e);
    }
}
 
Example 14
Source File: StAXDocumentSerializer.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
protected void encodeTerminationAndCurrentElement(boolean terminateAfter) throws XMLStreamException {
    try {
        encodeTermination();

        if (_inStartElement) {

            _b = EncodingConstants.ELEMENT;
            if (_attributesArrayIndex > 0) {
                _b |= EncodingConstants.ELEMENT_ATTRIBUTE_FLAG;
            }

            // Encode namespace decls associated with this element
            if (_namespacesArrayIndex > 0) {
                write(_b | EncodingConstants.ELEMENT_NAMESPACES_FLAG);
                for (int i = 0; i < _namespacesArrayIndex;) {
                    encodeNamespaceAttribute(_namespacesArray[i++], _namespacesArray[i++]);
                }
                _namespacesArrayIndex = 0;

                write(EncodingConstants.TERMINATOR);

                _b = 0;
            }

            // If element's prefix is empty - apply default scope namespace
            if (_currentPrefix.length() == 0) {
                if (_currentUri.length() == 0) {
                    _currentUri = _nsContext.getNamespaceURI("");
                } else {
                    String tmpPrefix = getPrefix(_currentUri);
                    if (tmpPrefix != null) {
                        _currentPrefix = tmpPrefix;
                    }
                }
            }

            encodeElementQualifiedNameOnThirdBit(_currentUri, _currentPrefix, _currentLocalName);

            for (int i = 0; i < _attributesArrayIndex;) {
                encodeAttributeQualifiedNameOnSecondBit(
                        _attributesArray[i++], _attributesArray[i++], _attributesArray[i++]);

                final String value = _attributesArray[i];
                _attributesArray[i++] = null;
                final boolean addToTable = isAttributeValueLengthMatchesLimit(value.length());
                encodeNonIdentifyingStringOnFirstBit(value, _v.attributeValue, addToTable, false);

                _b = EncodingConstants.TERMINATOR;
                _terminate = true;
            }
            _attributesArrayIndex = 0;
            _inStartElement = false;

            if (_isEmptyElement) {
                encodeElementTermination();
                if (_nsSupportContextStack[_stackCount--] == true) {
                    _nsContext.popContext();
                }

                _isEmptyElement = false;
            }

            if (terminateAfter) {
                encodeTermination();
            }
        }
    } catch (IOException e) {
        throw new XMLStreamException(e);
    }
}
 
Example 15
Source File: StAXDocumentSerializer.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
protected void encodeTerminationAndCurrentElement(boolean terminateAfter) throws XMLStreamException {
    try {
        encodeTermination();

        if (_inStartElement) {

            _b = EncodingConstants.ELEMENT;
            if (_attributesArrayIndex > 0) {
                _b |= EncodingConstants.ELEMENT_ATTRIBUTE_FLAG;
            }

            // Encode namespace decls associated with this element
            if (_namespacesArrayIndex > 0) {
                write(_b | EncodingConstants.ELEMENT_NAMESPACES_FLAG);
                for (int i = 0; i < _namespacesArrayIndex;) {
                    encodeNamespaceAttribute(_namespacesArray[i++], _namespacesArray[i++]);
                }
                _namespacesArrayIndex = 0;

                write(EncodingConstants.TERMINATOR);

                _b = 0;
            }

            // If element's prefix is empty - apply default scope namespace
            if (_currentPrefix.length() == 0) {
                if (_currentUri.length() == 0) {
                    _currentUri = _nsContext.getNamespaceURI("");
                } else {
                    String tmpPrefix = getPrefix(_currentUri);
                    if (tmpPrefix != null) {
                        _currentPrefix = tmpPrefix;
                    }
                }
            }

            encodeElementQualifiedNameOnThirdBit(_currentUri, _currentPrefix, _currentLocalName);

            for (int i = 0; i < _attributesArrayIndex;) {
                encodeAttributeQualifiedNameOnSecondBit(
                        _attributesArray[i++], _attributesArray[i++], _attributesArray[i++]);

                final String value = _attributesArray[i];
                _attributesArray[i++] = null;
                final boolean addToTable = isAttributeValueLengthMatchesLimit(value.length());
                encodeNonIdentifyingStringOnFirstBit(value, _v.attributeValue, addToTable, false);

                _b = EncodingConstants.TERMINATOR;
                _terminate = true;
            }
            _attributesArrayIndex = 0;
            _inStartElement = false;

            if (_isEmptyElement) {
                encodeElementTermination();
                if (_nsSupportContextStack[_stackCount--] == true) {
                    _nsContext.popContext();
                }

                _isEmptyElement = false;
            }

            if (terminateAfter) {
                encodeTermination();
            }
        }
    } catch (IOException e) {
        throw new XMLStreamException(e);
    }
}
 
Example 16
Source File: StAXDocumentSerializer.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
protected void encodeTerminationAndCurrentElement(boolean terminateAfter) throws XMLStreamException {
    try {
        encodeTermination();

        if (_inStartElement) {

            _b = EncodingConstants.ELEMENT;
            if (_attributesArrayIndex > 0) {
                _b |= EncodingConstants.ELEMENT_ATTRIBUTE_FLAG;
            }

            // Encode namespace decls associated with this element
            if (_namespacesArrayIndex > 0) {
                write(_b | EncodingConstants.ELEMENT_NAMESPACES_FLAG);
                for (int i = 0; i < _namespacesArrayIndex;) {
                    encodeNamespaceAttribute(_namespacesArray[i++], _namespacesArray[i++]);
                }
                _namespacesArrayIndex = 0;

                write(EncodingConstants.TERMINATOR);

                _b = 0;
            }

            // If element's prefix is empty - apply default scope namespace
            if (_currentPrefix.length() == 0) {
                if (_currentUri.length() == 0) {
                    _currentUri = _nsContext.getNamespaceURI("");
                } else {
                    String tmpPrefix = getPrefix(_currentUri);
                    if (tmpPrefix != null) {
                        _currentPrefix = tmpPrefix;
                    }
                }
            }

            encodeElementQualifiedNameOnThirdBit(_currentUri, _currentPrefix, _currentLocalName);

            for (int i = 0; i < _attributesArrayIndex;) {
                encodeAttributeQualifiedNameOnSecondBit(
                        _attributesArray[i++], _attributesArray[i++], _attributesArray[i++]);

                final String value = _attributesArray[i];
                _attributesArray[i++] = null;
                final boolean addToTable = isAttributeValueLengthMatchesLimit(value.length());
                encodeNonIdentifyingStringOnFirstBit(value, _v.attributeValue, addToTable, false);

                _b = EncodingConstants.TERMINATOR;
                _terminate = true;
            }
            _attributesArrayIndex = 0;
            _inStartElement = false;

            if (_isEmptyElement) {
                encodeElementTermination();
                if (_nsSupportContextStack[_stackCount--] == true) {
                    _nsContext.popContext();
                }

                _isEmptyElement = false;
            }

            if (terminateAfter) {
                encodeTermination();
            }
        }
    } catch (IOException e) {
        throw new XMLStreamException(e);
    }
}