/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
* THIS FILE WAS MODIFIED BY SUN MICROSYSTEMS, INC.
*/
/**
* The Fast Infoset StAX serializer.
* <p>
* Instantiate this serializer to serialize a fast infoset document in accordance
* with the StAX API.
*
* <p>
* More than one fast infoset document may be encoded to the
* {@link java.io.OutputStream}.
*/
implements XMLStreamWriter, LowLevelFastInfosetStreamWriter {
/**
* Local name of current element.
*/
/**
* Namespace of current element.
*/
/**
* Prefix of current element.
*/
/**
* This flag indicates when there is a pending start element event.
*/
protected boolean _inStartElement = false;
/**
* This flag indicates if the current element is empty.
*/
protected boolean _isEmptyElement = false;
/**
* List of attributes qnames and values defined in the current element.
*/
/**
* Mapping between uris and prefixes.
*/
/**
* List of namespaces defined in the current element.
*/
public StAXDocumentSerializer() {
super(true);
}
super(true);
}
super(true);
}
public void reset() {
super.reset();
_nsContext.reset();
_stackCount = -1;
_inStartElement = _isEmptyElement = false;
}
// -- XMLStreamWriter Interface -------------------------------------------
}
}
throws XMLStreamException
{
reset();
try {
encodeHeader(false);
} catch (IOException e) {
throw new XMLStreamException(e);
}
}
try {
// terminate all elements not terminated
// by writeEndElement
}
}
catch (IOException e) {
throw new XMLStreamException(e);
}
}
reset();
}
try {
}
catch (IOException e) {
throw new XMLStreamException(e);
}
}
throws XMLStreamException
{
// TODO is it necessary for FI to obtain the default namespace in scope?
}
throws XMLStreamException
{
}
{
_inStartElement = true;
_isEmptyElement = false;
_stackCount++;
System.arraycopy(_nsSupportContextStack, 0, nsSupportContextStack, 0, _nsSupportContextStack.length);
}
_nsSupportContextStack[_stackCount] = false;
}
throws XMLStreamException
{
}
throws XMLStreamException
{
}
{
_isEmptyElement = _inStartElement = true;
_stackCount++;
System.arraycopy(_nsSupportContextStack, 0, nsSupportContextStack, 0, _nsSupportContextStack.length);
}
_nsSupportContextStack[_stackCount] = false;
}
if (_inStartElement) {
}
try {
if (_nsSupportContextStack[_stackCount--] == true) {
}
}
catch (IOException e) {
throw new XMLStreamException(e);
}
catch (EmptyStackException e) {
throw new XMLStreamException(e);
}
}
throws XMLStreamException
{
}
{
// Find prefix for attribute, ignoring default namespace
// Undeclared prefix or ignorable default ns?
// Workaround for BUG in SAX NamespaceSupport helper
// which incorrectly defines namespace declaration URI
// TODO
// Need to check carefully the rule for the writing of
// namespaces in StAX. Is it safe to ignore such
// attributes, as declarations will be made using the
// writeNamespace method
return;
}
throw new XMLStreamException(CommonResourceBundle.getInstance().getString("message.URIUnbound", new Object[]{namespaceURI}));
}
}
}
{
if (!_inStartElement) {
throw new IllegalStateException(CommonResourceBundle.getInstance().getString("message.attributeWritingNotAllowed"));
}
// TODO
// Need to check carefully the rule for the writing of
// namespaces in StAX. Is it safe to ignore such
// attributes, as declarations will be made using the
// writeNamespace method
return;
}
}
}
throws XMLStreamException
{
if (prefix == null || prefix.length() == 0 || prefix.equals(EncodingConstants.XMLNS_NAMESPACE_PREFIX)) {
}
else {
if (!_inStartElement) {
throw new IllegalStateException(CommonResourceBundle.getInstance().getString("message.attributeWritingNotAllowed"));
}
}
}
}
throws XMLStreamException
{
if (!_inStartElement) {
throw new IllegalStateException(CommonResourceBundle.getInstance().getString("message.attributeWritingNotAllowed"));
}
}
}
try {
if (getIgnoreComments()) return;
// TODO: avoid array copy here
}
catch (IOException e) {
throw new XMLStreamException(e);
}
}
throws XMLStreamException
{
}
throws XMLStreamException
{
try {
if (getIgnoreProcesingInstructions()) return;
}
catch (IOException e) {
throw new XMLStreamException(e);
}
}
try {
if (length == 0) {
return;
if (getIgnoreWhiteSpaceTextContent() &&
isWhiteSpace(text)) return;
// Warning: this method must be called before any state
// is modified, such as the _charBuffer contents,
// so the characters of text cannot be copied to _charBuffer
// before this call
} else {
if (getIgnoreWhiteSpaceTextContent() &&
}
} catch (Exception e) {
throw new XMLStreamException(e);
}
}
throw new UnsupportedOperationException(CommonResourceBundle.getInstance().getString("message.notImplemented"));
}
throw new UnsupportedOperationException(CommonResourceBundle.getInstance().getString("message.notImplemented"));
}
try {
if (length == 0) {
return;
if (getIgnoreWhiteSpaceTextContent() &&
isWhiteSpace(text)) return;
// Warning: this method must be called before any state
// is modified, such as the _charBuffer contents,
// so the characters of text cannot be copied to _charBuffer
// before this call
} else {
if (getIgnoreWhiteSpaceTextContent() &&
}
}
catch (IOException e) {
throw new XMLStreamException(e);
}
}
throws XMLStreamException
{
try {
if (len <= 0) {
return;
}
if (getIgnoreWhiteSpaceTextContent() &&
}
catch (IOException e) {
throw new XMLStreamException(e);
}
}
}
throws XMLStreamException
{
_nsSupportContextStack[_stackCount] = true;
}
}
}
/**
* Sets the current namespace context for prefix and uri bindings.
* This context becomes the root namespace context for writing and
* will replace the current root namespace context. Subsequent calls
* to setPrefix and setDefaultNamespace will bind namespaces using
* the context passed to the method as the root context for resolving
* namespaces. This method may only be called once at the start of
* the document. It does not cause the namespaces to be declared.
* If a namespace URI to prefix mapping is found in the namespace
* context it is treated as declared and the prefix may be used
* by the StreamWriter.
* @param context the namespace context to use for this writer, may not be null
* @throws XMLStreamException
*/
throws XMLStreamException
{
throw new UnsupportedOperationException("setNamespaceContext");
}
return _nsContext;
}
throws IllegalArgumentException
{
}
return null;
}
}
}
throws XMLStreamException
{
try {
if (len == 0) {
return;
}
}
catch (IOException e) {
throw new XMLStreamException(e);
}
}
protected void encodeTerminationAndCurrentElement(boolean terminateAfter) throws XMLStreamException {
try {
if (_inStartElement) {
if (_attributesArrayIndex > 0) {
}
// Encode namespace decls associated with this element
if (_namespacesArrayIndex > 0) {
for (int i = 0; i < _namespacesArrayIndex;) {
}
_b = 0;
}
// If element's prefix is empty - apply default scope namespace
} else {
}
}
}
for (int i = 0; i < _attributesArrayIndex;) {
_attributesArray[i++] = null;
_terminate = true;
}
_inStartElement = false;
if (_isEmptyElement) {
if (_nsSupportContextStack[_stackCount--] == true) {
}
_isEmptyElement = false;
}
if (terminateAfter) {
}
}
} catch (IOException e) {
throw new XMLStreamException(e);
}
}
// LowLevelFastInfosetSerializer
}
public final int getNextElementIndex() {
}
public final int getNextAttributeIndex() {
}
public final int getLocalNameIndex() {
}
public final int getNextLocalNameIndex() {
}
mark();
}
}
if (!isIndexed)
return isIndexed;
}
}
throws IOException {
}
}
if (hasMark()) {
resetMark();
}
}
}
public final boolean writeLowLevelAttribute(String prefix, String namespaceURI, String localName) throws IOException {
if (!isIndexed)
return isIndexed;
}
{
}
}
}
if (hasMark()) {
resetMark();
} else {
// Terminate the attributes
_terminate = true;
}
}
}
if (length == 0)
return;
}
if (length == 0)
return;
} else {
}
}
if (length == 0)
return;
}
private boolean encodeElement(int type, String namespaceURI, String prefix, String localName) throws IOException {
return true;
}
}
entry.addQualifiedName(new QualifiedName(prefix, namespaceURI, localName, "", _v.elementName.getNextIndex()));
return false;
}
private boolean encodeAttribute(String namespaceURI, String prefix, String localName) throws IOException {
return true;
}
}
entry.addQualifiedName(new QualifiedName(prefix, namespaceURI, localName, "", _v.attributeName.getNextIndex()));
return false;
}
if (namespaceURI != "") {
if (prefix != "")
if (prefix != "")
} else
}
private void encodeLiteral(int type, String namespaceURI, String prefix, String localName) throws IOException {
if (localNameIndex == -1) {
} else
}
}