|
Enhydra 3.1 API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.xalan.xpath.xml.FormatterToXML
FormatterToXML formats SAX-style events into XML. Warning: this class will be replaced by the Xerces Serializer classes.
Field Summary | |
int |
indent
Amount to indent. |
protected int |
level
Current level of indent. |
char[] |
m_attrCharsMap
|
char[] |
m_attrSpecialChars
These are characters that will be escaped in the output. |
protected byte[] |
m_byteBuf
|
protected char[] |
m_charBuf
|
char[] |
m_charsMap
|
protected int |
m_currentIndent
Flag to keep track of the indent amount. |
protected boolean |
m_doIndent
Flag to tell if indenting (pretty-printing) is on. |
protected BoolStack |
m_elemStack
A stack of Boolean objects that tell if the given element has children. |
protected java.lang.String |
m_encoding
The character encoding. |
boolean |
m_escapeCData
If true, characters in cdata sections are escaped, instead of being writted out as cdata sections. |
protected boolean |
m_inCData
|
protected boolean |
m_inEntityRef
Tells if we're in an EntityRef event. |
protected boolean |
m_ispreserve
State flag to tell if preservation of whitespace is important. |
protected boolean |
m_isprevtext
State flag that tells if the previous node processed was text, so we can tell if we should preserve whitespace. |
protected java.lang.String |
m_lineSep
Use the system line seperator to write line breaks. |
protected int |
m_lineSepLen
The length of the line seperator, since the write is done one character at a time. |
protected java.io.OutputStream |
m_outputStream
|
protected int |
m_pos
|
protected BoolStack |
m_preserves
Stack to keep track of whether or not we need to preserve whitespace. |
boolean |
m_shouldNotWriteXMLHeader
Tells if we should write the XML declaration. |
boolean |
m_spaceBeforeClose
Add space before '/>' for XHTML. |
boolean |
m_stripCData
If true, cdata sections are simply stripped of their CDATA brackets, without escaping. |
java.lang.String |
m_version
Tells the XML version, for writing out to the XML decl. |
protected java.io.Writer |
m_writer
The writer where the XML will be written. |
protected static java.util.Hashtable |
s_revsize
|
Constructor Summary | |
FormatterToXML()
Default constructor. |
|
FormatterToXML(FormatterToXML xmlListener)
Constructor using a writer. |
|
FormatterToXML(java.io.OutputStream os)
Constructor using an output stream, and a simple OutputFormat. |
|
FormatterToXML(java.io.Writer writer)
Constructor using a writer. |
Method Summary | |
protected void |
accum(byte b)
Append a byte to the buffer. |
protected void |
accum(char b)
Append a character to the buffer. |
protected void |
accum(char[] chars,
int start,
int length)
Append a character to the buffer. |
protected void |
accum(java.lang.String s)
Append a character to the buffer. |
void |
cdata(char[] ch,
int start,
int length)
Receive notification of cdata. |
void |
characters(char[] chars,
int start,
int length)
Receive notification of character data. |
void |
charactersRaw(char[] ch,
int start,
int length)
If available, when the disable-output-escaping attribute is used, output raw text without escaping. |
protected boolean |
childNodesWereAdded()
Tell if child nodes have been added to the current element. |
void |
comment(char[] ch,
int start,
int length)
Report an XML comment anywhere in the document. |
static java.lang.String |
convertJava2MimeEncoding(java.lang.String encoding)
Convert a Java encoding name to MIME charset name. |
static java.lang.String |
convertMime2JavaEncoding(java.lang.String mimeCharsetName)
Convert a MIME charset name, also known as an XML encoding name, to a Java encoding name. |
void |
endCDATA()
Report the end of a CDATA section. |
void |
endDocument()
Receive notification of the end of a document. |
void |
endDTD()
Report the end of DTD declarations. |
void |
endElement(java.lang.String name)
Receive notification of the end of an element. |
void |
endEntity(java.lang.String name)
Report the end of an entity. |
void |
entityReference(java.lang.String name)
Receive notivication of a entityReference. |
void |
flush()
|
void |
flushWriter()
Flush the formatter's result stream. |
java.io.Writer |
getWriter()
Return the Writer. |
void |
ignorableWhitespace(char[] ch,
int start,
int length)
Receive notification of ignorable whitespace in element content. |
void |
indent(int n)
Prints a newline character and n spaces. |
void |
init(java.io.OutputStream output,
OutputFormat format)
Initialize the serializer with the specified output stream and output format. |
void |
init(java.io.Writer writer,
OutputFormat format)
Initialize the serializer with the specified writer and output format. |
protected void |
initAttrCharsMap()
Set the attribute characters what will require special mapping. |
protected void |
initCharsMap()
Set the characters what will require special mapping. |
static void |
initEncodings()
|
protected void |
openElementForChildren()
Flag the current element as not yet having any children. |
protected void |
outputLineSep()
Output a system-dependent line break. |
void |
printSpace(int n)
Prints n spaces. |
protected void |
processAttribute(java.lang.String name,
java.lang.String value)
Process an attribute. |
void |
processingInstruction(java.lang.String target,
java.lang.String data)
Receive notification of a processing instruction. |
void |
setDocumentLocator(Locator locator)
Receive an object for locating the origin of SAX document events. |
protected boolean |
shouldIndent()
|
void |
startCDATA()
Report the start of a CDATA section. |
void |
startDocument()
Receive notification of the beginning of a document. |
void |
startDTD(java.lang.String name,
java.lang.String publicId,
java.lang.String systemId)
Report the start of DTD declarations, if any. |
void |
startElement(java.lang.String name,
AttributeList atts)
Receive notification of the beginning of an element. |
void |
startEntity(java.lang.String name)
Report the beginning of an entity. |
void |
writeAttrString(java.lang.String string,
java.lang.String encoding)
Returns the specified string after substituting specials, and UTF-16 surrogates for chracter references &#xnn . |
protected void |
writeParentTagEnd()
Check to see if a parent's ">" has been written, and, if it has not, write it. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
protected java.io.Writer m_writer
protected java.io.OutputStream m_outputStream
public boolean m_stripCData
public boolean m_escapeCData
protected java.lang.String m_encoding
public boolean m_shouldNotWriteXMLHeader
public java.lang.String m_version
protected BoolStack m_elemStack
protected final java.lang.String m_lineSep
protected final int m_lineSepLen
protected boolean m_ispreserve
protected BoolStack m_preserves
protected boolean m_isprevtext
protected boolean m_doIndent
protected int m_currentIndent
public int indent
protected int level
protected boolean m_inEntityRef
public char[] m_attrSpecialChars
public char[] m_attrCharsMap
public char[] m_charsMap
public boolean m_spaceBeforeClose
protected boolean m_inCData
protected char[] m_charBuf
protected byte[] m_byteBuf
protected int m_pos
protected static java.util.Hashtable s_revsize
Constructor Detail |
public FormatterToXML()
public FormatterToXML(java.io.Writer writer)
writer
- The character output stream to use.public FormatterToXML(java.io.OutputStream os) throws java.io.UnsupportedEncodingException
writer
- The character output stream to use.public FormatterToXML(FormatterToXML xmlListener)
writer
- The character output stream to use.Method Detail |
public java.io.Writer getWriter()
protected final void outputLineSep() throws SAXException
protected void initAttrCharsMap()
protected void initCharsMap()
public void init(java.io.Writer writer, OutputFormat format)
writer
- The writer to useformat
- The output formatpublic void init(java.io.OutputStream output, OutputFormat format) throws java.io.UnsupportedEncodingException
output
- The output stream to useformat
- The output formatpublic void setDocumentLocator(Locator locator)
locator
- An object that can return the location of
any SAX document event.Locator
public void startDocument() throws SAXException
public void endDocument() throws SAXException
public void startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId) throws SAXException
name
- The document type name.publicId
- The declared public identifier for the
external DTD subset, or null if none was declared.systemId
- The declared system identifier for the
external DTD subset, or null if none was declared.endDTD()
,
startEntity(java.lang.String)
public void endDTD() throws SAXException
startDTD(java.lang.String, java.lang.String, java.lang.String)
public void startElement(java.lang.String name, AttributeList atts) throws SAXException
name
- The element type name.atts
- The attributes attached to the element, if any.endElement(java.lang.String)
,
AttributeList
protected void writeParentTagEnd() throws SAXException
protected void openElementForChildren()
protected boolean childNodesWereAdded()
public void endElement(java.lang.String name) throws SAXException
name
- The element type nameprotected void processAttribute(java.lang.String name, java.lang.String value) throws SAXException
name
- The name of the attribute.value
- The value of the attribute.public void processingInstruction(java.lang.String target, java.lang.String data) throws SAXException
target
- The processing instruction target.data
- The processing instruction data, or null if
none was supplied.public void comment(char[] ch, int start, int length) throws SAXException
ch
- An array holding the characters in the comment.start
- The starting position in the array.length
- The number of characters to use from the array.public void startCDATA() throws SAXException
endCDATA()
public void endCDATA() throws SAXException
startCDATA()
public void cdata(char[] ch, int start, int length) throws SAXException
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.
The application must not attempt to read from the array outside of the specified range.
Note that some parsers will report whitespace using the ignorableWhitespace() method rather than this one (validating parsers must do so).
ch
- The characters from the XML document.start
- The start position in the array.length
- The number of characters to read from the array.ignorableWhitespace(char[], int, int)
,
Locator
protected final void accum(byte b) throws SAXException
protected final void accum(char b) throws SAXException
protected final void accum(char[] chars, int start, int length) throws SAXException
protected final void accum(java.lang.String s) throws SAXException
public final void flushWriter() throws SAXException
public final void flush() throws SAXException
public void characters(char[] chars, int start, int length) throws SAXException
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.
The application must not attempt to read from the array outside of the specified range.
Note that some parsers will report whitespace using the ignorableWhitespace() method rather than this one (validating parsers must do so).
chars
- The characters from the XML document.start
- The start position in the array.length
- The number of characters to read from the array.ignorableWhitespace(char[], int, int)
,
Locator
public void charactersRaw(char[] ch, int start, int length) throws SAXException
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException
ch
- The characters from the XML document.start
- The start position in the array.length
- The number of characters to read from the array.characters(char[], int, int)
public void startEntity(java.lang.String name) throws SAXException
name
- The name of the entity. If it is a parameter
entity, the name will begin with '%'.endEntity(java.lang.String)
,
org.xml.sax.misc.DeclHandler#internalEntityDecl
,
org.xml.sax.misc.DeclHandler#externalEntityDecl
public void endEntity(java.lang.String name) throws SAXException
name
- The name of the entity that is ending.startEntity(java.lang.String)
public void entityReference(java.lang.String name) throws SAXException
public void writeAttrString(java.lang.String string, java.lang.String encoding) throws SAXException
&#xnn
.string
- String to convert to XML format.specials
- Chracters, should be represeted in chracter referenfces.encoding
- CURRENTLY NOT IMPLEMENTED.#backReference
protected boolean shouldIndent()
public void printSpace(int n) throws SAXException
pw
- The character output stream to use.n
- Number of spaces to print.public void indent(int n) throws SAXException
pw
- The character output stream to use.n
- Number of spaces to print.public static void initEncodings()
public static java.lang.String convertMime2JavaEncoding(java.lang.String mimeCharsetName) throws java.io.UnsupportedEncodingException
mimeCharsetName
- Case insensitive MIME charset name: UTF-8, US-ASCII, ISO-8859-1,
ISO-8859-2, ISO-8859-3, ISO-8859-4, ISO-8859-5, ISO-8859-6,
ISO-8859-7, ISO-8859-8, ISO-8859-9, ISO-2022-JP, Shift_JIS,
EUC-JP, GB2312, Big5, EUC-KR, ISO-2022-KR, KOI8-R,
EBCDIC-CP-US, EBCDIC-CP-CA, EBCDIC-CP-NL, EBCDIC-CP-DK,
EBCDIC-CP-NO, EBCDIC-CP-FI, EBCDIC-CP-SE, EBCDIC-CP-IT,
EBCDIC-CP-ES, EBCDIC-CP-GB, EBCDIC-CP-FR, EBCDIC-CP-AR1,
EBCDIC-CP-HE, EBCDIC-CP-CH, EBCDIC-CP-ROECE, EBCDIC-CP-YU,
EBCDIC-CP-IS and EBCDIC-CP-AR2
.#reverse
public static java.lang.String convertJava2MimeEncoding(java.lang.String encoding)
encoding
- Case insensitive Java encoding name: UTF8, ISO8859_1, ISO8859_2, ISO8859_3,
ISO8859_4, ISO8859_5, ISO8859_6, ISO8859_7, ISO8859_8, ISO8859_9, JIS, SJIS, EUCJIS,
GB2312, BIG5, KSC5601, ISO2022KR, KOI8_R, CP037, CP277, CP278,
CP280, CP284, CP285, CP297, CP420, CP424, CP500, CP870, CP871
and CP918
.#convert
|
Enhydra 3.1 API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |