Last update: 2011-06-23

org.proteios.io
Class XMLCrudeWriter2Impl

java.lang.Object
  extended by org.proteios.io.XMLCrudeWriterImpl
      extended by org.proteios.io.XMLCrudeWriter2Impl
All Implemented Interfaces:
XMLCrudeWriter, XMLCrudeWriter2

public class XMLCrudeWriter2Impl
extends XMLCrudeWriterImpl
implements XMLCrudeWriter2

This class supports crude XML writing, with some added convenience methods. This class 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. 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: 2007-05-09 10:59:00 +0200 (Wed, 09 May 2007) $

Constructor Summary
XMLCrudeWriter2Impl(OutputStream outStream)
          Constructor that takes an output stream as parameter.
 
Method Summary
 void writeEndTag(String element)
          Writes XML end tag for XML block.
 void writeSimpleElementPair(String elementName, String data)
          Convenience method for writing simple element pair.
 void writeStartListTag(String element, int count)
          Writes XML start list tag for XML block.
 void writeStartTag(String element)
          Writes XML start tag for XML block.
 
Methods inherited from class org.proteios.io.XMLCrudeWriterImpl
close, flush, getByteBufferSize, getOutStream, isIndentationUsed, setByteBufferSize, setIndentationUsed, setOutStream, writeAttribute, writeCharacters, writeComment, writeEndDocument, writeEndElement, writeIndentedText, writeNamespace, writeSingleElementEnd, writeStartDocument, writeStartElement, writeStartElementEnd, writeStyleSheetHeader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.proteios.io.XMLCrudeWriter
close, flush, getOutStream, isIndentationUsed, setIndentationUsed, setOutStream, writeAttribute, writeCharacters, writeComment, writeEndDocument, writeEndElement, writeNamespace, writeSingleElementEnd, writeStartDocument, writeStartElement, writeStartElementEnd
 

Constructor Detail

XMLCrudeWriter2Impl

public XMLCrudeWriter2Impl(OutputStream outStream)
Constructor that takes an output stream as parameter.

Parameters:
outStream - The FileWriter output stream to use.
Method Detail

writeStartTag

public void writeStartTag(String element)
                   throws javax.xml.stream.XMLStreamException
Writes XML start tag for XML block.

Specified by:
writeStartTag in interface XMLCrudeWriter2
Parameters:
element - String with element name.
Throws:
javax.xml.stream.XMLStreamException - If there is an XML Stream related error

writeStartListTag

public void writeStartListTag(String element,
                              int count)
                       throws javax.xml.stream.XMLStreamException
Writes XML start list tag for XML block.

Specified by:
writeStartListTag in interface XMLCrudeWriter2
Parameters:
element - String with element name.
count - int the number of XML blocks in the list.
Throws:
javax.xml.stream.XMLStreamException - If there is an XML Stream related error

writeEndTag

public void writeEndTag(String element)
                 throws javax.xml.stream.XMLStreamException
Writes XML end tag for XML block.

Specified by:
writeEndTag in interface XMLCrudeWriter2
Parameters:
element - String with element name.
Throws:
javax.xml.stream.XMLStreamException - If there is an XML Stream related error

writeSimpleElementPair

public void writeSimpleElementPair(String elementName,
                                   String data)
                            throws javax.xml.stream.XMLStreamException
Convenience method for writing simple element pair. Writes XMl expression like: data

Specified by:
writeSimpleElementPair in interface XMLCrudeWriter2
Parameters:
elementName - String with element name.
data - String with element data.
Throws:
javax.xml.stream.XMLStreamException - If there is an XML Stream related error

Last update: 2011-06-23