code
stringlengths
11
173k
docstring
stringlengths
2
593k
func_name
stringlengths
2
189
language
stringclasses
1 value
repo
stringclasses
833 values
path
stringlengths
11
294
url
stringlengths
60
339
license
stringclasses
4 values
private void outputDocTypeDecl(String name) throws SAXException { if (true == m_needToOutputDocTypeDecl) { String doctypeSystem = getDoctypeSystem(); String doctypePublic = getDoctypePublic(); if ((null != doctypeSystem) || (null != doctypePublic)) { final java.io.Writer writer = m_writer; try { writer.write("<!DOCTYPE "); writer.write(name); if (null != doctypePublic) { writer.write(" PUBLIC \""); writer.write(doctypePublic); writer.write('"'); } if (null != doctypeSystem) { if (null == doctypePublic) writer.write(" SYSTEM \""); else writer.write(" \""); writer.write(doctypeSystem); writer.write('"'); } writer.write('>'); outputLineSep(); } catch(IOException e) { throw new SAXException(e); } } } m_needToOutputDocTypeDecl = false; }
This method should only get called once. If a DOCTYPE declaration needs to get written out, it will be written out. If it doesn't need to be written out, then the call to this method has no effect.
ToHTMLStream::outputDocTypeDecl
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
Apache-2.0
public void startElement( String namespaceURI, String localName, String name, Attributes atts) throws org.xml.sax.SAXException { ElemContext elemContext = m_elemContext; // clean up any pending things first if (elemContext.m_startTagOpen) { closeStartTag(); elemContext.m_startTagOpen = false; } else if (m_cdataTagOpen) { closeCDATA(); m_cdataTagOpen = false; } else if (m_needToCallStartDocument) { startDocumentInternal(); m_needToCallStartDocument = false; } if (m_needToOutputDocTypeDecl) { String n = name; if (n == null || n.length() == 0) { // If the lexical QName is not given // use the localName in the DOCTYPE n = localName; } outputDocTypeDecl(n); } // if this element has a namespace then treat it like XML if (null != namespaceURI && namespaceURI.length() > 0) { super.startElement(namespaceURI, localName, name, atts); return; } try { // getElemDesc2(name) is faster than getElemDesc(name) ElemDesc elemDesc = getElemDesc2(name); int elemFlags = elemDesc.getFlags(); // deal with indentation issues first if (m_doIndent) { boolean isBlockElement = (elemFlags & ElemDesc.BLOCK) != 0; if (m_ispreserve) m_ispreserve = false; else if ( (null != elemContext.m_elementName) && (!m_inBlockElem || isBlockElement) /* && !isWhiteSpaceSensitive */ ) { m_startNewLine = true; indent(); } m_inBlockElem = !isBlockElement; } // save any attributes for later processing if (atts != null) addAttributes(atts); m_isprevtext = false; final java.io.Writer writer = m_writer; writer.write('<'); writer.write(name); if (m_tracer != null) firePseudoAttributes(); if ((elemFlags & ElemDesc.EMPTY) != 0) { // an optimization for elements which are expected // to be empty. m_elemContext = elemContext.push(); /* XSLTC sometimes calls namespaceAfterStartElement() * so we need to remember the name */ m_elemContext.m_elementName = name; m_elemContext.m_elementDesc = elemDesc; return; } else { elemContext = elemContext.push(namespaceURI,localName,name); m_elemContext = elemContext; elemContext.m_elementDesc = elemDesc; elemContext.m_isRaw = (elemFlags & ElemDesc.RAW) != 0; } if ((elemFlags & ElemDesc.HEADELEM) != 0) { // This is the <HEAD> element, do some special processing closeStartTag(); elemContext.m_startTagOpen = false; if (!m_omitMetaTag) { if (m_doIndent) indent(); writer.write( "<META http-equiv=\"Content-Type\" content=\"text/html; charset="); String encoding = getEncoding(); String encode = Encodings.getMimeEncoding(encoding); writer.write(encode); writer.write("\">"); } } } catch (IOException e) { throw new SAXException(e); } }
Receive notification of the beginning of an element. @param namespaceURI @param localName @param name The element type name. @param atts The attributes attached to the element, if any. @throws org.xml.sax.SAXException Any SAX exception, possibly wrapping another exception. @see #endElement @see org.xml.sax.AttributeList
ToHTMLStream::startElement
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
Apache-2.0
public final void endElement( final String namespaceURI, final String localName, final String name) throws org.xml.sax.SAXException { // deal with any pending issues if (m_cdataTagOpen) closeCDATA(); // if the element has a namespace, treat it like XML, not HTML if (null != namespaceURI && namespaceURI.length() > 0) { super.endElement(namespaceURI, localName, name); return; } try { ElemContext elemContext = m_elemContext; final ElemDesc elemDesc = elemContext.m_elementDesc; final int elemFlags = elemDesc.getFlags(); final boolean elemEmpty = (elemFlags & ElemDesc.EMPTY) != 0; // deal with any indentation issues if (m_doIndent) { final boolean isBlockElement = (elemFlags&ElemDesc.BLOCK) != 0; boolean shouldIndent = false; if (m_ispreserve) { m_ispreserve = false; } else if (m_doIndent && (!m_inBlockElem || isBlockElement)) { m_startNewLine = true; shouldIndent = true; } if (!elemContext.m_startTagOpen && shouldIndent) indent(elemContext.m_currentElemDepth - 1); m_inBlockElem = !isBlockElement; } final java.io.Writer writer = m_writer; if (!elemContext.m_startTagOpen) { writer.write("</"); writer.write(name); writer.write('>'); } else { // the start-tag open when this method was called, // so we need to process it now. if (m_tracer != null) super.fireStartElem(name); // the starting tag was still open when we received this endElement() call // so we need to process any gathered attributes NOW, before they go away. int nAttrs = m_attributes.getLength(); if (nAttrs > 0) { processAttributes(m_writer, nAttrs); // clear attributes object for re-use with next element m_attributes.clear(); } if (!elemEmpty) { // As per Dave/Paul recommendation 12/06/2000 // if (shouldIndent) // writer.write('>'); // indent(m_currentIndent); writer.write("></"); writer.write(name); writer.write('>'); } else { writer.write('>'); } } // clean up because the element has ended if ((elemFlags & ElemDesc.WHITESPACESENSITIVE) != 0) m_ispreserve = true; m_isprevtext = false; // fire off the end element event if (m_tracer != null) super.fireEndElem(name); // OPTIMIZE-EMPTY if (elemEmpty) { // a quick exit if the HTML element had no children. // This block of code can be removed if the corresponding block of code // in startElement() also labeled with "OPTIMIZE-EMPTY" is also removed m_elemContext = elemContext.m_prev; return; } // some more clean because the element has ended. if (!elemContext.m_startTagOpen) { if (m_doIndent && !m_preserves.isEmpty()) m_preserves.pop(); } m_elemContext = elemContext.m_prev; // m_isRawStack.pop(); } catch (IOException e) { throw new SAXException(e); } }
Receive notification of the end of an element. @param namespaceURI @param localName @param name The element type name @throws org.xml.sax.SAXException Any SAX exception, possibly wrapping another exception.
ToHTMLStream::endElement
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
Apache-2.0
protected void processAttribute( java.io.Writer writer, String name, String value, ElemDesc elemDesc) throws IOException { writer.write(' '); if ( ((value.length() == 0) || value.equalsIgnoreCase(name)) && elemDesc != null && elemDesc.isAttrFlagSet(name, ElemDesc.ATTREMPTY)) { writer.write(name); } else { // %REVIEW% %OPT% // Two calls to single-char write may NOT // be more efficient than one to string-write... writer.write(name); writer.write("=\""); if ( elemDesc != null && elemDesc.isAttrFlagSet(name, ElemDesc.ATTRURL)) writeAttrURI(writer, value, m_specialEscapeURLs); else writeAttrString(writer, value, this.getEncoding()); writer.write('"'); } }
Process an attribute. @param writer The writer to write the processed output to. @param name The name of the attribute. @param value The value of the attribute. @param elemDesc The description of the HTML element that has this attribute. @throws org.xml.sax.SAXException
ToHTMLStream::processAttribute
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
Apache-2.0
private boolean isASCIIDigit(char c) { return (c >= '0' && c <= '9'); }
Tell if a character is an ASCII digit.
ToHTMLStream::isASCIIDigit
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
Apache-2.0
private static String makeHHString(int i) { String s = Integer.toHexString(i).toUpperCase(); if (s.length() == 1) { s = "0" + s; } return s; }
Make an integer into an HH hex value. Does no checking on the size of the input, since this is only meant to be used locally by writeAttrURI. @param i must be a value less than 255. @return should be a two character string.
ToHTMLStream::makeHHString
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
Apache-2.0
private boolean isHHSign(String str) { boolean sign = true; try { char r = (char) Integer.parseInt(str, 16); } catch (NumberFormatException e) { sign = false; } return sign; }
Dmitri Ilyin: Makes sure if the String is HH encoded sign. @param str must be 2 characters long @return true or false
ToHTMLStream::isHHSign
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
Apache-2.0
public void writeAttrURI( final java.io.Writer writer, String string, boolean doURLEscaping) throws IOException { // http://www.ietf.org/rfc/rfc2396.txt says: // A URI is always in an "escaped" form, since escaping or unescaping a // completed URI might change its semantics. Normally, the only time // escape encodings can safely be made is when the URI is being created // from its component parts; each component may have its own set of // characters that are reserved, so only the mechanism responsible for // generating or interpreting that component can determine whether or // not escaping a character will change its semantics. Likewise, a URI // must be separated into its components before the escaped characters // within those components can be safely decoded. // // ...So we do our best to do limited escaping of the URL, without // causing damage. If the URL is already properly escaped, in theory, this // function should not change the string value. final int end = string.length(); if (end > m_attrBuff.length) { m_attrBuff = new char[end*2 + 1]; } string.getChars(0,end, m_attrBuff, 0); final char[] chars = m_attrBuff; int cleanStart = 0; int cleanLength = 0; char ch = 0; for (int i = 0; i < end; i++) { ch = chars[i]; if ((ch < 32) || (ch > 126)) { if (cleanLength > 0) { writer.write(chars, cleanStart, cleanLength); cleanLength = 0; } if (doURLEscaping) { // Encode UTF16 to UTF8. // Reference is Unicode, A Primer, by Tony Graham. // Page 92. // Note that Kay doesn't escape 0x20... // if(ch == 0x20) // Not sure about this... -sb // { // writer.write(ch); // } // else if (ch <= 0x7F) { writer.write('%'); writer.write(makeHHString(ch)); } else if (ch <= 0x7FF) { // Clear low 6 bits before rotate, put high 4 bits in low byte, // and set two high bits. int high = (ch >> 6) | 0xC0; int low = (ch & 0x3F) | 0x80; // First 6 bits, + high bit writer.write('%'); writer.write(makeHHString(high)); writer.write('%'); writer.write(makeHHString(low)); } else if (Encodings.isHighUTF16Surrogate(ch)) // high surrogate { // I'm sure this can be done in 3 instructions, but I choose // to try and do it exactly like it is done in the book, at least // until we are sure this is totally clean. I don't think performance // is a big issue with this particular function, though I could be // wrong. Also, the stuff below clearly does more masking than // it needs to do. // Clear high 6 bits. int highSurrogate = ((int) ch) & 0x03FF; // Middle 4 bits (wwww) + 1 // "Note that the value of wwww from the high surrogate bit pattern // is incremented to make the uuuuu bit pattern in the scalar value // so the surrogate pair don't address the BMP." int wwww = ((highSurrogate & 0x03C0) >> 6); int uuuuu = wwww + 1; // next 4 bits int zzzz = (highSurrogate & 0x003C) >> 2; // low 2 bits int yyyyyy = ((highSurrogate & 0x0003) << 4) & 0x30; // Get low surrogate character. ch = chars[++i]; // Clear high 6 bits. int lowSurrogate = ((int) ch) & 0x03FF; // put the middle 4 bits into the bottom of yyyyyy (byte 3) yyyyyy = yyyyyy | ((lowSurrogate & 0x03C0) >> 6); // bottom 6 bits. int xxxxxx = (lowSurrogate & 0x003F); int byte1 = 0xF0 | (uuuuu >> 2); // top 3 bits of uuuuu int byte2 = 0x80 | (((uuuuu & 0x03) << 4) & 0x30) | zzzz; int byte3 = 0x80 | yyyyyy; int byte4 = 0x80 | xxxxxx; writer.write('%'); writer.write(makeHHString(byte1)); writer.write('%'); writer.write(makeHHString(byte2)); writer.write('%'); writer.write(makeHHString(byte3)); writer.write('%'); writer.write(makeHHString(byte4)); } else { int high = (ch >> 12) | 0xE0; // top 4 bits int middle = ((ch & 0x0FC0) >> 6) | 0x80; // middle 6 bits int low = (ch & 0x3F) | 0x80; // First 6 bits, + high bit writer.write('%'); writer.write(makeHHString(high)); writer.write('%'); writer.write(makeHHString(middle)); writer.write('%'); writer.write(makeHHString(low)); } } else if (escapingNotNeeded(ch)) { writer.write(ch); } else { writer.write("&#"); writer.write(Integer.toString(ch)); writer.write(';'); } // In this character range we have first written out any previously accumulated // "clean" characters, then processed the current more complicated character, // which may have incremented "i". // We now we reset the next possible clean character. cleanStart = i + 1; } // Since http://www.ietf.org/rfc/rfc2396.txt refers to the URI grammar as // not allowing quotes in the URI proper syntax, nor in the fragment // identifier, we believe that it's OK to double escape quotes. else if (ch == '"') { // If the character is a '%' number number, try to avoid double-escaping. // There is a question if this is legal behavior. // Dmitri Ilyin: to check if '%' number number is invalid. It must be checked if %xx is a sign, that would be encoded // The encoded signes are in Hex form. So %xx my be in form %3C that is "<" sign. I will try to change here a little. // if( ((i+2) < len) && isASCIIDigit(stringArray[i+1]) && isASCIIDigit(stringArray[i+2]) ) // We are no longer escaping '%' if (cleanLength > 0) { writer.write(chars, cleanStart, cleanLength); cleanLength = 0; } // Mike Kay encodes this as &#34;, so he may know something I don't? if (doURLEscaping) writer.write("%22"); else writer.write("&quot;"); // we have to escape this, I guess. // We have written out any clean characters, then the escaped '%' and now we // We now we reset the next possible clean character. cleanStart = i + 1; } else if (ch == '&') { // HTML 4.01 reads, "Authors should use "&amp;" (ASCII decimal 38) // instead of "&" to avoid confusion with the beginning of a character // reference (entity reference open delimiter). if (cleanLength > 0) { writer.write(chars, cleanStart, cleanLength); cleanLength = 0; } writer.write("&amp;"); cleanStart = i + 1; } else { // no processing for this character, just count how // many characters in a row that we have that need no processing cleanLength++; } } // are there any clean characters at the end of the array // that we haven't processed yet? if (cleanLength > 1) { // if the whole string can be written out as-is do so // otherwise write out the clean chars at the end of the // array if (cleanStart == 0) writer.write(string); else writer.write(chars, cleanStart, cleanLength); } else if (cleanLength == 1) { // a little optimization for 1 clean character // (we could have let the previous if(...) handle them all) writer.write(ch); } }
Write the specified <var>string</var> after substituting non ASCII characters, with <CODE>%HH</CODE>, where HH is the hex of the byte value. @param string String to convert to XML format. @param doURLEscaping True if we should try to encode as per http://www.ietf.org/rfc/rfc2396.txt. @throws org.xml.sax.SAXException if a bad surrogate pair is detected.
ToHTMLStream::writeAttrURI
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
Apache-2.0
public void writeAttrString( final java.io.Writer writer, String string, String encoding) throws IOException { final int end = string.length(); if (end > m_attrBuff.length) { m_attrBuff = new char[end * 2 + 1]; } string.getChars(0, end, m_attrBuff, 0); final char[] chars = m_attrBuff; int cleanStart = 0; int cleanLength = 0; char ch = 0; for (int i = 0; i < end; i++) { ch = chars[i]; // System.out.println("SPECIALSSIZE: "+SPECIALSSIZE); // System.out.println("ch: "+(int)ch); // System.out.println("m_maxCharacter: "+(int)m_maxCharacter); // System.out.println("m_attrCharsMap[ch]: "+(int)m_attrCharsMap[ch]); if (escapingNotNeeded(ch) && (!m_charInfo.shouldMapAttrChar(ch))) { cleanLength++; } else if ('<' == ch || '>' == ch) { cleanLength++; // no escaping in this case, as specified in 15.2 } else if ( ('&' == ch) && ((i + 1) < end) && ('{' == chars[i + 1])) { cleanLength++; // no escaping in this case, as specified in 15.2 } else { if (cleanLength > 0) { writer.write(chars,cleanStart,cleanLength); cleanLength = 0; } int pos = accumDefaultEntity(writer, ch, i, chars, end, false, true); if (i != pos) { i = pos - 1; } else { if (Encodings.isHighUTF16Surrogate(ch)) { writeUTF16Surrogate(ch, chars, i, end); i++; // two input characters processed // this increments by one and the for() // loop itself increments by another one. } // The next is kind of a hack to keep from escaping in the case // of Shift_JIS and the like. /* else if ((ch < m_maxCharacter) && (m_maxCharacter == 0xFFFF) && (ch != 160)) { writer.write(ch); // no escaping in this case } else */ String outputStringForChar = m_charInfo.getOutputStringForChar(ch); if (null != outputStringForChar) { writer.write(outputStringForChar); } else if (escapingNotNeeded(ch)) { writer.write(ch); // no escaping in this case } else { writer.write("&#"); writer.write(Integer.toString(ch)); writer.write(';'); } } cleanStart = i + 1; } } // end of for() // are there any clean characters at the end of the array // that we haven't processed yet? if (cleanLength > 1) { // if the whole string can be written out as-is do so // otherwise write out the clean chars at the end of the // array if (cleanStart == 0) writer.write(string); else writer.write(chars, cleanStart, cleanLength); } else if (cleanLength == 1) { // a little optimization for 1 clean character // (we could have let the previous if(...) handle them all) writer.write(ch); } }
Writes the specified <var>string</var> after substituting <VAR>specials</VAR>, and UTF-16 surrogates for character references <CODE>&amp;#xnn</CODE>. @param string String to convert to XML format. @param encoding CURRENTLY NOT IMPLEMENTED. @throws org.xml.sax.SAXException
ToHTMLStream::writeAttrString
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
Apache-2.0
public final void entityReference(String name) throws org.xml.sax.SAXException { try { final java.io.Writer writer = m_writer; writer.write('&'); writer.write(name); writer.write(';'); } catch(IOException e) { throw new SAXException(e); } }
Receive notivication of a entityReference. @param name non-null reference to entity name string. @throws org.xml.sax.SAXException
ToHTMLStream::entityReference
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
Apache-2.0
public void processAttributes(java.io.Writer writer, int nAttrs) throws IOException,SAXException { /* * process the collected attributes */ for (int i = 0; i < nAttrs; i++) { processAttribute( writer, m_attributes.getQName(i), m_attributes.getValue(i), m_elemContext.m_elementDesc); } }
Process the attributes, which means to write out the currently collected attributes to the writer. The attributes are not cleared by this method @param writer the writer to write processed attributes to. @param nAttrs the number of attributes in m_attributes to be processed @throws org.xml.sax.SAXException
ToHTMLStream::processAttributes
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
Apache-2.0
protected void closeStartTag() throws SAXException { try { // finish processing attributes, time to fire off the start element event if (m_tracer != null) super.fireStartElem(m_elemContext.m_elementName); int nAttrs = m_attributes.getLength(); if (nAttrs>0) { processAttributes(m_writer, nAttrs); // clear attributes object for re-use with next element m_attributes.clear(); } m_writer.write('>'); /* At this point we have the prefix mappings now, so * lets determine if the current element is specified in the cdata- * section-elements list. */ if (m_CdataElems != null) // if there are any cdata sections m_elemContext.m_isCdataSection = isCdataSection(); if (m_doIndent) { m_isprevtext = false; m_preserves.push(m_ispreserve); } } catch(IOException e) { throw new SAXException(e); } }
For the enclosing elements starting tag write out out any attributes followed by ">". At this point we also mark if this element is a cdata-section-element. @throws org.xml.sax.SAXException
ToHTMLStream::closeStartTag
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
Apache-2.0
public void attributeDecl( String eName, String aName, String type, String valueDefault, String value) throws SAXException { // The internal DTD subset is not serialized by the ToHTMLStream serializer }
This method does nothing.
ToHTMLStream::attributeDecl
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
Apache-2.0
public Trie() { m_Root = new Node(); m_lowerCaseOnly = false; }
Construct the trie that has a case insensitive search.
Trie::Trie
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
Apache-2.0
public Trie(boolean lowerCaseOnly) { m_Root = new Node(); m_lowerCaseOnly = lowerCaseOnly; }
Construct the trie given the desired case sensitivity with the key. @param lowerCaseOnly true if the search keys are to be loser case only, not case insensitive.
Trie::Trie
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
Apache-2.0
public Object put(String key, Object value) { final int len = key.length(); if (len > m_charBuffer.length) { // make the biggest buffer ever needed in get(String) m_charBuffer = new char[len]; } Node node = m_Root; for (int i = 0; i < len; i++) { Node nextNode = node.m_nextChar[Character.toLowerCase(key.charAt(i))]; if (nextNode != null) { node = nextNode; } else { for (; i < len; i++) { Node newNode = new Node(); if (m_lowerCaseOnly) { // put this value into the tree only with a lower case key node.m_nextChar[Character.toLowerCase( key.charAt(i))] = newNode; } else { // put this value into the tree with a case insensitive key node.m_nextChar[Character.toUpperCase( key.charAt(i))] = newNode; node.m_nextChar[Character.toLowerCase( key.charAt(i))] = newNode; } node = newNode; } break; } } Object ret = node.m_Value; node.m_Value = value; return ret; }
Put an object into the trie for lookup. @param key must be a 7-bit ASCII string @param value any java object. @return The old object that matched key, or null.
Trie::put
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
Apache-2.0
public Object get(final String key) { final int len = key.length(); /* If the name is too long, we won't find it, this also keeps us * from overflowing m_charBuffer */ if (m_charBuffer.length < len) return null; Node node = m_Root; switch (len) // optimize the look up based on the number of chars { // case 0 looks silly, but the generated bytecode runs // faster for lookup of elements of length 2 with this in // and a fair bit faster. Don't know why. case 0 : { return null; } case 1 : { final char ch = key.charAt(0); if (ch < ALPHA_SIZE) { node = node.m_nextChar[ch]; if (node != null) return node.m_Value; } return null; } // comment out case 2 because the default is faster // case 2 : // { // final char ch0 = key.charAt(0); // final char ch1 = key.charAt(1); // if (ch0 < ALPHA_SIZE && ch1 < ALPHA_SIZE) // { // node = node.m_nextChar[ch0]; // if (node != null) // { // // if (ch1 < ALPHA_SIZE) // { // node = node.m_nextChar[ch1]; // if (node != null) // return node.m_Value; // } // } // } // return null; // } default : { for (int i = 0; i < len; i++) { // A thread-safe way to loop over the characters final char ch = key.charAt(i); if (ALPHA_SIZE <= ch) { // the key is not 7-bit ASCII so we won't find it here return null; } node = node.m_nextChar[ch]; if (node == null) return null; } return node.m_Value; } } }
Get an object that matches the key. @param key must be a 7-bit ASCII string @return The object that matches the key, or null.
Trie::get
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
Apache-2.0
Node() { m_nextChar = new Node[ALPHA_SIZE]; m_Value = null; }
Constructor, creates a Node[ALPHA_SIZE].
Node::Node
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
Apache-2.0
public Trie(Trie existingTrie) { // copy some fields from the existing Trie into this one. m_Root = existingTrie.m_Root; m_lowerCaseOnly = existingTrie.m_lowerCaseOnly; // get a buffer just big enough to hold the longest key in the table. int max = existingTrie.getLongestKeyLength(); m_charBuffer = new char[max]; }
Construct the trie from another Trie. Both the existing Trie and this new one share the same table for lookup, and it is assumed that the table is fully populated and not changing anymore. @param existingTrie the Trie that this one is a copy of.
Node::Trie
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
Apache-2.0
public Object get2(final String key) { final int len = key.length(); /* If the name is too long, we won't find it, this also keeps us * from overflowing m_charBuffer */ if (m_charBuffer.length < len) return null; Node node = m_Root; switch (len) // optimize the look up based on the number of chars { // case 0 looks silly, but the generated bytecode runs // faster for lookup of elements of length 2 with this in // and a fair bit faster. Don't know why. case 0 : { return null; } case 1 : { final char ch = key.charAt(0); if (ch < ALPHA_SIZE) { node = node.m_nextChar[ch]; if (node != null) return node.m_Value; } return null; } default : { /* Copy string into array. This is not thread-safe because * it modifies the contents of m_charBuffer. If multiple * threads were to use this Trie they all would be * using this same array (not good). So this * method is not thread-safe, but it is faster because * converting to a char[] and looping over elements of * the array is faster than a String's charAt(i). */ key.getChars(0, len, m_charBuffer, 0); for (int i = 0; i < len; i++) { final char ch = m_charBuffer[i]; if (ALPHA_SIZE <= ch) { // the key is not 7-bit ASCII so we won't find it here return null; } node = node.m_nextChar[ch]; if (node == null) return null; } return node.m_Value; } } }
Get an object that matches the key. This method is faster than get(), but is not thread-safe. @param key must be a 7-bit ASCII string @return The object that matches the key, or null.
Node::get2
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
Apache-2.0
public int getLongestKeyLength() { return m_charBuffer.length; }
Get the length of the longest key used in the table.
Node::getLongestKeyLength
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToHTMLStream.java
Apache-2.0
public WriterToUTF8Buffered(OutputStream out) { m_os = out; // get 3 extra bytes to make buffer overflow checking simpler and faster // we won't have to keep checking for a few extra characters m_outputBytes = new byte[BYTES_MAX + 3]; // Big enough to hold the input chars that will be transformed // into output bytes in m_ouputBytes. m_inputChars = new char[CHARS_MAX + 2]; count = 0; // the old body of this constructor, before the buffersize was changed to a constant // this(out, 8*1024); }
Create an buffered UTF-8 writer. @param out the underlying output stream. @throws UnsupportedEncodingException
WriterToUTF8Buffered::WriterToUTF8Buffered
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/WriterToUTF8Buffered.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/WriterToUTF8Buffered.java
Apache-2.0
public void write(final int c) throws IOException { /* If we are close to the end of the buffer then flush it. * Remember the buffer can hold a few more bytes than BYTES_MAX */ if (count >= BYTES_MAX) flushBuffer(); if (c < 0x80) { m_outputBytes[count++] = (byte) (c); } else if (c < 0x800) { m_outputBytes[count++] = (byte) (0xc0 + (c >> 6)); m_outputBytes[count++] = (byte) (0x80 + (c & 0x3f)); } else if (c < 0x10000) { m_outputBytes[count++] = (byte) (0xe0 + (c >> 12)); m_outputBytes[count++] = (byte) (0x80 + ((c >> 6) & 0x3f)); m_outputBytes[count++] = (byte) (0x80 + (c & 0x3f)); } else { m_outputBytes[count++] = (byte) (0xf0 + (c >> 18)); m_outputBytes[count++] = (byte) (0x80 + ((c >> 12) & 0x3f)); m_outputBytes[count++] = (byte) (0x80 + ((c >> 6) & 0x3f)); m_outputBytes[count++] = (byte) (0x80 + (c & 0x3f)); } }
Write a single character. The character to be written is contained in the 16 low-order bits of the given integer value; the 16 high-order bits are ignored. <p> Subclasses that intend to support efficient single-character output should override this method. @param c int specifying a character to be written. @exception IOException If an I/O error occurs
WriterToUTF8Buffered::write
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/WriterToUTF8Buffered.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/WriterToUTF8Buffered.java
Apache-2.0
public void write(final char chars[], final int start, final int length) throws java.io.IOException { // We multiply the length by three since this is the maximum length // of the characters that we can put into the buffer. It is possible // for each Unicode character to expand to three bytes. int lengthx3 = 3*length; if (lengthx3 >= BYTES_MAX - count) { // The requested length is greater than the unused part of the buffer flushBuffer(); if (lengthx3 > BYTES_MAX) { /* * The requested length exceeds the size of the buffer. * Cut the buffer up into chunks, each of which will * not cause an overflow to the output buffer m_outputBytes, * and make multiple recursive calls. * Be careful about integer overflows in multiplication. */ int split = length/CHARS_MAX; final int chunks; if (length % CHARS_MAX > 0) chunks = split + 1; else chunks = split; int end_chunk = start; for (int chunk = 1; chunk <= chunks; chunk++) { int start_chunk = end_chunk; end_chunk = start + (int) ((((long) length) * chunk) / chunks); // Adjust the end of the chunk if it ends on a high char // of a Unicode surrogate pair and low char of the pair // is not going to be in the same chunk final char c = chars[end_chunk - 1]; int ic = chars[end_chunk - 1]; if (c >= 0xD800 && c <= 0xDBFF) { // The last Java char that we were going // to process is the first of a // Java surrogate char pair that // represent a Unicode character. if (end_chunk < start + length) { // Avoid spanning by including the low // char in the current chunk of chars. end_chunk++; } else { /* This is the last char of the last chunk, * and it is the high char of a high/low pair with * no low char provided. * TODO: error message needed. * The char array incorrectly ends in a high char * of a high/low surrogate pair, but there is * no corresponding low as the high is the last char */ end_chunk--; } } int len_chunk = (end_chunk - start_chunk); this.write(chars,start_chunk, len_chunk); } return; } } final int n = length+start; final byte[] buf_loc = m_outputBytes; // local reference for faster access int count_loc = count; // local integer for faster access int i = start; { /* This block could be omitted and the code would produce * the same result. But this block exists to give the JIT * a better chance of optimizing a tight and common loop which * occurs when writing out ASCII characters. */ char c; for(; i < n && (c = chars[i])< 0x80 ; i++ ) buf_loc[count_loc++] = (byte)c; } for (; i < n; i++) { final char c = chars[i]; if (c < 0x80) buf_loc[count_loc++] = (byte) (c); else if (c < 0x800) { buf_loc[count_loc++] = (byte) (0xc0 + (c >> 6)); buf_loc[count_loc++] = (byte) (0x80 + (c & 0x3f)); } /** * The following else if condition is added to support XML 1.1 Characters for * UTF-8: [1111 0uuu] [10uu zzzz] [10yy yyyy] [10xx xxxx]* * Unicode: [1101 10ww] [wwzz zzyy] (high surrogate) * [1101 11yy] [yyxx xxxx] (low surrogate) * * uuuuu = wwww + 1 */ else if (c >= 0xD800 && c <= 0xDBFF) { char high, low; high = c; i++; low = chars[i]; buf_loc[count_loc++] = (byte) (0xF0 | (((high + 0x40) >> 8) & 0xf0)); buf_loc[count_loc++] = (byte) (0x80 | (((high + 0x40) >> 2) & 0x3f)); buf_loc[count_loc++] = (byte) (0x80 | ((low >> 6) & 0x0f) + ((high << 4) & 0x30)); buf_loc[count_loc++] = (byte) (0x80 | (low & 0x3f)); } else { buf_loc[count_loc++] = (byte) (0xe0 + (c >> 12)); buf_loc[count_loc++] = (byte) (0x80 + ((c >> 6) & 0x3f)); buf_loc[count_loc++] = (byte) (0x80 + (c & 0x3f)); } } // Store the local integer back into the instance variable count = count_loc; }
Write a portion of an array of characters. @param chars Array of characters @param start Offset from which to start writing characters @param length Number of characters to write @exception IOException If an I/O error occurs @throws java.io.IOException
WriterToUTF8Buffered::write
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/WriterToUTF8Buffered.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/WriterToUTF8Buffered.java
Apache-2.0
public void write(final String s) throws IOException { // We multiply the length by three since this is the maximum length // of the characters that we can put into the buffer. It is possible // for each Unicode character to expand to three bytes. final int length = s.length(); int lengthx3 = 3*length; if (lengthx3 >= BYTES_MAX - count) { // The requested length is greater than the unused part of the buffer flushBuffer(); if (lengthx3 > BYTES_MAX) { /* * The requested length exceeds the size of the buffer, * so break it up in chunks that don't exceed the buffer size. */ final int start = 0; int split = length/CHARS_MAX; final int chunks; if (length % CHARS_MAX > 0) chunks = split + 1; else chunks = split; int end_chunk = 0; for (int chunk = 1; chunk <= chunks; chunk++) { int start_chunk = end_chunk; end_chunk = start + (int) ((((long) length) * chunk) / chunks); s.getChars(start_chunk,end_chunk, m_inputChars,0); int len_chunk = (end_chunk - start_chunk); // Adjust the end of the chunk if it ends on a high char // of a Unicode surrogate pair and low char of the pair // is not going to be in the same chunk final char c = m_inputChars[len_chunk - 1]; if (c >= 0xD800 && c <= 0xDBFF) { // Exclude char in this chunk, // to avoid spanning a Unicode character // that is in two Java chars as a high/low surrogate end_chunk--; len_chunk--; if (chunk == chunks) { /* TODO: error message needed. * The String incorrectly ends in a high char * of a high/low surrogate pair, but there is * no corresponding low as the high is the last char * Recover by ignoring this last char. */ } } this.write(m_inputChars,0, len_chunk); } return; } } s.getChars(0, length , m_inputChars, 0); final char[] chars = m_inputChars; final int n = length; final byte[] buf_loc = m_outputBytes; // local reference for faster access int count_loc = count; // local integer for faster access int i = 0; { /* This block could be omitted and the code would produce * the same result. But this block exists to give the JIT * a better chance of optimizing a tight and common loop which * occurs when writing out ASCII characters. */ char c; for(; i < n && (c = chars[i])< 0x80 ; i++ ) buf_loc[count_loc++] = (byte)c; } for (; i < n; i++) { final char c = chars[i]; if (c < 0x80) buf_loc[count_loc++] = (byte) (c); else if (c < 0x800) { buf_loc[count_loc++] = (byte) (0xc0 + (c >> 6)); buf_loc[count_loc++] = (byte) (0x80 + (c & 0x3f)); } /** * The following else if condition is added to support XML 1.1 Characters for * UTF-8: [1111 0uuu] [10uu zzzz] [10yy yyyy] [10xx xxxx]* * Unicode: [1101 10ww] [wwzz zzyy] (high surrogate) * [1101 11yy] [yyxx xxxx] (low surrogate) * * uuuuu = wwww + 1 */ else if (c >= 0xD800 && c <= 0xDBFF) { char high, low; high = c; i++; low = chars[i]; buf_loc[count_loc++] = (byte) (0xF0 | (((high + 0x40) >> 8) & 0xf0)); buf_loc[count_loc++] = (byte) (0x80 | (((high + 0x40) >> 2) & 0x3f)); buf_loc[count_loc++] = (byte) (0x80 | ((low >> 6) & 0x0f) + ((high << 4) & 0x30)); buf_loc[count_loc++] = (byte) (0x80 | (low & 0x3f)); } else { buf_loc[count_loc++] = (byte) (0xe0 + (c >> 12)); buf_loc[count_loc++] = (byte) (0x80 + ((c >> 6) & 0x3f)); buf_loc[count_loc++] = (byte) (0x80 + (c & 0x3f)); } } // Store the local integer back into the instance variable count = count_loc; }
Write a string. @param s String to be written @exception IOException If an I/O error occurs
WriterToUTF8Buffered::write
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/WriterToUTF8Buffered.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/WriterToUTF8Buffered.java
Apache-2.0
public void flushBuffer() throws IOException { if (count > 0) { m_os.write(m_outputBytes, 0, count); count = 0; } }
Flush the internal buffer @throws IOException
WriterToUTF8Buffered::flushBuffer
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/WriterToUTF8Buffered.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/WriterToUTF8Buffered.java
Apache-2.0
public void flush() throws java.io.IOException { flushBuffer(); m_os.flush(); }
Flush the stream. If the stream has saved any characters from the various write() methods in a buffer, write them immediately to their intended destination. Then, if that destination is another character or byte stream, flush it. Thus one flush() invocation will flush all the buffers in a chain of Writers and OutputStreams. @exception IOException If an I/O error occurs @throws java.io.IOException
WriterToUTF8Buffered::flush
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/WriterToUTF8Buffered.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/WriterToUTF8Buffered.java
Apache-2.0
public void close() throws java.io.IOException { flushBuffer(); m_os.close(); }
Close the stream, flushing it first. Once a stream has been closed, further write() or flush() invocations will cause an IOException to be thrown. Closing a previously-closed stream, however, has no effect. @exception IOException If an I/O error occurs @throws java.io.IOException
WriterToUTF8Buffered::close
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/WriterToUTF8Buffered.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/WriterToUTF8Buffered.java
Apache-2.0
static public final Properties getDefaultMethodProperties(String method) { String fileName = null; Properties defaultProperties = null; // According to this article : Double-check locking does not work // http://www.javaworld.com/javaworld/jw-02-2001/jw-0209-toolbox.html try { synchronized (m_synch_object) { if (null == m_xml_properties) // double check { fileName = PROP_FILE_XML; m_xml_properties = loadPropertiesFile(fileName, null); } } if (method.equals(Method.XML)) { defaultProperties = m_xml_properties; } else if (method.equals(Method.HTML)) { if (null == m_html_properties) // double check { fileName = PROP_FILE_HTML; m_html_properties = loadPropertiesFile(fileName, m_xml_properties); } defaultProperties = m_html_properties; } else if (method.equals(Method.TEXT)) { if (null == m_text_properties) // double check { fileName = PROP_FILE_TEXT; m_text_properties = loadPropertiesFile(fileName, m_xml_properties); if (null == m_text_properties.getProperty(OutputKeys.ENCODING)) { String mimeEncoding = Encodings.getMimeEncoding(null); m_text_properties.put( OutputKeys.ENCODING, mimeEncoding); } } defaultProperties = m_text_properties; } else if (method.equals(Method.UNKNOWN)) { if (null == m_unknown_properties) // double check { fileName = PROP_FILE_UNKNOWN; m_unknown_properties = loadPropertiesFile(fileName, m_xml_properties); } defaultProperties = m_unknown_properties; } else { // TODO: Calculate res file from name. defaultProperties = m_xml_properties; } } catch (IOException ioe) { throw new WrappedRuntimeException( Utils.messages.createMessage( MsgKey.ER_COULD_NOT_LOAD_METHOD_PROPERTY, new Object[] { fileName, method }), ioe); } // wrap these cached defaultProperties in a new Property object just so // that the caller of this method can't modify the default values return new Properties(defaultProperties); }
Creates an empty OutputProperties with the property key/value defaults specified by a property file. The method argument is used to construct a string of the form output_[method].properties (for instance, output_html.properties). The output_xml.properties file is always used as the base. <p>Anything other than 'text', 'xml', and 'html', will use the output_xml.properties file.</p> @param method non-null reference to method name. @return Properties object that holds the defaults for the given method.
OutputPropertiesFactory::getDefaultMethodProperties
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/OutputPropertiesFactory.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/OutputPropertiesFactory.java
Apache-2.0
static private String fixupPropertyString(String s, boolean doClipping) { int index; if (doClipping && s.startsWith(S_XSLT_PREFIX)) { s = s.substring(S_XSLT_PREFIX_LEN); } if (s.startsWith(S_XALAN_PREFIX)) { s = S_BUILTIN_EXTENSIONS_UNIVERSAL + s.substring(S_XALAN_PREFIX_LEN); } if ((index = s.indexOf("\\u003a")) > 0) { String temp = s.substring(index + 6); s = s.substring(0, index) + ":" + temp; } return s; }
Fix up a string in an output properties file according to the rules of {@link #loadPropertiesFile}. @param s non-null reference to string that may need to be fixed up. @return A new string if fixup occured, otherwise the s argument.
(anonymous)::fixupPropertyString
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/OutputPropertiesFactory.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/OutputPropertiesFactory.java
Apache-2.0
private CharInfo() { this.array_of_bits = createEmptySetOfIntegers(65535); this.firstWordNotUsed = 0; this.shouldMapAttrChar_ASCII = new boolean[ASCII_MAX]; this.shouldMapTextChar_ASCII = new boolean[ASCII_MAX]; this.m_charKey = new CharKey(); // Not set here, but in a constructor that uses this one // this.m_charToString = new Hashtable(); this.onlyQuotAmpLtGt = true; return; }
A base constructor just to explicitly create the fields, with the exception of m_charToString which is handled by the constructor that delegates base construction to this one. <p> m_charToString is not created here only for performance reasons, to avoid creating a Hashtable that will be replaced when making a mutable copy, {@link #mutableCopyOf(CharInfo)}.
CharInfo::CharInfo
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/CharInfo.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/CharInfo.java
Apache-2.0
private boolean defineEntity(String name, char value) { StringBuffer sb = new StringBuffer("&"); sb.append(name); sb.append(';'); String entityString = sb.toString(); boolean extra = defineChar2StringMapping(entityString, value); return extra; }
Defines a new character reference. The reference's name and value are supplied. Nothing happens if the character reference is already defined. <p>Unlike internal entities, character references are a string to single character mapping. They are used to map non-ASCII characters both on parsing and printing, primarily for HTML documents. '&amp;lt;' is an example of a character reference.</p> @param name The entity's name @param value The entity's value @return true if the mapping is not one of: <ul> <li> '<' to "&lt;" <li> '>' to "&gt;" <li> '&' to "&amp;" <li> '"' to "&quot;" </ul>
CharInfo::defineEntity
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/CharInfo.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/CharInfo.java
Apache-2.0
String getOutputStringForChar(char value) { // CharKey m_charKey = new CharKey(); //Alternative to synchronized m_charKey.setChar(value); return (String) m_charToString.get(m_charKey); }
Map a character to a String. For example given the character '>' this method would return the fully decorated entity name "&lt;". Strings for entity references are loaded from a properties file, but additional mappings defined through calls to defineChar2String() are possible. Such entity reference mappings could be over-ridden. This is reusing a stored key object, in an effort to avoid heap activity. Unfortunately, that introduces a threading risk. Simplest fix for now is to make it a synchronized method, or to give up the reuse; I see very little performance difference between them. Long-term solution would be to replace the hashtable with a sparse array keyed directly from the character's integer value; see DTM's string pool for a related solution. @param value The character that should be resolved to a String, e.g. resolve '>' to "&lt;". @return The String that the character is mapped to, or null if not found. @xsl.usage internal
CharInfo::getOutputStringForChar
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/CharInfo.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/CharInfo.java
Apache-2.0
final boolean shouldMapAttrChar(int value) { // for performance try the values in the boolean array first, // this is faster access than the BitSet for common ASCII values if (value < ASCII_MAX) return shouldMapAttrChar_ASCII[value]; // rather than java.util.BitSet, our private // implementation is faster (and less general). return get(value); }
Tell if the character argument that is from an attribute value has a mapping to a String. @param value the value of a character that is in an attribute value @return true if the character should have any special treatment, such as when writing out entity references. @xsl.usage internal
CharInfo::shouldMapAttrChar
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/CharInfo.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/CharInfo.java
Apache-2.0
final boolean shouldMapTextChar(int value) { // for performance try the values in the boolean array first, // this is faster access than the BitSet for common ASCII values if (value < ASCII_MAX) return shouldMapTextChar_ASCII[value]; // rather than java.util.BitSet, our private // implementation is faster (and less general). return get(value); }
Tell if the character argument that is from a text node has a mapping to a String, for example to map '<' to "&lt;". @param value the value of a character that is in a text node @return true if the character has a mapping to a String, such as when writing out entity references. @xsl.usage internal
CharInfo::shouldMapTextChar
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/CharInfo.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/CharInfo.java
Apache-2.0
static CharInfo getCharInfo(String entitiesFileName, String method) { CharInfo charInfo = (CharInfo) m_getCharInfoCache.get(entitiesFileName); if (charInfo != null) { return mutableCopyOf(charInfo); } // try to load it internally - cache try { charInfo = getCharInfoBasedOnPrivilege(entitiesFileName, method, true); // Put the common copy of charInfo in the cache, but return // a copy of it. m_getCharInfoCache.put(entitiesFileName, charInfo); return mutableCopyOf(charInfo); } catch (Exception e) {} // try to load it externally - do not cache try { return getCharInfoBasedOnPrivilege(entitiesFileName, method, false); } catch (Exception e) {} String absoluteEntitiesFileName; if (entitiesFileName.indexOf(':') < 0) { absoluteEntitiesFileName = SystemIDResolver.getAbsoluteURIFromRelative(entitiesFileName); } else { try { absoluteEntitiesFileName = SystemIDResolver.getAbsoluteURI(entitiesFileName, null); } catch (TransformerException te) { throw new WrappedRuntimeException(te); } } return getCharInfoBasedOnPrivilege(entitiesFileName, method, false); }
Factory that reads in a resource file that describes the mapping of characters to entity references. Resource files must be encoded in UTF-8 and have a format like: <pre> # First char # is a comment Entity numericValue quot 34 amp 38 </pre> (Note: Why don't we just switch to .properties files? Oct-01 -sc) @param entitiesResource Name of entities resource file that should be loaded, which describes that mapping of characters to entity references. @param method the output method type, which should be one of "xml", "html", "text"... @xsl.usage internal
CharInfo::getCharInfo
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/CharInfo.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/CharInfo.java
Apache-2.0
private static CharInfo mutableCopyOf(CharInfo charInfo) { CharInfo copy = new CharInfo(); int max = charInfo.array_of_bits.length; System.arraycopy(charInfo.array_of_bits,0,copy.array_of_bits,0,max); copy.firstWordNotUsed = charInfo.firstWordNotUsed; max = charInfo.shouldMapAttrChar_ASCII.length; System.arraycopy(charInfo.shouldMapAttrChar_ASCII,0,copy.shouldMapAttrChar_ASCII,0,max); max = charInfo.shouldMapTextChar_ASCII.length; System.arraycopy(charInfo.shouldMapTextChar_ASCII,0,copy.shouldMapTextChar_ASCII,0,max); // utility field copy.m_charKey is already created in the default constructor copy.m_charToString = (HashMap) charInfo.m_charToString.clone(); copy.onlyQuotAmpLtGt = charInfo.onlyQuotAmpLtGt; return copy; }
Create a mutable copy of the cached one. @param charInfo The cached one. @return
CharInfo::mutableCopyOf
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/CharInfo.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/CharInfo.java
Apache-2.0
private static int arrayIndex(int i) { return (i >> SHIFT_PER_WORD); }
Returns the array element holding the bit value for the given integer @param i the integer that might be in the set of integers
CharInfo::arrayIndex
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/CharInfo.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/CharInfo.java
Apache-2.0
private static int bit(int i) { int ret = (1 << (i & LOW_ORDER_BITMASK)); return ret; }
For a given integer in the set it returns the single bit value used within a given word that represents whether the integer is in the set or not.
CharInfo::bit
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/CharInfo.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/CharInfo.java
Apache-2.0
private int[] createEmptySetOfIntegers(int max) { firstWordNotUsed = 0; // an optimization int[] arr = new int[arrayIndex(max - 1) + 1]; return arr; }
Creates a new empty set of integers (characters) @param max the maximum integer to be in the set.
CharInfo::createEmptySetOfIntegers
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/CharInfo.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/CharInfo.java
Apache-2.0
private final void set(int i) { setASCIItextDirty(i); setASCIIattrDirty(i); int j = (i >> SHIFT_PER_WORD); // this word is used int k = j + 1; if(firstWordNotUsed < k) // for optimization purposes. firstWordNotUsed = k; array_of_bits[j] |= (1 << (i & LOW_ORDER_BITMASK)); }
Adds the integer (character) to the set of integers. @param i the integer to add to the set, valid values are 0, 1, 2 ... up to the maximum that was specified at the creation of the set.
CharInfo::set
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/CharInfo.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/CharInfo.java
Apache-2.0
private final boolean get(int i) { boolean in_the_set = false; int j = (i >> SHIFT_PER_WORD); // wordIndex(i) // an optimization here, ... a quick test to see // if this integer is beyond any of the words in use if(j < firstWordNotUsed) in_the_set = (array_of_bits[j] & (1 << (i & LOW_ORDER_BITMASK)) ) != 0; // 0L for 64 bit words return in_the_set; }
Return true if the integer (character)is in the set of integers. This implementation uses an array of integers with 32 bits per integer. If a bit is set to 1 the corresponding integer is in the set of integers. @param i an integer that is tested to see if it is the set of integers, or not.
CharInfo::get
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/CharInfo.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/CharInfo.java
Apache-2.0
private boolean extraEntity(String outputString, int charToMap) { boolean extra = false; if (charToMap < ASCII_MAX) { switch (charToMap) { case '"' : // quot if (!outputString.equals("&quot;")) extra = true; break; case '&' : // amp if (!outputString.equals("&amp;")) extra = true; break; case '<' : // lt if (!outputString.equals("&lt;")) extra = true; break; case '>' : // gt if (!outputString.equals("&gt;")) extra = true; break; default : // other entity in range 0 to 127 extra = true; } } return extra; }
This method returns true if there are some non-standard mappings to entities other than quot, amp, lt, gt, and its only purpose is for performance. @param charToMap The value of the character that is mapped to a String @param outputString The String to which the character is mapped, usually an entity reference such as "&lt;". @return true if the mapping is not one of: <ul> <li> '<' to "&lt;" <li> '>' to "&gt;" <li> '&' to "&amp;" <li> '"' to "&quot;" </ul>
CharInfo::extraEntity
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/CharInfo.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/CharInfo.java
Apache-2.0
private void setASCIItextDirty(int j) { if (0 <= j && j < ASCII_MAX) { shouldMapTextChar_ASCII[j] = true; } }
If the character is in the ASCII range then mark it as needing replacement with a String on output if it occurs in a text node. @param ch
CharInfo::setASCIItextDirty
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/CharInfo.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/CharInfo.java
Apache-2.0
private void setASCIIattrDirty(int j) { if (0 <= j && j < ASCII_MAX) { shouldMapAttrChar_ASCII[j] = true; } }
If the character is in the ASCII range then mark it as needing replacement with a String on output if it occurs in a attribute value. @param ch
CharInfo::setASCIIattrDirty
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/CharInfo.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/CharInfo.java
Apache-2.0
boolean defineChar2StringMapping(String outputString, char inputChar) { CharKey character = new CharKey(inputChar); m_charToString.put(character, outputString); set(inputChar); // mark the character has having a mapping to a String boolean extraMapping = extraEntity(outputString, inputChar); return extraMapping; }
Call this method to register a char to String mapping, for example to map '<' to "&lt;". @param outputString The String to map to. @param inputChar The char to map from. @return true if the mapping is not one of: <ul> <li> '<' to "&lt;" <li> '>' to "&gt;" <li> '&' to "&amp;" <li> '"' to "&quot;" </ul>
CharInfo::defineChar2StringMapping
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/CharInfo.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/CharInfo.java
Apache-2.0
public CharKey(char key) { m_char = key; }
Constructor CharKey @param key char value of this object.
CharKey::CharKey
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/CharInfo.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/CharInfo.java
Apache-2.0
public CharKey() { }
Default constructor for a CharKey. @param key char value of this object.
CharKey::CharKey
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/CharInfo.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/CharInfo.java
Apache-2.0
public final void setChar(char c) { m_char = c; }
Get the hash value of the character. @return hash value of the character.
CharKey::setChar
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/CharInfo.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/CharInfo.java
Apache-2.0
public final boolean equals(Object obj) { return ((CharKey)obj).m_char == m_char; }
Override of equals() for this object @param obj to compare to @return True if this object equals this string value
CharKey::equals
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/CharInfo.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/CharInfo.java
Apache-2.0
public void endElement(String elemName) throws SAXException { if (m_tracer != null) super.fireEndElem(elemName); }
From XSLTC @see ExtendedContentHandler#endElement(String)
ToTextSAXHandler::endElement
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
Apache-2.0
public void endElement(String arg0, String arg1, String arg2) throws SAXException { if (m_tracer != null) super.fireEndElem(arg2); }
@see org.xml.sax.ContentHandler#endElement(String, String, String)
ToTextSAXHandler::endElement
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
Apache-2.0
public ToTextSAXHandler(ContentHandler handler, String encoding) { super(handler,encoding); }
From XSLTC
ToTextSAXHandler::ToTextSAXHandler
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
Apache-2.0
public Properties getOutputFormat() { return null; }
@see Serializer#getOutputFormat()
ToTextSAXHandler::getOutputFormat
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
Apache-2.0
public OutputStream getOutputStream() { return null; }
@see Serializer#getOutputStream()
ToTextSAXHandler::getOutputStream
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
Apache-2.0
public Writer getWriter() { return null; }
@see Serializer#getWriter()
ToTextSAXHandler::getWriter
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
Apache-2.0
public void indent(int n) throws SAXException { }
Does nothing because the indent attribute is ignored for text output.
ToTextSAXHandler::indent
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
Apache-2.0
public boolean reset() { return false; }
@see Serializer#reset()
ToTextSAXHandler::reset
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
Apache-2.0
public void serialize(Node node) throws IOException { }
@see DOMSerializer#serialize(Node)
ToTextSAXHandler::serialize
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
Apache-2.0
public void setIndent(boolean indent) { }
@see SerializationHandler#setIndent(boolean)
ToTextSAXHandler::setIndent
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
Apache-2.0
public void setOutputFormat(Properties format) { }
@see Serializer#setOutputFormat(Properties)
ToTextSAXHandler::setOutputFormat
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
Apache-2.0
public void setOutputStream(OutputStream output) { }
@see Serializer#setOutputStream(OutputStream)
ToTextSAXHandler::setOutputStream
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
Apache-2.0
public void setWriter(Writer writer) { }
@see Serializer#setWriter(Writer)
ToTextSAXHandler::setWriter
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
Apache-2.0
public void addAttribute( String uri, String localName, String rawName, String type, String value, boolean XSLAttribute) { }
@see ExtendedContentHandler#addAttribute(String, String, String, String, String)
ToTextSAXHandler::addAttribute
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
Apache-2.0
public void attributeDecl( String arg0, String arg1, String arg2, String arg3, String arg4) throws SAXException { }
@see org.xml.sax.ext.DeclHandler#attributeDecl(String, String, String, String, String)
ToTextSAXHandler::attributeDecl
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
Apache-2.0
public void elementDecl(String arg0, String arg1) throws SAXException { }
@see org.xml.sax.ext.DeclHandler#elementDecl(String, String)
ToTextSAXHandler::elementDecl
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
Apache-2.0
public void externalEntityDecl(String arg0, String arg1, String arg2) throws SAXException { }
@see org.xml.sax.ext.DeclHandler#externalEntityDecl(String, String, String)
ToTextSAXHandler::externalEntityDecl
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
Apache-2.0
public void internalEntityDecl(String arg0, String arg1) throws SAXException { }
@see org.xml.sax.ext.DeclHandler#internalEntityDecl(String, String)
ToTextSAXHandler::internalEntityDecl
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
Apache-2.0
public void endPrefixMapping(String arg0) throws SAXException { }
@see org.xml.sax.ContentHandler#endPrefixMapping(String)
ToTextSAXHandler::endPrefixMapping
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
Apache-2.0
public void ignorableWhitespace(char[] arg0, int arg1, int arg2) throws SAXException { }
@see org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int)
ToTextSAXHandler::ignorableWhitespace
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
Apache-2.0
public void processingInstruction(String arg0, String arg1) throws SAXException { if (m_tracer != null) super.fireEscapingEvent(arg0, arg1); }
From XSLTC @see org.xml.sax.ContentHandler#processingInstruction(String, String)
ToTextSAXHandler::processingInstruction
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
Apache-2.0
public void setDocumentLocator(Locator arg0) { }
@see org.xml.sax.ContentHandler#setDocumentLocator(Locator)
ToTextSAXHandler::setDocumentLocator
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
Apache-2.0
public void skippedEntity(String arg0) throws SAXException { }
@see org.xml.sax.ContentHandler#skippedEntity(String)
ToTextSAXHandler::skippedEntity
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
Apache-2.0
public void startElement( String arg0, String arg1, String arg2, Attributes arg3) throws SAXException { flushPending(); super.startElement(arg0, arg1, arg2, arg3); }
@see org.xml.sax.ContentHandler#startElement(String, String, String, Attributes)
ToTextSAXHandler::startElement
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
Apache-2.0
public void endCDATA() throws SAXException { }
@see org.xml.sax.ext.LexicalHandler#endCDATA()
ToTextSAXHandler::endCDATA
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
Apache-2.0
public void endDTD() throws SAXException { }
@see org.xml.sax.ext.LexicalHandler#endDTD()
ToTextSAXHandler::endDTD
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
Apache-2.0
public void startCDATA() throws SAXException { }
@see org.xml.sax.ext.LexicalHandler#startCDATA()
ToTextSAXHandler::startCDATA
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
Apache-2.0
public void startEntity(String arg0) throws SAXException { }
@see org.xml.sax.ext.LexicalHandler#startEntity(String)
ToTextSAXHandler::startEntity
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
Apache-2.0
public void startElement( String elementNamespaceURI, String elementLocalName, String elementName) throws SAXException { super.startElement(elementNamespaceURI, elementLocalName, elementName); }
From XSLTC @see ExtendedContentHandler#startElement(String)
ToTextSAXHandler::startElement
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
Apache-2.0
public void endDocument() throws SAXException { flushPending(); m_saxHandler.endDocument(); if (m_tracer != null) super.fireEndDoc(); }
From XSLTC @see org.xml.sax.ContentHandler#endDocument()
ToTextSAXHandler::endDocument
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
Apache-2.0
public void characters(String characters) throws SAXException { final int length = characters.length(); if (length > m_charsBuff.length) { m_charsBuff = new char[length*2 + 1]; } characters.getChars(0, length, m_charsBuff, 0); m_saxHandler.characters(m_charsBuff, 0, length); }
@see ExtendedContentHandler#characters(String)
ToTextSAXHandler::characters
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
Apache-2.0
public void characters(char[] characters, int offset, int length) throws SAXException { m_saxHandler.characters(characters, offset, length); // time to fire off characters event if (m_tracer != null) super.fireCharEvent(characters, offset, length); }
@see org.xml.sax.ContentHandler#characters(char[], int, int)
ToTextSAXHandler::characters
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextSAXHandler.java
Apache-2.0
public WriterToASCI(OutputStream os) { m_os = os; }
Create an unbuffered ASCII writer. @param os The byte stream to write to.
WriterToASCI::WriterToASCI
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/WriterToASCI.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/WriterToASCI.java
Apache-2.0
public void write(String s) throws IOException { int n = s.length(); for (int i = 0; i < n; i++) { m_os.write(s.charAt(i)); } }
Write a string. @param s String to be written @exception IOException If an I/O error occurs
WriterToASCI::write
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/WriterToASCI.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/WriterToASCI.java
Apache-2.0
public void flush() throws java.io.IOException { m_os.flush(); }
Flush the stream. If the stream has saved any characters from the various write() methods in a buffer, write them immediately to their intended destination. Then, if that destination is another character or byte stream, flush it. Thus one flush() invocation will flush all the buffers in a chain of Writers and OutputStreams. @exception IOException If an I/O error occurs
WriterToASCI::flush
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/WriterToASCI.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/WriterToASCI.java
Apache-2.0
public void close() throws java.io.IOException { m_os.close(); }
Close the stream, flushing it first. Once a stream has been closed, further write() or flush() invocations will cause an IOException to be thrown. Closing a previously-closed stream, however, has no effect. @exception IOException If an I/O error occurs
WriterToASCI::close
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/WriterToASCI.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/WriterToASCI.java
Apache-2.0
public Writer getWriter() { return null; }
Get the writer that this writer directly chains to.
WriterToASCI::getWriter
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/WriterToASCI.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/WriterToASCI.java
Apache-2.0
public final int getIndex(String qname) { int index; if (super.getLength() < MAX) { // if we haven't got too many attributes let the // super class look it up index = super.getIndex(qname); return index; } // we have too many attributes and the super class is slow // so find it quickly using our Hashtable. Integer i = (Integer)m_indexFromQName.get(qname); if (i == null) index = -1; else index = i.intValue(); return index; }
This method gets the index of an attribute given its qName. @param qname the qualified name of the attribute, e.g. "prefix1:locName1" @return the integer index of the attribute. @see org.xml.sax.Attributes#getIndex(String)
AttributesImplSerializer::getIndex
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/AttributesImplSerializer.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/AttributesImplSerializer.java
Apache-2.0
public final void addAttribute( String uri, String local, String qname, String type, String val) { int index = super.getLength(); super.addAttribute(uri, local, qname, type, val); // (index + 1) is now the number of attributes // so either compare (index+1) to MAX, or compare index to (MAX-1) if (index < MAXMinus1) { return; } else if (index == MAXMinus1) { switchOverToHash(MAX); } else { /* add the key with the format of "prefix:localName" */ /* we have just added the attibute, its index is the old length */ Integer i = new Integer(index); m_indexFromQName.put(qname, i); /* now add with key of the format "{uri}localName" */ m_buff.setLength(0); m_buff.append('{').append(uri).append('}').append(local); String key = m_buff.toString(); m_indexFromQName.put(key, i); } return; }
This method adds the attribute, but also records its qName/index pair in the hashtable for fast lookup by getIndex(qName). @param uri the URI of the attribute @param local the local name of the attribute @param qname the qualified name of the attribute @param type the type of the attribute @param val the value of the attribute @see org.xml.sax.helpers.AttributesImpl#addAttribute(String, String, String, String, String) @see #getIndex(String)
AttributesImplSerializer::addAttribute
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/AttributesImplSerializer.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/AttributesImplSerializer.java
Apache-2.0
private void switchOverToHash(int numAtts) { for (int index = 0; index < numAtts; index++) { String qName = super.getQName(index); Integer i = new Integer(index); m_indexFromQName.put(qName, i); // Add quick look-up to find with uri/local name pair String uri = super.getURI(index); String local = super.getLocalName(index); m_buff.setLength(0); m_buff.append('{').append(uri).append('}').append(local); String key = m_buff.toString(); m_indexFromQName.put(key, i); } }
We are switching over to having a hash table for quick look up of attributes, but up until now we haven't kept any information in the Hashtable, so we now update the Hashtable. Future additional attributes will update the Hashtable as they are added. @param numAtts
AttributesImplSerializer::switchOverToHash
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/AttributesImplSerializer.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/AttributesImplSerializer.java
Apache-2.0
public final void clear() { int len = super.getLength(); super.clear(); if (MAX <= len) { // if we have had enough attributes and are // using the Hashtable, then clear the Hashtable too. m_indexFromQName.clear(); } }
This method clears the accumulated attributes. @see org.xml.sax.helpers.AttributesImpl#clear()
AttributesImplSerializer::clear
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/AttributesImplSerializer.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/AttributesImplSerializer.java
Apache-2.0
public final void setAttributes(Attributes atts) { super.setAttributes(atts); // we've let the super class add the attributes, but // we need to keep the hash table up to date ourselves for the // potentially new qName/index pairs for quick lookup. int numAtts = atts.getLength(); if (MAX <= numAtts) switchOverToHash(numAtts); }
This method sets the attributes, previous attributes are cleared, it also keeps the hashtable up to date for quick lookup via getIndex(qName). @param atts the attributes to copy into these attributes. @see org.xml.sax.helpers.AttributesImpl#setAttributes(Attributes) @see #getIndex(String)
AttributesImplSerializer::setAttributes
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/AttributesImplSerializer.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/AttributesImplSerializer.java
Apache-2.0
public final int getIndex(String uri, String localName) { int index; if (super.getLength() < MAX) { // if we haven't got too many attributes let the // super class look it up index = super.getIndex(uri,localName); return index; } // we have too many attributes and the super class is slow // so find it quickly using our Hashtable. // Form the key of format "{uri}localName" m_buff.setLength(0); m_buff.append('{').append(uri).append('}').append(localName); String key = m_buff.toString(); Integer i = (Integer)m_indexFromQName.get(key); if (i == null) index = -1; else index = i.intValue(); return index; }
This method gets the index of an attribute given its uri and locanName. @param uri the URI of the attribute name. @param localName the local namer (after the ':' ) of the attribute name. @return the integer index of the attribute. @see org.xml.sax.Attributes#getIndex(String)
AttributesImplSerializer::getIndex
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/AttributesImplSerializer.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/AttributesImplSerializer.java
Apache-2.0
protected void startDocumentInternal() throws org.xml.sax.SAXException { super.startDocumentInternal(); m_needToCallStartDocument = false; // No action for the moment. }
Receive notification of the beginning of a document. <p>The SAX parser will invoke this method only once, before any other methods in this interface or in DTDHandler (except for setDocumentLocator).</p> @throws org.xml.sax.SAXException Any SAX exception, possibly wrapping another exception. @throws org.xml.sax.SAXException
ToTextStream::startDocumentInternal
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextStream.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextStream.java
Apache-2.0
public void endDocument() throws org.xml.sax.SAXException { flushPending(); flushWriter(); if (m_tracer != null) super.fireEndDoc(); }
Receive notification of the end of a document. <p>The SAX parser will invoke this method only once, and it will be the last method invoked during the parse. The parser shall not invoke this method until it has either abandoned parsing (because of an unrecoverable error) or reached the end of input.</p> @throws org.xml.sax.SAXException Any SAX exception, possibly wrapping another exception. @throws org.xml.sax.SAXException
ToTextStream::endDocument
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextStream.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextStream.java
Apache-2.0
public void startElement( String namespaceURI, String localName, String name, Attributes atts) throws org.xml.sax.SAXException { // time to fire off startElement event if (m_tracer != null) { super.fireStartElem(name); this.firePseudoAttributes(); } return; }
Receive notification of the beginning of an element. <p>The Parser will invoke this method at the beginning of every element in the XML document; there will be a corresponding endElement() event for every startElement() event (even when the element is empty). All of the element's content will be reported, in order, before the corresponding endElement() event.</p> <p>If the element name has a namespace prefix, the prefix will still be attached. Note that the attribute list provided will contain only attributes with explicit values (specified or defaulted): #IMPLIED attributes will be omitted.</p> @param namespaceURI The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed. @param localName The local name (without prefix), or the empty string if Namespace processing is not being performed. @param name The qualified name (with prefix), or the empty string if qualified names are not available. @param atts The attributes attached to the element, if any. @throws org.xml.sax.SAXException Any SAX exception, possibly wrapping another exception. @see #endElement @see org.xml.sax.AttributeList @throws org.xml.sax.SAXException
ToTextStream::startElement
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextStream.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextStream.java
Apache-2.0
public void endElement(String namespaceURI, String localName, String name) throws org.xml.sax.SAXException { if (m_tracer != null) super.fireEndElem(name); }
Receive notification of the end of an element. <p>The SAX parser will invoke this method at the end of every element in the XML document; there will be a corresponding startElement() event for every endElement() event (even when the element is empty).</p> <p>If the element name has a namespace prefix, the prefix will still be attached to the name.</p> @param namespaceURI The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed. @param localName The local name (without prefix), or the empty string if Namespace processing is not being performed. @param name The qualified name (with prefix), or the empty string if qualified names are not available. @throws org.xml.sax.SAXException Any SAX exception, possibly wrapping another exception. @throws org.xml.sax.SAXException
ToTextStream::endElement
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextStream.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextStream.java
Apache-2.0
public void characters(char ch[], int start, int length) throws org.xml.sax.SAXException { flushPending(); try { if (inTemporaryOutputState()) { /* leave characters un-processed as we are * creating temporary output, the output generated by * this serializer will be input to a final serializer * later on and it will do the processing in final * output state (not temporary output state). * * A "temporary" ToTextStream serializer is used to * evaluate attribute value templates (for example), * and the result of evaluating such a thing * is fed into a final serializer later on. */ m_writer.write(ch, start, length); } else { // In final output state we do process the characters! writeNormalizedChars(ch, start, length, m_lineSepUse); } if (m_tracer != null) super.fireCharEvent(ch, start, length); } catch(IOException ioe) { throw new SAXException(ioe); } }
Receive notification of character data. <p>The Parser will call this method to report each chunk of character data. SAX parsers may return all contiguous character data in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity, so that the Locator provides useful information.</p> <p>The application must not attempt to read from the array outside of the specified range.</p> <p>Note that some parsers will report whitespace using the ignorableWhitespace() method rather than this one (validating parsers must do so).</p> @param ch The characters from the XML document. @param start The start position in the array. @param length The number of characters to read from the array. @throws org.xml.sax.SAXException Any SAX exception, possibly wrapping another exception. @see #ignorableWhitespace @see org.xml.sax.Locator
ToTextStream::characters
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextStream.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextStream.java
Apache-2.0
public void charactersRaw(char ch[], int start, int length) throws org.xml.sax.SAXException { try { writeNormalizedChars(ch, start, length, m_lineSepUse); } catch(IOException ioe) { throw new SAXException(ioe); } }
If available, when the disable-output-escaping attribute is used, output raw text without escaping. @param ch The characters from the XML document. @param start The start position in the array. @param length The number of characters to read from the array. @throws org.xml.sax.SAXException Any SAX exception, possibly wrapping another exception.
ToTextStream::charactersRaw
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextStream.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextStream.java
Apache-2.0
void writeNormalizedChars( final char ch[], final int start, final int length, final boolean useLineSep) throws IOException, org.xml.sax.SAXException { final String encoding = getEncoding(); final java.io.Writer writer = m_writer; final int end = start + length; /* copy a few "constants" before the loop for performance */ final char S_LINEFEED = CharInfo.S_LINEFEED; // This for() loop always increments i by one at the end // of the loop. Additional increments of i adjust for when // two input characters (a high/low UTF16 surrogate pair) // are processed. for (int i = start; i < end; i++) { final char c = ch[i]; if (S_LINEFEED == c && useLineSep) { writer.write(m_lineSep, 0, m_lineSepLen); // one input char processed } else if (m_encodingInfo.isInEncoding(c)) { writer.write(c); // one input char processed } else if (Encodings.isHighUTF16Surrogate(c)) { final int codePoint = writeUTF16Surrogate(c, ch, i, end); if (codePoint != 0) { // I think we can just emit the message, // not crash and burn. final String integralValue = Integer.toString(codePoint); final String msg = Utils.messages.createMessage( MsgKey.ER_ILLEGAL_CHARACTER, new Object[] { integralValue, encoding }); //Older behavior was to throw the message, //but newer gentler behavior is to write a message to System.err //throw new SAXException(msg); System.err.println(msg); } i++; // two input chars processed } else { // Don't know what to do with this char, it is // not in the encoding and not a high char in // a surrogate pair, so write out as an entity ref if (encoding != null) { /* The output encoding is known, * so somthing is wrong. */ // not in the encoding, so write out a character reference writer.write('&'); writer.write('#'); writer.write(Integer.toString(c)); writer.write(';'); // I think we can just emit the message, // not crash and burn. final String integralValue = Integer.toString(c); final String msg = Utils.messages.createMessage( MsgKey.ER_ILLEGAL_CHARACTER, new Object[] { integralValue, encoding }); //Older behavior was to throw the message, //but newer gentler behavior is to write a message to System.err //throw new SAXException(msg); System.err.println(msg); } else { /* The output encoding is not known, * so just write it out as-is. */ writer.write(c); } // one input char was processed } } }
Normalize the characters, but don't escape. Different from SerializerToXML#writeNormalizedChars because it does not attempt to do XML escaping at all. @param ch The characters from the XML document. @param start The start position in the array. @param length The number of characters to read from the array. @param useLineSep true if the operating systems end-of-line separator should be output rather than a new-line character. @throws IOException @throws org.xml.sax.SAXException
ToTextStream::writeNormalizedChars
java
google/j2objc
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextStream.java
https://github.com/google/j2objc/blob/master/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToTextStream.java
Apache-2.0