net.sf.jsefa.xml.lowlevel
Class StaxBasedXmlLowLevelSerializer

java.lang.Object
  extended by net.sf.jsefa.xml.lowlevel.StaxBasedXmlLowLevelSerializer
All Implemented Interfaces:
LowLevelSerializer, XmlLowLevelSerializer

public final class StaxBasedXmlLowLevelSerializer
extends Object
implements XmlLowLevelSerializer

Stax based implementation of XmlLowLevelSerializer.

Author:
Norman Lahme-Huetig, Matthias Derer

Constructor Summary
StaxBasedXmlLowLevelSerializer(XmlLowLevelConfiguration config)
          Constructs a new StaxBasedXmlLowLevelSerializer.
 
Method Summary
 void close(boolean closeWriter)
          Closes the serialization stream.
 void flush()
          Flushes the stream.
 void open(Writer writer)
          Opens a new serialization stream based on the given writer.
 void writeAttribute(QName name, String value)
          Writes an attribute with the given name and value.
 void writeDocTypeDeclaration(QName rootElementName, String publicId, String systemId)
          Writes the DOCTYPE declaration.
 void writeEndElement()
          Writes the end tag of the current element.
 void writeStartElement(QName name)
          Writes the start tag of an element.
 void writeStartElement(QName name, QName dataTypeName)
          Writes the start tag of an element.
 void writeText(String text, TextMode textMode)
          Writes the given text as the content of the current element if the text is not empty.
 void writeXmlDeclaration(String version, String encoding)
          Writes the XML Declaration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StaxBasedXmlLowLevelSerializer

public StaxBasedXmlLowLevelSerializer(XmlLowLevelConfiguration config)
Constructs a new StaxBasedXmlLowLevelSerializer.

Parameters:
config - the configuration object
Method Detail

open

public void open(Writer writer)
Opens a new serialization stream based on the given writer.

Specified by:
open in interface LowLevelSerializer
Parameters:
writer - the writer to base the stream on

writeXmlDeclaration

public void writeXmlDeclaration(String version,
                                String encoding)
Writes the XML Declaration. Note that the encoding parameter does not set the actual encoding of the underlying writer.

Specified by:
writeXmlDeclaration in interface XmlLowLevelSerializer
Parameters:
version - version of the xml document
encoding - encoding of the xml declaration

writeDocTypeDeclaration

public void writeDocTypeDeclaration(QName rootElementName,
                                    String publicId,
                                    String systemId)
Writes the DOCTYPE declaration.

Specified by:
writeDocTypeDeclaration in interface XmlLowLevelSerializer
Parameters:
rootElementName - the name of the root element.
publicId - the public id - may be null
systemId - the system id

writeStartElement

public void writeStartElement(QName name)
Writes the start tag of an element.

Specified by:
writeStartElement in interface XmlLowLevelSerializer
Parameters:
name - the name of the element

writeStartElement

public void writeStartElement(QName name,
                              QName dataTypeName)
Writes the start tag of an element.

Specified by:
writeStartElement in interface XmlLowLevelSerializer
Parameters:
name - the name of the element
dataTypeName - the name of its data type

writeAttribute

public void writeAttribute(QName name,
                           String value)
Writes an attribute with the given name and value.

Specified by:
writeAttribute in interface XmlLowLevelSerializer
Parameters:
name - the attribute name
value - the attribute value

writeText

public void writeText(String text,
                      TextMode textMode)
Writes the given text as the content of the current element if the text is not empty. Otherwise nothing happens.

Specified by:
writeText in interface XmlLowLevelSerializer
Parameters:
text - the text.
textMode - the text mode (IMPLICIT/CDATA).

writeEndElement

public void writeEndElement()
Writes the end tag of the current element.

Specified by:
writeEndElement in interface XmlLowLevelSerializer

flush

public void flush()
Flushes the stream.

Specified by:
flush in interface LowLevelSerializer

close

public void close(boolean closeWriter)
Closes the serialization stream. The underlying writer will be closed only if closeWriter is true, too.

Specified by:
close in interface LowLevelSerializer
Parameters:
closeWriter - if true, the underlying writer will be closed, too.


Copyright © 2014. All rights reserved.