tuwien.auto.calimero.xml.def
Class DefaultXMLWriter

java.lang.Object
  extended by tuwien.auto.calimero.xml.def.DefaultXMLWriter
All Implemented Interfaces:
XMLWriter

public class DefaultXMLWriter
extends java.lang.Object
implements XMLWriter

Default XML writer implementation of the XMLWriter interface.

Does not add any feature not already documented in the implemented interface.
This writer is not thread safe.


Constructor Summary
DefaultXMLWriter()
          Creates a new XML writer.
DefaultXMLWriter(java.io.Writer w, boolean close)
          Creates a new XML writer with output w.
 
Method Summary
 void close()
          Closes this XML writer.
 void endAllElements()
          Closes all open elements and flushes buffered data to output.
 void endElement()
          Closes the current element.
 void setOutput(java.io.Writer output, boolean close)
          Sets the output destination for this XML writer.
 void writeCharData(java.lang.String text, boolean isCDATASection)
          Writes character data to the current position in a document.
 void writeComment(java.lang.String comment)
          Writes a comment to the current position in a document.
 void writeDeclaration(boolean standalone, java.lang.String encoding)
          Writes the XML declaration, specifying standalone document declaration and encoding declaration.
 void writeElement(java.lang.String name, java.util.List att, java.lang.String content)
          Writes a new element to the current position in a document.
 void writeEmptyElement(java.lang.String name, java.util.List att)
          Writes an empty element tag to the current position in a document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultXMLWriter

public DefaultXMLWriter()
Creates a new XML writer.


DefaultXMLWriter

public DefaultXMLWriter(java.io.Writer w,
                        boolean close)
Creates a new XML writer with output w.

The writer is buffered by this XML writer.

Parameters:
w - the output Writer
close - true to close w if XML writer is closed, false otherwise
See Also:
XMLWriter.setOutput(Writer, boolean)
Method Detail

close

public void close()
           throws KNXMLException
Description copied from interface: XMLWriter
Closes this XML writer.

If this XML writer is already closed, no action is performed. All open elements are closed. If for an output source was specified to get closed on invocation of this method, it is closed (calling Writer.close() before return.

Specified by:
close in interface XMLWriter
Throws:
KNXMLException
See Also:
XMLWriter.endAllElements()

endAllElements

public void endAllElements()
                    throws KNXMLException
Description copied from interface: XMLWriter
Closes all open elements and flushes buffered data to output.

Specified by:
endAllElements in interface XMLWriter
Throws:
KNXMLException - on output error

endElement

public void endElement()
                throws KNXMLException
Description copied from interface: XMLWriter
Closes the current element.

Specified by:
endElement in interface XMLWriter
Throws:
KNXMLException - on output error

setOutput

public void setOutput(java.io.Writer output,
                      boolean close)
Description copied from interface: XMLWriter
Sets the output destination for this XML writer.

If this XML writer was already closed, setting a new output has no effect.

Specified by:
setOutput in interface XMLWriter
Parameters:
output - a writer for output
close - true if the specified writer should be closed on XMLWriter.close(), false to leave it open

writeCharData

public void writeCharData(java.lang.String text,
                          boolean isCDATASection)
                   throws KNXMLException
Description copied from interface: XMLWriter
Writes character data to the current position in a document.

Character data can be put into CDATA sections.
CDATA sections begin with the string "<![CDATA[" and end with the string "]]>". A CDATA section is used to escape text with characters which would be recognized as markup otherwise.
Predefined entities in text are replaced before write, iff the character data to write is no CDATA section. Data in CDATA sections is not modified.

Specified by:
writeCharData in interface XMLWriter
Parameters:
text - text to write, the character data
isCDATASection - true to write data into CDATA section, false to write default character data
Throws:
KNXMLException - on output error

writeComment

public void writeComment(java.lang.String comment)
                  throws KNXMLException
Description copied from interface: XMLWriter
Writes a comment to the current position in a document.

The text of the comment is wrapped with "<!--" and "-->" by this method. The string "--" (double-hyphen) must not occur within comments.

Specified by:
writeComment in interface XMLWriter
Parameters:
comment - text of the comment
Throws:
KNXMLException - on output error

writeDeclaration

public void writeDeclaration(boolean standalone,
                             java.lang.String encoding)
                      throws KNXMLException
Description copied from interface: XMLWriter
Writes the XML declaration, specifying standalone document declaration and encoding declaration.

The version information is always 1.0.
Note that an arbitrary encoding might be specified in the declaration. It is not necessarily checked by the XML writer whether the actual output meets that encoding. The user is responsible to specify the encoding matching the output writer.

Specified by:
writeDeclaration in interface XMLWriter
Parameters:
standalone - true if there are no external markup declarations, false to indicates that there are or may be such external markup declarations
encoding - character encoding (for example "UTF-8"), case-insensitive, (IANA registered name)
Throws:
KNXMLException - on output error

writeElement

public void writeElement(java.lang.String name,
                         java.util.List att,
                         java.lang.String content)
                  throws KNXMLException
Description copied from interface: XMLWriter
Writes a new element to the current position in a document.

Predefined entities in text are replaced with references before write.

Specified by:
writeElement in interface XMLWriter
Parameters:
name - element name, the element's type
att - attribute specifications for this element, empty list or null for no attributes
content - text to write, the character data, null for no data
Throws:
KNXMLException - on output error

writeEmptyElement

public void writeEmptyElement(java.lang.String name,
                              java.util.List att)
                       throws KNXMLException
Description copied from interface: XMLWriter
Writes an empty element tag to the current position in a document.

Note that an empty element tag has no content and XMLWriter.endElement() does not recognize such elements.

Specified by:
writeEmptyElement in interface XMLWriter
Parameters:
name - element name, the element's type
att - attribute specifications for this element, empty list or null for no attributes
Throws:
KNXMLException - on output error