/** * Method called to initialize buffers that need not be immediately * initialized */ protected final void allocBuffers() { if (mAttributes == null) { mAttributes = new Attribute[8]; } if (mValueBuilder == null) { mValueBuilder = new TextBuilder(EXP_ATTR_COUNT); } }
throws XMLStreamException char[] outBuf = tb.getCharBuffer(); int outPtr = tb.getCharSize(); int outLen = outBuf.length; WstxInputSource currScope = mInput; ch -= 0x10000; if (outPtr >= outLen) { outBuf = tb.bufferFull(1); outLen = outBuf.length; verifyLimit("Maximum attribute size", mConfig.getMaxAttributeSize(), tb.getCharSize()); outBuf = tb.bufferFull(1); outLen = outBuf.length; tb.setBufferSize(outPtr);
/** * Method called to allow reusing of collector, usually right before * starting collecting attributes for a new start tag. *<p> * Note: public only so that it can be called by unit tests. */ public void reset() { if (mNsCount > 0) { mNamespaceBuilder.reset(); mDefaultNsDeclared = false; mNsCount = 0; } /* No need to clear attr name, or NS prefix Strings; they are * canonicalized and will be referenced by symbol table in any * case... so we can save trouble of cleaning them up. This Object * will get GC'ed soon enough, after parser itself gets disposed of. */ if (mAttrCount > 0) { mValueBuilder.reset(); mAttrCount = 0; if (mXmlIdAttrIndex >= 0) { mXmlIdAttrIndex = XMLID_IX_NONE; } } /* Note: attribute values will be cleared later on, when validating * namespaces. This so that we know how much to clean up; and * occasionally can also just avoid clean up (when resizing) */ }
public void append(char c) { if (mBuffer.length == mBufferLen) { resize(1); } mBuffer[mBufferLen++] = c; }
/** * Method for getting start pointer within shared value buffer * for given attribute. It is also the same as end pointer * for preceding attribute, if any. */ protected int getValueStartOffset(int index) { if (index < mAttrCount) { return mAttributes[index].mValueStartOffset; } return mValueBuilder.getCharSize(); }
protected char[] getSharedValueBuffer() { return mValueBuilder.getCharBuffer(); }
/** * Method called to normalize value of an ID attribute, specified * using name xml:id, when support for Xml:id specification enabled. */ protected final void normalizeXmlIdAttr(AttributeCollector ac, int ix) { // StringUtil has a method, but it works on char arrays... TextBuilder attrBuilder = ac.getAttrBuilder(); char[] attrCB = attrBuilder.getCharBuffer(); String normValue = StringUtil.normalizeSpaces (attrCB, attrBuilder.getOffset(ix), attrBuilder.getOffset(ix+1)); if (normValue != null) { ac.setNormalizedValue(ix, normValue); } } }
boolean internNsUris = mConfig.willInternNsURIs(); for (int i = 0; i < nsCount; ++i) { String nsUri = nsURIs.getEntry(i); if (internNsUris && nsUri.length() > 0) { nsUri = sInternCache.intern(nsUri); String[] nameData = attrNames.getInternalArray(); TextBuilder attrBuilder = ac.getAttrBuilder(); char[] attrCB = attrBuilder.getCharBuffer(); for (int i = 0, nr = 0; i < attrLen; i += 2, ++nr) { prefix = nameData[i]; String normValue = mValidator.validateAttribute (ln, attrURIs[nr], prefix, attrCB, attrBuilder.getOffset(nr), attrBuilder.getOffset(nr+1)); if (normValue != null) { ac.setNormalizedValue(nr, normValue);
/** * Method called to resolve and initialize specified collected * namespace declaration * * @return Attribute that contains specified namespace declaration */ protected Attribute resolveNamespaceDecl(int index, boolean internURI) { Attribute ns = mNamespaces[index]; String full = mNamespaceBuilder.getAllValues(); String uri; if (mNsCount == 0) { uri = full; } else { ++index; if (index < mNsCount) { // not last int endOffset = mNamespaces[index].mValueStartOffset; uri = ns.getValue(full, endOffset); } else { // is last uri = ns.getValue(full); } } if (internURI && uri.length() > 0) { uri = sInternCache.intern(uri); } ns.mNamespaceURI = uri; return ns; }
public String getNsURI(int index) { return mNamespaceURIs.getEntry(index); }
public char[] bufferFull(int needSpaceFor) { mBufferLen = mBuffer.length; resize(1); return mBuffer; }
int uriStart = mNamespaceBuilder.getCharSize(); Attribute curr = mNamespaces[len]; if (curr == null) {
/** * Method called to decode the attribute value that consists of * zero or more space-separated tokens. * Decoding is done using the decoder provided. * @return Number of tokens decoded */ public final int decodeValues(int index, TypedArrayDecoder tad, InputProblemReporter rep) throws XMLStreamException { if (index < 0 || index >= mAttrCount) { throwIndex(index); } // Char[] faster than String... and no need to trim here: return decodeValues(tad, rep, mValueBuilder.getCharBuffer(), mAttributes[index].mValueStartOffset, getValueStartOffset(index+1)); }
/** * Method called to normalize value of an ID attribute, specified * using name xml:id, when support for Xml:id specification enabled. */ protected final void normalizeXmlIdAttr(AttributeCollector ac, int ix) { // StringUtil has a method, but it works on char arrays... TextBuilder attrBuilder = ac.getAttrBuilder(); char[] attrCB = attrBuilder.getCharBuffer(); String normValue = StringUtil.normalizeSpaces (attrCB, attrBuilder.getOffset(ix), attrBuilder.getOffset(ix+1)); if (normValue != null) { ac.setNormalizedValue(ix, normValue); } } }
boolean internNsUris = mConfig.willInternNsURIs(); for (int i = 0; i < nsCount; ++i) { String nsUri = nsURIs.getEntry(i); if (internNsUris && nsUri.length() > 0) { nsUri = sInternCache.intern(nsUri); String[] nameData = attrNames.getInternalArray(); TextBuilder attrBuilder = ac.getAttrBuilder(); char[] attrCB = attrBuilder.getCharBuffer(); for (int i = 0, nr = 0; i < attrLen; i += 2, ++nr) { prefix = nameData[i]; String normValue = mValidator.validateAttribute (ln, attrURIs[nr], prefix, attrCB, attrBuilder.getOffset(nr), attrBuilder.getOffset(nr+1)); if (normValue != null) { ac.setNormalizedValue(nr, normValue);
/** *<p> * Note: the main reason this method is defined at this level, and * made final, is performance. JIT may be able to fully inline this * method, even when reference is via this base class. This is important * since this is likely to be the most often called method of the * collector instances. */ public final String getValue(int index) { if (index < 0 || index >= mAttrCount) { throwIndex(index); } String full = mValueBuilder.getAllValues(); Attribute attr = mAttributes[index]; ++index; if (index < mAttrCount) { // not last int endOffset = mAttributes[index].mValueStartOffset; return attr.getValue(full, endOffset); } // last can be optimized bit more: return attr.getValue(full); }
public String getNsURI(int index) { return mNamespaceURIs.getEntry(index); }
throws IOException, XMLStreamException char[] outBuf = tb.getCharBuffer(); int outPtr = tb.getCharSize(); int outLen = outBuf.length; WstxInputSource currScope = mInput; outBuf = tb.bufferFull(1); outLen = outBuf.length; outBuf = tb.bufferFull(1); outLen = outBuf.length; tb.setBufferSize(outPtr);
public void append(char[] src, int start, int len) { if (len > (mBuffer.length - mBufferLen)) { resize(len); } System.arraycopy(src, start, mBuffer, mBufferLen, len); mBufferLen += len; }
int valueStart = mValueBuilder.getCharSize(); if (mAttrCount >= mAttributes.length) { if ((mAttrCount + mNsCount) >= mMaxAttributesPerElement) {