tuwien.auto.calimero.xml
Interface XMLWriter

All Known Implementing Classes:
DefaultXMLWriter

public interface XMLWriter

XML writer implementations don't need to be thread safe.


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 text)
          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.
 

Method Detail

close

void close()
           throws KNXMLException
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.

Throws:
KNXMLException
See Also:
endAllElements()

endAllElements

void endAllElements()
                    throws KNXMLException
Closes all open elements and flushes buffered data to output.

Throws:
KNXMLException - on output error

endElement

void endElement()
                throws KNXMLException
Closes the current element.

Throws:
KNXMLException - on output error

setOutput

void setOutput(java.io.Writer output,
               boolean close)
Sets the output destination for this XML writer.

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

Parameters:
output - a writer for output
close - true if the specified writer should be closed on close(), false to leave it open

writeCharData

void writeCharData(java.lang.String text,
                   boolean isCDATASection)
                   throws KNXMLException
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.

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

void writeComment(java.lang.String comment)
                  throws KNXMLException
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.

Parameters:
comment - text of the comment
Throws:
KNXMLException - on output error

writeDeclaration

void writeDeclaration(boolean standalone,
                      java.lang.String encoding)
                      throws KNXMLException
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.

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

void writeElement(java.lang.String name,
                  java.util.List att,
                  java.lang.String text)
                  throws KNXMLException
Writes a new element to the current position in a document.

Predefined entities in text are replaced with references before write.

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

writeEmptyElement

void writeEmptyElement(java.lang.String name,
                       java.util.List att)
                       throws KNXMLException
Writes an empty element tag to the current position in a document.

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

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