|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.novell.xml.sax.SAXWriter
Class to serialize SAX events.
Field Summary | |
protected boolean |
children
|
protected boolean |
firstElement
|
protected int |
indentLevel
|
protected int |
lastNode
|
protected NamespaceStack |
namespaceStack
|
protected boolean |
startTagOpen
|
protected Stack |
stateStack
|
protected static int |
XML_SPACE_DEFAULT
|
protected static int |
XML_SPACE_PRESERVE
|
protected int |
xmlSpace
|
protected static Integer |
xmlSpaceDefault
|
protected static Integer |
xmlSpacePreserve
|
Constructor Summary | |
SAXWriter(Parser parser,
InputSource inputSource,
OutputStream outputStream,
String encoding)
Construct a SAXWriter for the passed OutputStream, using the
passed encoding, if possible. |
|
SAXWriter(Parser parser,
InputSource inputSource,
Writer writer)
Construct a SAXWriter object for a given java.io.Writer
object. |
Method Summary | |
void |
characters(char[] ch,
int start,
int length)
Receive notification of character data. |
protected void |
closeStartTag()
Close any open element start tag |
void |
comment(String data)
Handle a comment |
void |
endDocument()
Receive notification of the end of a document. |
void |
endElement(String name)
Receive notification of the end of an element. |
void |
flush()
Flush the underlying writer attached to this SAXWriter |
Collection |
getCdataSectionElements()
Get the list of element tag names whose text content should be output as CDATA sections. |
boolean |
getDisableTextEscaping()
Return non-zero if XML text escaping is disabled for this XmlWriter. |
String |
getDoctypePublic()
Return the DOCTYPE PUBLIC id to use for the DTD declaration |
String |
getDoctypeSystem()
Return the DOCTYPE SYSTEM id to use for the XML-declaration |
String |
getEncoding()
Get the encoding string that will be specified in the XML declaration, if a declaration is output |
boolean |
getIndent()
Return if this object will inject whitespace to "pretty print" the serialization of a DOM tree |
boolean |
getStandalone()
Return if this object will write a "standalone=yes" declaration in the XML-declaration. |
boolean |
getWriteDeclaration()
Return if this object will write an XML-declaration when it serializes a DOM tree |
void |
ignorableWhitespace(char[] ch,
int start,
int length)
Receive notification of ignorable whitespace in element content. |
protected void |
injectWhitespace(int nodeType)
Optionally inject whitespace into the serialization stream |
protected void |
popState()
|
void |
processingInstruction(String target,
String data)
Receive notification of a processing instruction. |
protected void |
pushState()
|
void |
setCdataSectionElements(Collection cdataSectionElements)
Set the list of element tag names whose text content should be output as CDATA sections. |
void |
setDisableTextEscaping(boolean disableTextEscaping)
Set if XML text escaping is to be disabled for this XmlWriter. |
void |
setDoctypePublic(String doctypePublic)
Set the DOCTYPE PUBLIC id to use in the DTD declaration Note that this will only be used if the DOCTYPE SYSTEM id is not null and non-empty (see setDoctypeSystem()), and that the public id overrides the system id. |
void |
setDoctypeSystem(String doctypeSystem)
Set the DOCTYPE SYSTEM id to use in the DTD declaration Note that this will be overridden by the DOCTYPE PUBLIC id (see setDoctypePublic()), but must be set to use the public id. |
void |
setDocumentLocator(Locator locator)
Receive an object for locating the origin of SAX document events. |
void |
setEncoding(String encoding)
Set the encoding string that will be specified in the XML declaration, if a declaration is output. |
void |
setIndent(boolean indent)
Set whether this object should inject whitespace to "pretty print" the serialization of a DOM tree. |
void |
setStandalone(boolean standalone)
Set whether this object should write a "standalone=yes" declaration in the XML-declaration |
void |
setWriteDeclaration(boolean writeDeclaration)
Set whether this object should output an XML-declaration when it serializes a DOM tree |
void |
startDocument()
Receive notification of the beginning of a document. |
void |
startElement(String name,
AttributeList atts)
Receive notification of the beginning of an element. |
protected boolean |
useCdataOutput(String elementName)
Return whether or not CDATA section output should be used for text children of the passed element name |
void |
write()
Serialize a series of SAX events as XML |
protected void |
writeDeclaration()
Write an XML declaration based on XmlWriter settings |
protected void |
writeDTD(String name)
Write a DTD based on XmlWriter parameters |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected int indentLevel
protected boolean firstElement
protected int lastNode
protected boolean startTagOpen
protected boolean children
protected Stack stateStack
protected NamespaceStack namespaceStack
protected static final int XML_SPACE_DEFAULT
protected static final int XML_SPACE_PRESERVE
protected static final Integer xmlSpaceDefault
protected static final Integer xmlSpacePreserve
protected int xmlSpace
Constructor Detail |
public SAXWriter(Parser parser, InputSource inputSource, Writer writer)
SAXWriter
object for a given java.io.Writer
object. Use a com.novell.xml.util.XMLWriter
for character
encoding. Note that using a buffered writer will result
in maximum efficiency.
parser
- The SAX Parser
from which to get the SAX eventsinputSource
- The SAX InputSource
to pass to the parser's parse()
methodwriter
- The writer object to use.public SAXWriter(Parser parser, InputSource inputSource, OutputStream outputStream, String encoding) throws UnsupportedEncodingException
SAXWriter
for the passed OutputStream, using the
passed encoding, if possible.
parser
- The SAX Parser
from which to get the SAX eventsinputSource
- The SAX InputSource
to pass to the parser's parse()
methodoutputStream
- The OutputStream to which to writeencoding
- The name of the character encoding to useMethod Detail |
public void flush() throws IOException
IOException
public void write() throws IOException
write
in interface XmlWriter
IOException
public boolean getWriteDeclaration()
getWriteDeclaration
in interface XmlWriter
public void setWriteDeclaration(boolean writeDeclaration)
setWriteDeclaration
in interface XmlWriter
writeDeclaration
- True if an XML-declaration should be writtenpublic String getEncoding()
getEncoding
in interface XmlWriter
public void setEncoding(String encoding)
setEncoding
in interface XmlWriter
encoding
- The encoding string to place in the xml
declarationpublic boolean getIndent()
getIndent
in interface XmlWriter
public void setIndent(boolean indent)
setIndent
in interface XmlWriter
indent
- True if whitespace should be injected to "pretty print"
the XML serialization of a DOM tree.public boolean getStandalone()
getStandalone
in interface XmlWriter
public void setStandalone(boolean standalone)
setStandalone
in interface XmlWriter
standalone
- True if a standalone="yes" declaration should be
written in the XML-declarationpublic String getDoctypePublic()
getDoctypePublic
in interface XmlWriter
public void setDoctypePublic(String doctypePublic)
setDoctypePublic
in interface XmlWriter
doctypePublic
- The DOCTYPE PUBLIC id to use in the DTD declaration
or null if none should be used.public String getDoctypeSystem()
getDoctypeSystem
in interface XmlWriter
public void setDoctypeSystem(String doctypeSystem)
setDoctypeSystem
in interface XmlWriter
doctypeSystem
- The DOCTYPE SYSTEM id to use in the DTD declaration
or null if none should be used.public boolean getDisableTextEscaping()
getDisableTextEscaping
in interface XmlWriter
public void setDisableTextEscaping(boolean disableTextEscaping)
setDisableTextEscaping
in interface XmlWriter
disableTextEscaping
- True if text escaping is disabledpublic Collection getCdataSectionElements()
getCdataSectionElements
in interface XmlWriter
public void setCdataSectionElements(Collection cdataSectionElements)
setCdataSectionElements
in interface XmlWriter
cdataSectionElements
- A Collection of ExpandedQName objects, each
of which represents an element tag name.public void setDocumentLocator(Locator locator)
setDocumentLocator
in interface DocumentHandler
locator
- An object that can return the location of
any SAX document event.Locator
public void startDocument() throws SAXException
startDocument
in interface DocumentHandler
SAXException
- Any SAX exception, possibly
wrapping another exception.public void endDocument() throws SAXException
endDocument
in interface DocumentHandler
SAXException
- Any SAX exception, possibly
wrapping another exception.public void startElement(String name, AttributeList atts) throws SAXException
startElement
in interface DocumentHandler
name
- The element type name.atts
- The attributes attached to the element, if any.
SAXException
- Any SAX exception, possibly
wrapping another exception.endElement(java.lang.String)
,
AttributeList
public void endElement(String name) throws SAXException
endElement
in interface DocumentHandler
name
- The element type name
SAXException
- Any SAX exception, possibly
wrapping another exception.public void characters(char[] ch, int start, int length) throws SAXException
characters
in interface DocumentHandler
ch
- The characters from the XML document.start
- The start position in the array.length
- The number of characters to read from the array.
SAXException
- Any SAX exception, possibly
wrapping another exception.ignorableWhitespace(char[], int, int)
,
Locator
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException
ignorableWhitespace
in interface DocumentHandler
ch
- The characters from the XML document.start
- The start position in the array.length
- The number of characters to read from the array.
SAXException
- Any SAX exception, possibly
wrapping another exception.characters(char[], int, int)
public void processingInstruction(String target, String data) throws SAXException
processingInstruction
in interface DocumentHandler
target
- The processing instruction target.data
- The processing instruction data, or null if
none was supplied.
SAXException
- Any SAX exception, possibly
wrapping another exception.public void comment(String data) throws SAXException
comment
in interface DocumentCommentHandler
data
- The comment data, that is, everything
between the tags.
SAXException
protected void writeDeclaration() throws IOException
IOException
protected void writeDTD(String name) throws IOException
name
- The name of the document element
IOException
protected void injectWhitespace(int nodeType) throws IOException
nodeType
- The current node type
IOException
protected void closeStartTag() throws IOException
IOException
protected boolean useCdataOutput(String elementName)
elementName
- The element name to checkprotected void pushState()
protected void popState()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |