org.kxml.io
Class AbstractXmlWriter

java.lang.Object
  extended by java.io.Writer
      extended by org.kxml.io.AbstractXmlWriter
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, java.lang.Appendable
Direct Known Subclasses:
WbxmlWriter, XmlWriter

public abstract class AbstractXmlWriter
extends java.io.Writer

An abstract XmlWriter including namespace handling.


Field Summary
protected  State current
           
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
AbstractXmlWriter()
           
 
Method Summary
abstract  void attribute(java.lang.String name, java.lang.String value)
          writes an attribute.
 void attribute(java.lang.String namespace, java.lang.String name, java.lang.String value)
          writes an attribute with the given namespace.
abstract  void endTag()
          Abstract method for writing an end tag.
 PrefixMap getPrefixMap()
           
protected abstract  void startTag(PrefixMap prefixMap, java.lang.String tag)
          abstract method that must be overwritten by a method actually writing the resolved start tag without namespace checking.
 void startTag(PrefixMap prefixMap, java.lang.String namespace, java.lang.String name)
          writes a start tag with the given name, using the given prefix map.
 void startTag(java.lang.String name)
          convenience method for startTag (Xml.NO_NAMESPACE, name)
 void startTag(java.lang.String namespace, java.lang.String name)
          writes a start tag with the given namespace and name
abstract  void writeLegacy(int type, java.lang.String text)
          writes Xml.DOCTYPE, Xml.PROCESSING_INSTRUCTION or Xml.COMMENT
 
Methods inherited from class java.io.Writer
append, append, append, close, flush, write, write, write, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

current

protected State current
Constructor Detail

AbstractXmlWriter

public AbstractXmlWriter()
Method Detail

attribute

public abstract void attribute(java.lang.String name,
                               java.lang.String value)
                        throws java.io.IOException
writes an attribute. Only allowed immediately after startTag or attribute.

Throws:
java.io.IOException

attribute

public void attribute(java.lang.String namespace,
                      java.lang.String name,
                      java.lang.String value)
               throws java.io.IOException
writes an attribute with the given namespace. Only allowed immediately after startTag or another attribute call.

Throws:
java.io.IOException

getPrefixMap

public PrefixMap getPrefixMap()

startTag

public void startTag(PrefixMap prefixMap,
                     java.lang.String namespace,
                     java.lang.String name)
              throws java.io.IOException
writes a start tag with the given name, using the given prefix map. This method cares about the namespace prefixes and calls startTag (PrefixMap prefixMap, String tag) for concrete writing.

Throws:
java.io.IOException

startTag

public void startTag(java.lang.String namespace,
                     java.lang.String name)
              throws java.io.IOException
writes a start tag with the given namespace and name

Throws:
java.io.IOException

startTag

public void startTag(java.lang.String name)
              throws java.io.IOException
convenience method for startTag (Xml.NO_NAMESPACE, name)

Throws:
java.io.IOException

startTag

protected abstract void startTag(PrefixMap prefixMap,
                                 java.lang.String tag)
                          throws java.io.IOException
abstract method that must be overwritten by a method actually writing the resolved start tag without namespace checking. This implementation just puts the state on the stack.

Attention: The actual implementation include the following line in order to put the current State on the stack!

current = new State (current, prefixMap, tag);

Throws:
java.io.IOException

endTag

public abstract void endTag()
                     throws java.io.IOException
Abstract method for writing an end tag. Attention: Concrete implementations must pop the previous stack from the stack:

current = current.prev;

Throws:
java.io.IOException

writeLegacy

public abstract void writeLegacy(int type,
                                 java.lang.String text)
                          throws java.io.IOException
writes Xml.DOCTYPE, Xml.PROCESSING_INSTRUCTION or Xml.COMMENT

Throws:
java.io.IOException