de.topicmapslab.majortom.io
Class XMLC14NWriter

java.lang.Object
  extended by de.topicmapslab.majortom.io.XMLC14NWriter

final class XMLC14NWriter
extends java.lang.Object

Simple SAX-alike XML writer that respects canonical XML to some extend.

This class is not meant to be a generic XML-C14N writer, but it is good enough to support CXTM.

Version:
$Rev: 360 $ - $Date: 2009-11-04 17:58:30 +0100 (Wed, 04 Nov 2009) $ Note: This class was boldly stolen from the tinyTiM project
Author:
Lars Heuer (heuer[at]semagia.com) Semagia

Field Summary
private static char _NL
           
private  java.io.OutputStreamWriter _out
           
static org.xml.sax.Attributes EMPTY_ATTRS
           
 
Constructor Summary
XMLC14NWriter(java.io.OutputStream out)
           
 
Method Summary
private  void _writeEscapedAttributeValue(java.lang.String value)
          Escapes the attribute's value according to canonical XML.
private  void _writeEscapedTextContent(java.lang.String value)
          Escapes the data according to the canonical XML rules.
 void characters(java.lang.String data)
          Writes the specified characters to the output.
 void endDocument()
          Indicates the end of the serialization process.
 void endElement(java.lang.String localName)
          Indicates the end of an elemnt.
 void newline()
          Writes a #x0A to the output.
 void startDocument()
          Indicates the start of the serialization process.
 void startElement(java.lang.String localName)
          Indicates the start of an element with the specified local name.
 void startElement(java.lang.String localName, org.xml.sax.Attributes attrs)
          Indicates the start of an element with the provided local name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_ATTRS

public static final org.xml.sax.Attributes EMPTY_ATTRS

_NL

private static final char _NL
See Also:
Constant Field Values

_out

private final java.io.OutputStreamWriter _out
Constructor Detail

XMLC14NWriter

public XMLC14NWriter(java.io.OutputStream out)
              throws java.io.IOException
Throws:
java.io.IOException
Method Detail

startDocument

public void startDocument()
                   throws java.io.IOException
Indicates the start of the serialization process.

Throws:
java.io.IOException - If an error occurs.

endDocument

public void endDocument()
                 throws java.io.IOException
Indicates the end of the serialization process.

Throws:
java.io.IOException - If an error occurs.

startElement

public void startElement(java.lang.String localName)
                  throws java.io.IOException
Indicates the start of an element with the specified local name.

Parameters:
localName - The element's name.
Throws:
java.io.IOException - If an error occurs.
See Also:
startElement(String, Attributes).

startElement

public void startElement(java.lang.String localName,
                         org.xml.sax.Attributes attrs)
                  throws java.io.IOException
Indicates the start of an element with the provided local name. The attributes written in canonical XML.

Parameters:
localName - The name of the element.
attrs - The element's attributes.
Throws:
java.io.IOException - If an error occurs.

endElement

public void endElement(java.lang.String localName)
                throws java.io.IOException
Indicates the end of an elemnt.

Parameters:
localName - The element's name.
Throws:
java.io.IOException - If an error occurs.

newline

public void newline()
             throws java.io.IOException
Writes a #x0A to the output.

Throws:
java.io.IOException - If an error occurs.

characters

public void characters(java.lang.String data)
                throws java.io.IOException
Writes the specified characters to the output.

The data is written according to the rules of canonicalized XML.

Parameters:
data - The data to write.
Throws:
java.io.IOException - If an error occurs.

_writeEscapedTextContent

private void _writeEscapedTextContent(java.lang.String value)
                               throws java.io.IOException
Escapes the data according to the canonical XML rules.

Parameters:
value - The value.
Throws:
java.io.IOException

_writeEscapedAttributeValue

private void _writeEscapedAttributeValue(java.lang.String value)
                                  throws java.io.IOException
Escapes the attribute's value according to canonical XML.

Parameters:
value - The value to escape.
Throws:
java.io.IOException