Last update: 2011-06-23

org.proteios.io
Interface XMLCrudeWriter

All Known Subinterfaces:
XMLCrudeWriter2, XMLCrudeWriter3
All Known Implementing Classes:
XMLCrudeWriter2Impl, XMLCrudeWriter3Impl, XMLCrudeWriterImpl

public interface XMLCrudeWriter

This interface defines crude XML writing. This interface contains some methods that may help writing XML files. It was created as support for e.g. writing single tags with XMLStreamWriter could not be found. It is up to the implementations to decide on indentation, which may be ignored if desired, but if guidelines are requested, recommended use is as follows: To get consistent indentation and change to a new line, the following rules are used: 1. A start element or comment starts a new line. 2. An end element starts a new line, unless following data. 3. Indentation level is increased by one before start element. 4. Indentation level is decreased by one after end element. To avoid having the outermost element block indented, the indentaiion level starts at -1 instead of 0.

Version:
2.0
Author:
Olle
Last modified
$Date: 2009-04-09 08:48:11 +0200 (Thu, 09 Apr 2009) $

Method Summary
 void close()
          Close (not) output stream.
 void flush()
          Flushes output stream.
 OutputStream getOutStream()
          Get FileWriter output stream.
 boolean isIndentationUsed()
          Get indentation use flag.
 void setIndentationUsed(boolean indentationUsed)
          Set indentation use flag.
 void setOutStream(OutputStream outStream)
          Set FileWriter output stream.
 void writeAttribute(String name, String value)
          Writes XML attribute.
 void writeCharacters(String text)
          Writes text between XML start and end tags.
 void writeComment(String comment)
          Writes XML comment.
 void writeEndDocument()
          Writes end of XML document.
 void writeEndElement(String element)
          Writes XML end element.
 void writeNamespace(String name, String value)
          Writes XML namespace.
 void writeSingleElementEnd()
          Writes XML single element end.
 void writeStartDocument(String encoding, String version)
          Writes XML file header.
 void writeStartElement(String element)
          Writes XML start element.
 void writeStartElementEnd()
          Writes XML start element end.
 

Method Detail

getOutStream

OutputStream getOutStream()
Get FileWriter output stream.

Returns:
outStream FileWriter output stream.

setOutStream

void setOutStream(OutputStream outStream)
Set FileWriter output stream.

Parameters:
outStream - FileWriter output stream.

isIndentationUsed

boolean isIndentationUsed()
Get indentation use flag.

Returns:
indentationUsed boolean indentation use flag.

setIndentationUsed

void setIndentationUsed(boolean indentationUsed)
Set indentation use flag.

Parameters:
indentationUsed - boolean indenation use flag.

writeStartDocument

void writeStartDocument(String encoding,
                        String version)
                        throws javax.xml.stream.XMLStreamException
Writes XML file header.

Parameters:
encoding - String with XML encoding.
version - String with XML version.
Throws:
javax.xml.stream.XMLStreamException - If there is an error

writeEndDocument

void writeEndDocument()
                      throws javax.xml.stream.XMLStreamException
Writes end of XML document. Note that unlike e.g. XMLStreamWriter writeEndDocument() method, this does not close any open tags, but simple writes a line separator to finish the last line. All tags must be closed by "hand".

Throws:
javax.xml.stream.XMLStreamException - If there is an error

writeComment

void writeComment(String comment)
                  throws javax.xml.stream.XMLStreamException
Writes XML comment.

Parameters:
comment - String with comment.
Throws:
javax.xml.stream.XMLStreamException - If there is an error

writeStartElement

void writeStartElement(String element)
                       throws javax.xml.stream.XMLStreamException
Writes XML start element.

Parameters:
element - String with element name.
Throws:
javax.xml.stream.XMLStreamException - If there is an error

writeAttribute

void writeAttribute(String name,
                    String value)
                    throws javax.xml.stream.XMLStreamException
Writes XML attribute.

Parameters:
name - String with attribute name.
value - String with attribute value.
Throws:
javax.xml.stream.XMLStreamException - If there is an error

writeNamespace

void writeNamespace(String name,
                    String value)
                    throws javax.xml.stream.XMLStreamException
Writes XML namespace.

Parameters:
name - String with namespace name.
value - String with namespace value.
Throws:
javax.xml.stream.XMLStreamException - If there is an error

writeStartElementEnd

void writeStartElementEnd()
                          throws javax.xml.stream.XMLStreamException
Writes XML start element end.

Throws:
javax.xml.stream.XMLStreamException - If there is an error

writeSingleElementEnd

void writeSingleElementEnd()
                           throws javax.xml.stream.XMLStreamException
Writes XML single element end.

Throws:
javax.xml.stream.XMLStreamException - If there is an error

writeEndElement

void writeEndElement(String element)
                     throws javax.xml.stream.XMLStreamException
Writes XML end element.

Parameters:
element - String with element name.
Throws:
javax.xml.stream.XMLStreamException - If there is an error

writeCharacters

void writeCharacters(String text)
                     throws javax.xml.stream.XMLStreamException
Writes text between XML start and end tags.

Parameters:
text - String with element text.
Throws:
javax.xml.stream.XMLStreamException - If there is an error

flush

void flush()
           throws javax.xml.stream.XMLStreamException
Flushes output stream.

Throws:
javax.xml.stream.XMLStreamException - If there is an error

close

void close()
           throws javax.xml.stream.XMLStreamException
Close (not) output stream.

Throws:
javax.xml.stream.XMLStreamException - If there is an error

Last update: 2011-06-23