com.ssx.xml.output.sinks
Class TextSink

java.lang.Object
  extended bycom.ssx.xml.output.sinks.TextSink
All Implemented Interfaces:
XmlSink

public class TextSink
extends Object
implements XmlSink

Output XML text to a java.io character stream.


Constructor Summary
TextSink(Writer writer, String encoding)
          Instantiate a new Xml text output with default settings
TextSink(Writer writer, String encoding, boolean singleQuote, boolean formatting)
          Instantiate a new Xml text output with custom settings
TextSink(Writer writer, String encoding, boolean singleQuote, boolean formatting, String endOfLine, String indent)
          Instantiate a new Xml text output with custom settings
 
Method Summary
 void close()
          The user has finished providing XML.
 void comment(String content)
          Add a comment
 void endElement(Namespace namespace, String name, List namespaceList, boolean empty)
          End an element.
 Writer getOutput()
           
 void instruction(String target, String data)
          Add a processing instruction
 void open()
          This method will be called before any other methods, after the user has provided the first xml node
 void startElement(Namespace namespace, String name, AttributeList attributes, List namespaceList, boolean empty)
          Start a new element
 void text(String text)
          Add character data
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextSink

public TextSink(Writer writer,
                String encoding)
Instantiate a new Xml text output with default settings

Parameters:
writer - The XML will be written to this stream
encoding - The character encoding that will be used for this XML document.

TextSink

public TextSink(Writer writer,
                String encoding,
                boolean singleQuote,
                boolean formatting)
Instantiate a new Xml text output with custom settings

Parameters:
writer - The XML will be written to this stream
encoding - The character encoding that will be used for this XML document.
singleQuote - Use a single quote to surround attribute values
formatting - Format the XML output to a human readable form using end of line markers and indented lines.

TextSink

public TextSink(Writer writer,
                String encoding,
                boolean singleQuote,
                boolean formatting,
                String endOfLine,
                String indent)
Instantiate a new Xml text output with custom settings

Parameters:
writer - The XML will be written to this stream
encoding - The character encoding that will be used for this XML document.
singleQuote - Use a single quote to surround attribute values
formatting - Format the XML output to a human readable form using end of line markers and indented lines.
endOfLine - The marker to use at the end of lines (defaults to CRLF)
indent - The string to use for each indent level (defaults to 4 spaces)
Method Detail

getOutput

public Writer getOutput()
Returns:
the Writer used to capture the XML output

open

public void open()
Description copied from interface: XmlSink
This method will be called before any other methods, after the user has provided the first xml node

Specified by:
open in interface XmlSink
See Also:
XmlSink.open()

startElement

public void startElement(Namespace namespace,
                         String name,
                         AttributeList attributes,
                         List namespaceList,
                         boolean empty)
Description copied from interface: XmlSink
Start a new element

Specified by:
startElement in interface XmlSink
Parameters:
namespace - The element namespace
name - The element name
attributes - The element attributes
namespaceList - The namespaces declared in this element
empty - True if the element contains no other nodes
See Also:
XmlSink.startElement( Namespace, String, AttributeList, List, boolean)

text

public void text(String text)
Description copied from interface: XmlSink
Add character data

Specified by:
text in interface XmlSink
Parameters:
text - The String to add as character data
See Also:
XmlSink.text(String)

endElement

public void endElement(Namespace namespace,
                       String name,
                       List namespaceList,
                       boolean empty)
Description copied from interface: XmlSink
End an element. If empty is true it indicates that the body of the element is empty.

Specified by:
endElement in interface XmlSink
Parameters:
namespace - The element namespace
name - The element name
namespaceList - The namespaces that were declared in this element
empty - True if the element contains no other nodes
See Also:
XmlSink.endElement(Namespace, String, List, boolean)

comment

public void comment(String content)
Description copied from interface: XmlSink
Add a comment

Specified by:
comment in interface XmlSink
Parameters:
content - The text content of the comment
See Also:
XmlSink.comment(String)

instruction

public void instruction(String target,
                        String data)
Description copied from interface: XmlSink
Add a processing instruction

Specified by:
instruction in interface XmlSink
Parameters:
target - The PI target
data - The PI data - structure depends on the PI
See Also:
XmlSink.instruction(String, String)

close

public void close()
Description copied from interface: XmlSink
The user has finished providing XML. No other methods will be called after this.

Specified by:
close in interface XmlSink
See Also:
XmlSink.close()