org.apache.ws.commons.serialize

Interface XMLWriter

public interface XMLWriter extends ContentHandler

A simple serializer for XML documents, which is writing to an instance of java.io.Writer.
Method Summary
booleancanEncode(char pChar)

Returns whether the XMLWriter can encode the character c without an escape sequence like &#ddd;.

StringgetEncoding()
Returns the writers encoding.
StringgetIndentString()
Returns the string being used to indent an XML element by one level.
StringgetLineFeed()
Returns the line terminator.
WritergetWriter()
Returns the target Writer.
booleanisDeclarating()
Returns, whether an XML declaration is being generated.
booleanisFlushing()
Returns, whether the method org.xml.sax.ContentHandler#endDocument should do a flush on the target stream.
booleanisIndenting()
Returns, whether the XMLWriter is indenting (pretty printing).
voidsetDeclarating(boolean pDeclarating)
Sets, whether an XML declaration is being generated.
voidsetEncoding(String pEncoding)
Sets the writers encoding.
voidsetFlushing(boolean pFlushing)
Sets, whether the method org.xml.sax.ContentHandler#endDocument should do a flush on the target stream.
voidsetIndenting(boolean pIndenting)
Returns, whether the XMLWriter is indenting (pretty printing).
voidsetIndentString(String pIndentString)
Sets the string being used to indent an XML element by one level.
voidsetLineFeed(String pLineFeed)
Sets the line terminator.
voidsetWriter(Writer pWriter)
Sets the target Writer.

Method Detail

canEncode

public boolean canEncode(char pChar)

Returns whether the XMLWriter can encode the character c without an escape sequence like &#ddd;.

Parameters: pChar The character being checked for escaping.

Returns: Whether to encode the character.

getEncoding

public String getEncoding()
Returns the writers encoding.

Returns: 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.

Returns: The indentation string, by default " " (two blanks).

getLineFeed

public String getLineFeed()
Returns the line terminator. Ignored, if indentation is disabled.

Returns: 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.

Returns: The target writer.

isDeclarating

public boolean isDeclarating()
Returns, whether an XML declaration is being generated.

Returns: 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.

Returns: 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 XMLWriter and XMLWriter as well.

Returns: Whether indentation is enabled. Defaults to false.

setDeclarating

public void setDeclarating(boolean pDeclarating)
Sets, whether an XML declaration is being generated.

Parameters: pDeclarating Whether an XML declaration is generated. Defaults to false.

setEncoding

public void setEncoding(String pEncoding)
Sets the writers encoding.

Parameters: 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.

Parameters: pFlushing True, if a flush should be done. Defaults to false.

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 XMLWriter and XMLWriter as well.

Parameters: pIndenting Whether indentation is enabled. 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.

Parameters: pIndentString The indentation string, by default " " (two blanks).

setLineFeed

public void setLineFeed(String pLineFeed)
Sets the line terminator. Ignored, if indentation is disabled.

Parameters: 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.

Parameters: pWriter The target writer.

Copyright © 2005-2009 Apache Software Foundation. All Rights Reserved.