int l = s.length(); boolean inCurly = false; FastStringBuffer buf = new FastStringBuffer(); if (buf.length() > 0) QName qname = QName.getQNameFromString(buf.toString()); v.addElement(qname); buf.reset(); inCurly = false; buf.append(c); if (buf.length() > 0) QName qname = QName.getQNameFromString(buf.toString()); v.addElement(qname); buf.reset();
/** * Get a single character from the string buffer. * * * @param pos character position requested. * @return A character from the requested position. */ public char charAt(int pos) { int startChunk = pos >>> m_chunkBits; if (startChunk == 0 && m_innerFSB != null) return m_innerFSB.charAt(pos & m_chunkMask); else return m_array[startChunk][pos & m_chunkMask]; }
/** * @param start Offset of first character in the range. * @param length Number of characters to send. * @return a new String object initialized from the specified range of * characters. */ public String getString(int start, int length) { int startColumn = start & m_chunkMask; int startChunk = start >>> m_chunkBits; if (startColumn + length < m_chunkMask && m_innerFSB == null) { return getOneChunkString(startChunk, startColumn, length); } return getString(new StringBuffer(length), startChunk, startColumn, length).toString(); }
/** * Set an output property with a QName list value. The QNames will be turned * into strings with the namespace in curly brackets. * * @param key the key to be placed into the property list. * @param v non-null list of QNames corresponding to <tt>key</tt>. * @see javax.xml.transform.OutputKeys */ public void setQNameProperties(String key, Vector v) { int s = v.size(); // Just an initial guess at reasonable tuning parameters FastStringBuffer fsb = new FastStringBuffer(9,9); for (int i = 0; i < s; i++) { QName qname = (QName) v.elementAt(i); fsb.append(qname.toNamespacedString()); // Don't append space after last value if (i < s-1) fsb.append(' '); } m_properties.put(key, fsb.toString()); }
int length = m_chars.size() - m_textPendingStart; boolean doStrip = false; doStrip = m_chars.isWhitespace(m_textPendingStart, length); m_chars.setLength(m_textPendingStart); // Discard accumulated text } else {
while(node!=null) buf.append(node.getNodeValue()); node=logicalNextDOMTextNode(node); boolean b = buf.isWhitespace(0, buf.length()); StringBufferPool.free(buf); return b;
public void characters(char[] ch, int start, int length) throws org.xml.sax.SAXException { // Actually creating the text node is handled by // processAccumulatedText(); here we just accumulate the // characters into the buffer. m_char.append(ch,start,length); }
/** * Get the textual contents of the node. See * getNodeData(Node,FastStringBuffer) for discussion of how * whitespace nodes are handled. * * @param node DOM Node to be examined * @return String containing a concatenation of all the * textual content within that node. * @see #getNodeData(Node,FastStringBuffer) * */ public static String getNodeData(Node node) { FastStringBuffer buf = StringBufferPool.get(); String s; try { getNodeData(node, buf); s = (buf.length() > 0) ? buf.toString() : ""; } finally { StringBufferPool.free(buf); } return s; }
/** * @param sb StringBuffer to be appended to * @param start Offset of first character in the range. * @param length Number of characters to send. * @return sb with the requested text appended to it */ StringBuffer getString(StringBuffer sb, int start, int length) { return getString(sb, start >>> m_chunkBits, start & m_chunkMask, length); }
private final FastStringBuffer getBuffer(){ if(USE_OBJECT_POOL){ return StringBufferPool.get(); }else{ return new FastStringBuffer(INIT_BUFFER_CHUNK_BITS); } } }
public SAX2RTFDTM(DTMManager mgr, Source source, int dtmIdentity, DTMWSFilter whiteSpaceFilter, XMLStringFactory xstringfactory, boolean doIndexing) { super(mgr, source, dtmIdentity, whiteSpaceFilter, xstringfactory, doIndexing); // NEVER track source locators for RTFs; they aren't meaningful. I think. // (If we did track them, we'd need to tail-prune these too.) //org.apache.xalan.processor.TransformerFactoryImpl.m_source_location; m_useSourceLocationProperty=false; m_sourceSystemId = (m_useSourceLocationProperty) ? new StringVector() : null; m_sourceLine = (m_useSourceLocationProperty) ? new IntVector() : null; m_sourceColumn = (m_useSourceLocationProperty) ? new IntVector() : null; // Record initial sizes of fields that are pushed and restored // for RTF tail-pruning. More entries can be popped than pushed, so // we need this to mark the primordial state of the DTM. m_emptyNodeCount = m_size; m_emptyNSDeclSetCount = (m_namespaceDeclSets == null) ? 0 : m_namespaceDeclSets.size(); m_emptyNSDeclSetElemsCount = (m_namespaceDeclSetElements == null) ? 0 : m_namespaceDeclSetElements.size(); m_emptyDataCount = m_data.size(); m_emptyCharsCount = m_chars.size(); m_emptyDataQNCount = m_dataOrQName.size(); }
chunkOK = m_innerFSB.isWhitespace(sourcecolumn, runlength); else chunkOK = org.apache.xml.utils.XMLCharacterRecognizer.isWhiteSpace(
private void processAccumulatedText() { int len=m_char.length(); if(len!=m_char_current_start) { // The FastStringBuffer has been previously agreed upon appendTextChild(m_char_current_start,len-m_char_current_start); m_char_current_start=len; } } public void endDocument()
/** * @param start Offset of first character in the range. * @param length Number of characters to send. * @return a new String object initialized from the specified range of * characters. */ public String getString(int start, int length) { int startColumn = start & m_chunkMask; int startChunk = start >>> m_chunkBits; if (startColumn + length < m_chunkMask && m_innerFSB == null) { return getOneChunkString(startChunk, startColumn, length); } return getString(new StringBuffer(length), startChunk, startColumn, length).toString(); }
int length = m_chars.size() - m_textPendingStart; boolean doStrip = false; doStrip = m_chars.isWhitespace(m_textPendingStart, length); m_chars.setLength(m_textPendingStart); // Discard accumulated text } else {