org.apache.ws.commons.serialize
Interface XMLWriter
- org.xml.sax.ContentHandler
- CharSetXMLWriter, OrderedAttributeXMLWriter, PassThroughXMLWriter, XMLWriterImpl
public interface XMLWriter
extends org.xml.sax.ContentHandler
A simple serializer for XML documents, which is writing to
an instance of java.io.Writer
.
boolean | canEncode(char pChar) - Returns whether the XMLWriter can encode the character
c without an escape sequence like &#ddd;.
|
String | getEncoding() - Returns the writers encoding.
|
String | getIndentString() - Returns the string being used to indent an XML element
by one level.
|
String | getLineFeed() - Returns the line terminator.
|
Writer | getWriter() - Returns the target
Writer .
|
boolean | isDeclarating() - Returns, whether an XML declaration is being generated.
|
boolean | isFlushing() - Returns, whether the method
org.xml.sax.ContentHandler.endDocument
should do a flush on the target stream.
|
boolean | isIndenting() - Returns, whether the
XMLWriter is indenting
(pretty printing).
|
void | setDeclarating(boolean pDeclarating) - Sets, whether an XML declaration is being generated.
|
void | setEncoding(String pEncoding) - Sets the writers encoding.
|
void | setFlushing(boolean pFlushing) - Sets, whether the method
org.xml.sax.ContentHandler.endDocument
should do a flush on the target stream.
|
void | setIndentString(String pIndentString) - Sets the string being used to indent an XML element
by one level.
|
void | setIndenting(boolean pIndenting) - Returns, whether the
XMLWriter is indenting
(pretty printing).
|
void | setLineFeed(String pLineFeed) - Sets the line terminator.
|
void | setWriter(Writer pWriter) - Sets the target
Writer .
|
canEncode
public boolean canEncode(char pChar)
Returns whether the XMLWriter can encode the character
c
without an escape sequence like &#ddd;.
pChar
- The character being checked for escaping.
- Whether to encode the character.
getEncoding
public String getEncoding()
Returns the writers encoding.
- Writers encoding, by default null, in
which case UTF-8 is being used.
getIndentString
public String getIndentString()
Returns the string being used to indent an XML element
by one level. Ignored, if indentation is disabled.
- The indentation string, by default " " (two blanks).
getLineFeed
public String getLineFeed()
Returns the line terminator. Ignored, if indentation is
disabled.
- The line terminator, by default "\n"
(Line Feed). You might prefer "\r\n" (Carriage Return,
Line Feed), which is the default on Windows and related
operating systems.
getWriter
public Writer getWriter()
Returns the target Writer
. This is typically an instance
of java.io.BufferedWriter
, which is connected to an
instance of java.io.OutputStreamWriter
with an encoding
matching the XML documents encoding.
isDeclarating
public boolean isDeclarating()
Returns, whether an XML declaration is being generated.
- Whether an XML declaration is generated. Defaults
to false.
isFlushing
public boolean isFlushing()
Returns, whether the method org.xml.sax.ContentHandler.endDocument
should do a flush on the target stream.
- True, if a flush should be done. Defaults to false.
isIndenting
public boolean isIndenting()
Returns, whether the XMLWriter
is indenting
(pretty printing). If you want indenting,
you should consider to invoke the methods
setIndentString(java.lang.String)
and
setLineFeed(java.lang.String)
as well.
- Whether indentation is enabled. Defaults to false.
setDeclarating
public void setDeclarating(boolean pDeclarating)
Sets, whether an XML declaration is being generated.
pDeclarating
- Whether an XML declaration is generated. Defaults
to false.
setEncoding
public void setEncoding(String pEncoding)
Sets the writers encoding.
pEncoding
- Writers encoding, by default null, in
which case UTF-8 is being used.
setFlushing
public void setFlushing(boolean pFlushing)
Sets, whether the method org.xml.sax.ContentHandler.endDocument
should do a flush on the target stream.
pFlushing
- True, if a flush should be done. Defaults to
false.
setIndentString
public void setIndentString(String pIndentString)
Sets the string being used to indent an XML element
by one level. Ignored, if indentation is disabled.
pIndentString
- The indentation string, by default " " (two blanks).
setIndenting
public void setIndenting(boolean pIndenting)
Returns, whether the XMLWriter
is indenting
(pretty printing). If you want indenting,
you should consider to invoke the methods
setIndentString(java.lang.String)
and
setLineFeed(java.lang.String)
as well.
pIndenting
- Whether indentation is enabled. Defaults to false.
setLineFeed
public void setLineFeed(String pLineFeed)
Sets the line terminator. Ignored, if indentation is
disabled.
pLineFeed
- The line terminator, by default "\n"
(Line Feed). You might prefer "\r\n" (Carriage Return,
Line Feed), which is the default on Windows and related
operating systems.
setWriter
public void setWriter(Writer pWriter)
Sets the target Writer
. This is typically an instance
of java.io.BufferedWriter
, which is connected to an
instance of java.io.OutputStreamWriter
with an encoding
matching the XML documents encoding.
pWriter
- The target writer.