aoqi@0: /* aoqi@0: * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. Oracle designates this aoqi@0: * particular file as subject to the "Classpath" exception as provided aoqi@0: * by Oracle in the LICENSE file that accompanied this code. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: * aoqi@0: * THIS FILE WAS MODIFIED BY SUN MICROSYSTEMS, INC. aoqi@0: */ aoqi@0: aoqi@0: package com.sun.xml.internal.fastinfoset.sax; aoqi@0: aoqi@0: import com.sun.xml.internal.fastinfoset.Encoder; aoqi@0: import com.sun.xml.internal.fastinfoset.EncodingConstants; aoqi@0: import com.sun.xml.internal.fastinfoset.QualifiedName; aoqi@0: import com.sun.xml.internal.org.jvnet.fastinfoset.sax.FastInfosetWriter; aoqi@0: import com.sun.xml.internal.fastinfoset.util.LocalNameQualifiedNamesMap; aoqi@0: import java.io.IOException; aoqi@0: import com.sun.xml.internal.org.jvnet.fastinfoset.EncodingAlgorithmIndexes; aoqi@0: import com.sun.xml.internal.org.jvnet.fastinfoset.FastInfosetException; aoqi@0: import com.sun.xml.internal.org.jvnet.fastinfoset.RestrictedAlphabet; aoqi@0: import com.sun.xml.internal.org.jvnet.fastinfoset.sax.EncodingAlgorithmAttributes; aoqi@0: import org.xml.sax.Attributes; aoqi@0: import org.xml.sax.SAXException; aoqi@0: import com.sun.xml.internal.fastinfoset.CommonResourceBundle; aoqi@0: aoqi@0: /** aoqi@0: * The Fast Infoset SAX serializer. aoqi@0: *

aoqi@0: * Instantiate this serializer to serialize a fast infoset document in accordance aoqi@0: * with the SAX API. aoqi@0: *

aoqi@0: * This utilizes the SAX API in a reverse manner to that of parsing. It is the aoqi@0: * responsibility of the client to call the appropriate event methods on the aoqi@0: * SAX handlers, and to ensure that such a sequence of methods calls results aoqi@0: * in the production well-formed fast infoset documents. The aoqi@0: * SAXDocumentSerializer performs no well-formed checks. aoqi@0: * aoqi@0: *

aoqi@0: * More than one fast infoset document may be encoded to the aoqi@0: * {@link java.io.OutputStream}. aoqi@0: */ aoqi@0: public class SAXDocumentSerializer extends Encoder implements FastInfosetWriter { aoqi@0: protected boolean _elementHasNamespaces = false; aoqi@0: aoqi@0: protected boolean _charactersAsCDATA = false; aoqi@0: aoqi@0: protected SAXDocumentSerializer(boolean v) { aoqi@0: super(v); aoqi@0: } aoqi@0: aoqi@0: public SAXDocumentSerializer() { aoqi@0: } aoqi@0: aoqi@0: aoqi@0: public void reset() { aoqi@0: super.reset(); aoqi@0: aoqi@0: _elementHasNamespaces = false; aoqi@0: _charactersAsCDATA = false; aoqi@0: } aoqi@0: aoqi@0: // ContentHandler aoqi@0: aoqi@0: public final void startDocument() throws SAXException { aoqi@0: try { aoqi@0: reset(); aoqi@0: encodeHeader(false); aoqi@0: encodeInitialVocabulary(); aoqi@0: } catch (IOException e) { aoqi@0: throw new SAXException("startDocument", e); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: public final void endDocument() throws SAXException { aoqi@0: try { aoqi@0: encodeDocumentTermination(); aoqi@0: } catch (IOException e) { aoqi@0: throw new SAXException("endDocument", e); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: public void startPrefixMapping(String prefix, String uri) throws SAXException { aoqi@0: try { aoqi@0: if (_elementHasNamespaces == false) { aoqi@0: encodeTermination(); aoqi@0: aoqi@0: // Mark the current buffer position to flag attributes if necessary aoqi@0: mark(); aoqi@0: _elementHasNamespaces = true; aoqi@0: aoqi@0: // Write out Element byte with namespaces aoqi@0: write(EncodingConstants.ELEMENT | EncodingConstants.ELEMENT_NAMESPACES_FLAG); aoqi@0: } aoqi@0: aoqi@0: encodeNamespaceAttribute(prefix, uri); aoqi@0: } catch (IOException e) { aoqi@0: throw new SAXException("startElement", e); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: public final void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { aoqi@0: // TODO consider using buffer for encoding of attributes, then pre-counting is not necessary aoqi@0: final int attributeCount = (atts != null && atts.getLength() > 0) aoqi@0: ? countAttributes(atts) : 0; aoqi@0: try { aoqi@0: if (_elementHasNamespaces) { aoqi@0: _elementHasNamespaces = false; aoqi@0: aoqi@0: if (attributeCount > 0) { aoqi@0: // Flag the marked byte with attributes aoqi@0: _octetBuffer[_markIndex] |= EncodingConstants.ELEMENT_ATTRIBUTE_FLAG; aoqi@0: } aoqi@0: resetMark(); aoqi@0: aoqi@0: write(EncodingConstants.TERMINATOR); aoqi@0: aoqi@0: _b = 0; aoqi@0: } else { aoqi@0: encodeTermination(); aoqi@0: aoqi@0: _b = EncodingConstants.ELEMENT; aoqi@0: if (attributeCount > 0) { aoqi@0: _b |= EncodingConstants.ELEMENT_ATTRIBUTE_FLAG; aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: encodeElement(namespaceURI, qName, localName); aoqi@0: aoqi@0: if (attributeCount > 0) { aoqi@0: encodeAttributes(atts); aoqi@0: } aoqi@0: } catch (IOException e) { aoqi@0: throw new SAXException("startElement", e); aoqi@0: } catch (FastInfosetException e) { aoqi@0: throw new SAXException("startElement", e); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: public final void endElement(String namespaceURI, String localName, String qName) throws SAXException { aoqi@0: try { aoqi@0: encodeElementTermination(); aoqi@0: } catch (IOException e) { aoqi@0: throw new SAXException("endElement", e); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: public final void characters(char[] ch, int start, int length) throws SAXException { aoqi@0: if (length <= 0) { aoqi@0: return; aoqi@0: } aoqi@0: aoqi@0: if (getIgnoreWhiteSpaceTextContent() && aoqi@0: isWhiteSpace(ch, start, length)) return; aoqi@0: aoqi@0: try { aoqi@0: encodeTermination(); aoqi@0: aoqi@0: if (!_charactersAsCDATA) { aoqi@0: encodeCharacters(ch, start, length); aoqi@0: } else { aoqi@0: encodeCIIBuiltInAlgorithmDataAsCDATA(ch, start, length); aoqi@0: } aoqi@0: } catch (IOException e) { aoqi@0: throw new SAXException(e); aoqi@0: } catch (FastInfosetException e) { aoqi@0: throw new SAXException(e); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: public final void ignorableWhitespace(char[] ch, int start, int length) throws SAXException { aoqi@0: if (getIgnoreWhiteSpaceTextContent()) return; aoqi@0: aoqi@0: characters(ch, start, length); aoqi@0: } aoqi@0: aoqi@0: public final void processingInstruction(String target, String data) throws SAXException { aoqi@0: try { aoqi@0: if (getIgnoreProcesingInstructions()) return; aoqi@0: aoqi@0: if (target.length() == 0) { aoqi@0: throw new SAXException(CommonResourceBundle.getInstance(). aoqi@0: getString("message.processingInstructionTargetIsEmpty")); aoqi@0: } aoqi@0: encodeTermination(); aoqi@0: aoqi@0: encodeProcessingInstruction(target, data); aoqi@0: } catch (IOException e) { aoqi@0: throw new SAXException("processingInstruction", e); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: public final void setDocumentLocator(org.xml.sax.Locator locator) { aoqi@0: } aoqi@0: aoqi@0: public final void skippedEntity(String name) throws SAXException { aoqi@0: } aoqi@0: aoqi@0: aoqi@0: aoqi@0: // LexicalHandler aoqi@0: aoqi@0: public final void comment(char[] ch, int start, int length) throws SAXException { aoqi@0: try { aoqi@0: if (getIgnoreComments()) return; aoqi@0: aoqi@0: encodeTermination(); aoqi@0: aoqi@0: encodeComment(ch, start, length); aoqi@0: } catch (IOException e) { aoqi@0: throw new SAXException("startElement", e); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: public final void startCDATA() throws SAXException { aoqi@0: _charactersAsCDATA = true; aoqi@0: } aoqi@0: aoqi@0: public final void endCDATA() throws SAXException { aoqi@0: _charactersAsCDATA = false; aoqi@0: } aoqi@0: aoqi@0: public final void startDTD(String name, String publicId, String systemId) throws SAXException { aoqi@0: if (getIgnoreDTD()) return; aoqi@0: aoqi@0: try { aoqi@0: encodeTermination(); aoqi@0: aoqi@0: encodeDocumentTypeDeclaration(publicId, systemId); aoqi@0: encodeElementTermination(); aoqi@0: } catch (IOException e) { aoqi@0: throw new SAXException("startDTD", e); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: public final void endDTD() throws SAXException { aoqi@0: } aoqi@0: aoqi@0: public final void startEntity(String name) throws SAXException { aoqi@0: } aoqi@0: aoqi@0: public final void endEntity(String name) throws SAXException { aoqi@0: } aoqi@0: aoqi@0: aoqi@0: // EncodingAlgorithmContentHandler aoqi@0: aoqi@0: public final void octets(String URI, int id, byte[] b, int start, int length) throws SAXException { aoqi@0: if (length <= 0) { aoqi@0: return; aoqi@0: } aoqi@0: aoqi@0: try { aoqi@0: encodeTermination(); aoqi@0: aoqi@0: encodeNonIdentifyingStringOnThirdBit(URI, id, b, start, length); aoqi@0: } catch (IOException e) { aoqi@0: throw new SAXException(e); aoqi@0: } catch (FastInfosetException e) { aoqi@0: throw new SAXException(e); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: public final void object(String URI, int id, Object data) throws SAXException { aoqi@0: try { aoqi@0: encodeTermination(); aoqi@0: aoqi@0: encodeNonIdentifyingStringOnThirdBit(URI, id, data); aoqi@0: } catch (IOException e) { aoqi@0: throw new SAXException(e); aoqi@0: } catch (FastInfosetException e) { aoqi@0: throw new SAXException(e); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: aoqi@0: // PrimitiveTypeContentHandler aoqi@0: aoqi@0: public final void bytes(byte[] b, int start, int length) throws SAXException { aoqi@0: if (length <= 0) { aoqi@0: return; aoqi@0: } aoqi@0: aoqi@0: try { aoqi@0: encodeTermination(); aoqi@0: aoqi@0: encodeCIIOctetAlgorithmData(EncodingAlgorithmIndexes.BASE64, b, start, length); aoqi@0: } catch (IOException e) { aoqi@0: throw new SAXException(e); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: public final void shorts(short[] s, int start, int length) throws SAXException { aoqi@0: if (length <= 0) { aoqi@0: return; aoqi@0: } aoqi@0: aoqi@0: try { aoqi@0: encodeTermination(); aoqi@0: aoqi@0: encodeCIIBuiltInAlgorithmData(EncodingAlgorithmIndexes.SHORT, s, start, length); aoqi@0: } catch (IOException e) { aoqi@0: throw new SAXException(e); aoqi@0: } catch (FastInfosetException e) { aoqi@0: throw new SAXException(e); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: public final void ints(int[] i, int start, int length) throws SAXException { aoqi@0: if (length <= 0) { aoqi@0: return; aoqi@0: } aoqi@0: aoqi@0: try { aoqi@0: encodeTermination(); aoqi@0: aoqi@0: encodeCIIBuiltInAlgorithmData(EncodingAlgorithmIndexes.INT, i, start, length); aoqi@0: } catch (IOException e) { aoqi@0: throw new SAXException(e); aoqi@0: } catch (FastInfosetException e) { aoqi@0: throw new SAXException(e); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: public final void longs(long[] l, int start, int length) throws SAXException { aoqi@0: if (length <= 0) { aoqi@0: return; aoqi@0: } aoqi@0: aoqi@0: try { aoqi@0: encodeTermination(); aoqi@0: aoqi@0: encodeCIIBuiltInAlgorithmData(EncodingAlgorithmIndexes.LONG, l, start, length); aoqi@0: } catch (IOException e) { aoqi@0: throw new SAXException(e); aoqi@0: } catch (FastInfosetException e) { aoqi@0: throw new SAXException(e); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: public final void booleans(boolean[] b, int start, int length) throws SAXException { aoqi@0: if (length <= 0) { aoqi@0: return; aoqi@0: } aoqi@0: aoqi@0: try { aoqi@0: encodeTermination(); aoqi@0: aoqi@0: encodeCIIBuiltInAlgorithmData(EncodingAlgorithmIndexes.BOOLEAN, b, start, length); aoqi@0: } catch (IOException e) { aoqi@0: throw new SAXException(e); aoqi@0: } catch (FastInfosetException e) { aoqi@0: throw new SAXException(e); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: public final void floats(float[] f, int start, int length) throws SAXException { aoqi@0: if (length <= 0) { aoqi@0: return; aoqi@0: } aoqi@0: aoqi@0: try { aoqi@0: encodeTermination(); aoqi@0: aoqi@0: encodeCIIBuiltInAlgorithmData(EncodingAlgorithmIndexes.FLOAT, f, start, length); aoqi@0: } catch (IOException e) { aoqi@0: throw new SAXException(e); aoqi@0: } catch (FastInfosetException e) { aoqi@0: throw new SAXException(e); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: public final void doubles(double[] d, int start, int length) throws SAXException { aoqi@0: if (length <= 0) { aoqi@0: return; aoqi@0: } aoqi@0: aoqi@0: try { aoqi@0: encodeTermination(); aoqi@0: aoqi@0: encodeCIIBuiltInAlgorithmData(EncodingAlgorithmIndexes.DOUBLE, d, start, length); aoqi@0: } catch (IOException e) { aoqi@0: throw new SAXException(e); aoqi@0: } catch (FastInfosetException e) { aoqi@0: throw new SAXException(e); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: public void uuids(long[] msblsb, int start, int length) throws SAXException { aoqi@0: if (length <= 0) { aoqi@0: return; aoqi@0: } aoqi@0: aoqi@0: try { aoqi@0: encodeTermination(); aoqi@0: aoqi@0: encodeCIIBuiltInAlgorithmData(EncodingAlgorithmIndexes.UUID, msblsb, start, length); aoqi@0: } catch (IOException e) { aoqi@0: throw new SAXException(e); aoqi@0: } catch (FastInfosetException e) { aoqi@0: throw new SAXException(e); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: aoqi@0: // RestrictedAlphabetContentHandler aoqi@0: aoqi@0: public void numericCharacters(char ch[], int start, int length) throws SAXException { aoqi@0: if (length <= 0) { aoqi@0: return; aoqi@0: } aoqi@0: aoqi@0: try { aoqi@0: encodeTermination(); aoqi@0: aoqi@0: final boolean addToTable = isCharacterContentChunkLengthMatchesLimit(length); aoqi@0: encodeNumericFourBitCharacters(ch, start, length, addToTable); aoqi@0: } catch (IOException e) { aoqi@0: throw new SAXException(e); aoqi@0: } catch (FastInfosetException e) { aoqi@0: throw new SAXException(e); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: public void dateTimeCharacters(char ch[], int start, int length) throws SAXException { aoqi@0: if (length <= 0) { aoqi@0: return; aoqi@0: } aoqi@0: aoqi@0: try { aoqi@0: encodeTermination(); aoqi@0: aoqi@0: final boolean addToTable = isCharacterContentChunkLengthMatchesLimit(length); aoqi@0: encodeDateTimeFourBitCharacters(ch, start, length, addToTable); aoqi@0: } catch (IOException e) { aoqi@0: throw new SAXException(e); aoqi@0: } catch (FastInfosetException e) { aoqi@0: throw new SAXException(e); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: public void alphabetCharacters(String alphabet, char ch[], int start, int length) throws SAXException { aoqi@0: if (length <= 0) { aoqi@0: return; aoqi@0: } aoqi@0: aoqi@0: try { aoqi@0: encodeTermination(); aoqi@0: aoqi@0: final boolean addToTable = isCharacterContentChunkLengthMatchesLimit(length); aoqi@0: encodeAlphabetCharacters(alphabet, ch, start, length, addToTable); aoqi@0: } catch (IOException e) { aoqi@0: throw new SAXException(e); aoqi@0: } catch (FastInfosetException e) { aoqi@0: throw new SAXException(e); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: // ExtendedContentHandler aoqi@0: aoqi@0: public void characters(char[] ch, int start, int length, boolean index) throws SAXException { aoqi@0: if (length <= 0) { aoqi@0: return; aoqi@0: } aoqi@0: aoqi@0: if (getIgnoreWhiteSpaceTextContent() && aoqi@0: isWhiteSpace(ch, start, length)) return; aoqi@0: aoqi@0: try { aoqi@0: encodeTermination(); aoqi@0: aoqi@0: if (!_charactersAsCDATA) { aoqi@0: encodeNonIdentifyingStringOnThirdBit(ch, start, length, _v.characterContentChunk, index, true); aoqi@0: } else { aoqi@0: encodeCIIBuiltInAlgorithmDataAsCDATA(ch, start, length); aoqi@0: } aoqi@0: } catch (IOException e) { aoqi@0: throw new SAXException(e); aoqi@0: } catch (FastInfosetException e) { aoqi@0: throw new SAXException(e); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: aoqi@0: aoqi@0: protected final int countAttributes(Attributes atts) { aoqi@0: // Count attributes ignoring any in the XMLNS namespace aoqi@0: // Note, such attributes may be produced when transforming from a DOM node aoqi@0: int count = 0; aoqi@0: for (int i = 0; i < atts.getLength(); i++) { aoqi@0: final String uri = atts.getURI(i); aoqi@0: if (uri == "http://www.w3.org/2000/xmlns/" || uri.equals("http://www.w3.org/2000/xmlns/")) { aoqi@0: continue; aoqi@0: } aoqi@0: count++; aoqi@0: } aoqi@0: return count; aoqi@0: } aoqi@0: aoqi@0: protected void encodeAttributes(Attributes atts) throws IOException, FastInfosetException { aoqi@0: boolean addToTable; aoqi@0: boolean mustBeAddedToTable; aoqi@0: String value; aoqi@0: if (atts instanceof EncodingAlgorithmAttributes) { aoqi@0: final EncodingAlgorithmAttributes eAtts = (EncodingAlgorithmAttributes)atts; aoqi@0: Object data; aoqi@0: String alphabet; aoqi@0: for (int i = 0; i < eAtts.getLength(); i++) { aoqi@0: if (encodeAttribute(atts.getURI(i), atts.getQName(i), atts.getLocalName(i))) { aoqi@0: data = eAtts.getAlgorithmData(i); aoqi@0: // If data is null then there is no algorithm data aoqi@0: if (data == null) { aoqi@0: value = eAtts.getValue(i); aoqi@0: addToTable = isAttributeValueLengthMatchesLimit(value.length()); aoqi@0: mustBeAddedToTable = eAtts.getToIndex(i); aoqi@0: aoqi@0: alphabet = eAtts.getAlpababet(i); aoqi@0: if (alphabet == null) { aoqi@0: encodeNonIdentifyingStringOnFirstBit(value, _v.attributeValue, addToTable, mustBeAddedToTable); aoqi@0: } else if (alphabet == RestrictedAlphabet.DATE_TIME_CHARACTERS) { aoqi@0: encodeDateTimeNonIdentifyingStringOnFirstBit( aoqi@0: value, addToTable, mustBeAddedToTable); aoqi@0: } else if (alphabet == RestrictedAlphabet.NUMERIC_CHARACTERS) { aoqi@0: encodeNumericNonIdentifyingStringOnFirstBit( aoqi@0: value, addToTable, mustBeAddedToTable); aoqi@0: } else { aoqi@0: encodeNonIdentifyingStringOnFirstBit(value, _v.attributeValue, addToTable, mustBeAddedToTable); aoqi@0: } aoqi@0: } else { aoqi@0: encodeNonIdentifyingStringOnFirstBit(eAtts.getAlgorithmURI(i), aoqi@0: eAtts.getAlgorithmIndex(i), data); aoqi@0: } aoqi@0: } aoqi@0: } aoqi@0: } else { aoqi@0: for (int i = 0; i < atts.getLength(); i++) { aoqi@0: if (encodeAttribute(atts.getURI(i), atts.getQName(i), atts.getLocalName(i))) { aoqi@0: value = atts.getValue(i); aoqi@0: addToTable = isAttributeValueLengthMatchesLimit(value.length()); aoqi@0: encodeNonIdentifyingStringOnFirstBit(value, _v.attributeValue, addToTable, false); aoqi@0: } aoqi@0: } aoqi@0: } aoqi@0: _b = EncodingConstants.TERMINATOR; aoqi@0: _terminate = true; aoqi@0: } aoqi@0: aoqi@0: protected void encodeElement(String namespaceURI, String qName, String localName) throws IOException { aoqi@0: LocalNameQualifiedNamesMap.Entry entry = _v.elementName.obtainEntry(qName); aoqi@0: if (entry._valueIndex > 0) { aoqi@0: QualifiedName[] names = entry._value; aoqi@0: for (int i = 0; i < entry._valueIndex; i++) { aoqi@0: final QualifiedName n = names[i]; aoqi@0: if ((namespaceURI == n.namespaceName || namespaceURI.equals(n.namespaceName))) { aoqi@0: encodeNonZeroIntegerOnThirdBit(names[i].index); aoqi@0: return; aoqi@0: } aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: encodeLiteralElementQualifiedNameOnThirdBit(namespaceURI, getPrefixFromQualifiedName(qName), aoqi@0: localName, entry); aoqi@0: } aoqi@0: aoqi@0: protected boolean encodeAttribute(String namespaceURI, String qName, String localName) throws IOException { aoqi@0: LocalNameQualifiedNamesMap.Entry entry = _v.attributeName.obtainEntry(qName); aoqi@0: if (entry._valueIndex > 0) { aoqi@0: QualifiedName[] names = entry._value; aoqi@0: for (int i = 0; i < entry._valueIndex; i++) { aoqi@0: if ((namespaceURI == names[i].namespaceName || namespaceURI.equals(names[i].namespaceName))) { aoqi@0: encodeNonZeroIntegerOnSecondBitFirstBitZero(names[i].index); aoqi@0: return true; aoqi@0: } aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: return encodeLiteralAttributeQualifiedNameOnSecondBit(namespaceURI, getPrefixFromQualifiedName(qName), aoqi@0: localName, entry); aoqi@0: } aoqi@0: }