totextstream.java
来自「JAVA 所有包」· Java 代码 · 共 633 行 · 第 1/2 页
JAVA
633 行
* 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 } } } /** * Receive notification of cdata. * * <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 */ public void cdata(char ch[], int start, int length) throws org.xml.sax.SAXException { try { writeNormalizedChars(ch, start, length, m_lineSepUse); if (m_tracer != null) super.fireCDATAEvent(ch, start, length); } catch(IOException ioe) { throw new SAXException(ioe); } } /** * Receive notification of ignorable whitespace in element content. * * <p>Validating Parsers must use this method to report each chunk * of ignorable whitespace (see the W3C XML 1.0 recommendation, * section 2.10): non-validating parsers may also use this method * if they are capable of parsing and using content models.</p> * * <p>SAX parsers may return all contiguous whitespace 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> * * @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 #characters * * @throws org.xml.sax.SAXException */ public void ignorableWhitespace(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); } } /** * Receive notification of a processing instruction. * * <p>The Parser will invoke this method once for each processing * instruction found: note that processing instructions may occur * before or after the main document element.</p> * * <p>A SAX parser should never report an XML declaration (XML 1.0, * section 2.8) or a text declaration (XML 1.0, section 4.3.1) * using this method.</p> * * @param target The processing instruction target. * @param data The processing instruction data, or null if * none was supplied. * @throws org.xml.sax.SAXException Any SAX exception, possibly * wrapping another exception. * * @throws org.xml.sax.SAXException */ public void processingInstruction(String target, String data) throws org.xml.sax.SAXException { // flush anything pending first flushPending(); if (m_tracer != null) super.fireEscapingEvent(target, data); } /** * Called when a Comment is to be constructed. * Note that Xalan will normally invoke the other version of this method. * %REVIEW% In fact, is this one ever needed, or was it a mistake? * * @param data The comment data. * @throws org.xml.sax.SAXException Any SAX exception, possibly * wrapping another exception. */ public void comment(String data) throws org.xml.sax.SAXException { final int length = data.length(); if (length > m_charsBuff.length) { m_charsBuff = new char[length*2 + 1]; } data.getChars(0, length, m_charsBuff, 0); comment(m_charsBuff, 0, length); } /** * Report an XML comment anywhere in the document. * * This callback will be used for comments inside or outside the * document element, including comments in the external DTD * subset (if read). * * @param ch An array holding the characters in the comment. * @param start The starting position in the array. * @param length The number of characters to use from the array. * @throws org.xml.sax.SAXException The application may raise an exception. */ public void comment(char ch[], int start, int length) throws org.xml.sax.SAXException { flushPending(); if (m_tracer != null) super.fireCommentEvent(ch, start, length); } /** * Receive notivication of a entityReference. * * @param name non-null reference to the name of the entity. * * @throws org.xml.sax.SAXException */ public void entityReference(String name) throws org.xml.sax.SAXException { if (m_tracer != null) super.fireEntityReference(name); } /** * @see ExtendedContentHandler#addAttribute(String, String, String, String, String) */ public void addAttribute( String uri, String localName, String rawName, String type, String value, boolean XSLAttribute) { // do nothing, just forget all about the attribute } /** * @see org.xml.sax.ext.LexicalHandler#endCDATA() */ public void endCDATA() throws SAXException { // do nothing } /** * @see ExtendedContentHandler#endElement(String) */ public void endElement(String elemName) throws SAXException { if (m_tracer != null) super.fireEndElem(elemName); } /** * From XSLTC */ public void startElement( String elementNamespaceURI, String elementLocalName, String elementName) throws SAXException { if (m_needToCallStartDocument) startDocumentInternal(); // time to fire off startlement event. if (m_tracer != null) { super.fireStartElem(elementName); this.firePseudoAttributes(); } return; } /** * From XSLTC */ 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); characters(m_charsBuff, 0, length); } /** * From XSLTC */ public void addAttribute(String name, String value) { // do nothing, forget about the attribute } /** * Add a unique attribute */ public void addUniqueAttribute(String qName, String value, int flags) throws SAXException { // do nothing, forget about the attribute } public boolean startPrefixMapping( String prefix, String uri, boolean shouldFlush) throws SAXException { // no namespace support for HTML return false; } public void startPrefixMapping(String prefix, String uri) throws org.xml.sax.SAXException { // no namespace support for HTML } public void namespaceAfterStartElement( final String prefix, final String uri) throws SAXException { // no namespace support for HTML } public void flushPending() throws org.xml.sax.SAXException { if (m_needToCallStartDocument) { startDocumentInternal(); m_needToCallStartDocument = false; } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?