org.apache.jsieve.util
Class XmlOut

java.lang.Object
  extended by org.apache.jsieve.util.XmlOut
All Implemented Interfaces:
SieveToXml.Out

public final class XmlOut
extends java.lang.Object
implements SieveToXml.Out

Lightweight SieveToXml#Out implementation.

Requires a wrapper to be used safely in a multithreaded environment.

Not intended to be subclassed. Please copy and hack!


Constructor Summary
XmlOut(java.io.Writer writer)
           
 
Method Summary
 void attribute(java.lang.CharSequence name, java.lang.CharSequence value)
          Writes an attribute of an element.
 void attribute(java.lang.CharSequence localName, java.lang.CharSequence uri, java.lang.CharSequence prefix, java.lang.CharSequence value)
          Outputs a attribute.
 void closeDocument()
          Closes all pending elements.
 void closeElement()
          Closes the last element written.
 void content(java.lang.CharSequence content)
          Writes content.
 void openElement(java.lang.CharSequence elementName)
          Writes the start of an element.
 void openElement(java.lang.CharSequence localName, java.lang.CharSequence uri, java.lang.CharSequence prefix)
          Starts an XML element.
 void startDocument()
          Starts a document by writing a prolog.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlOut

public XmlOut(java.io.Writer writer)
Method Detail

startDocument

public void startDocument()
                   throws java.io.IOException
Starts a document by writing a prolog. Calling this method is optional. When writing a document fragment, it should not be called.

Throws:
OperationNotAllowedException - if called after the first element has been written or once a prolog has already been written
java.io.IOException

openElement

public void openElement(java.lang.CharSequence elementName)
                 throws java.io.IOException
Writes the start of an element.

Parameters:
elementName - the name of the element, not null
Throws:
InvalidXmlException - if the name is not valid for an xml element
OperationNotAllowedException - if called after the first element has been closed
java.io.IOException

attribute

public void attribute(java.lang.CharSequence name,
                      java.lang.CharSequence value)
               throws java.io.IOException
Writes an attribute of an element. Note that this is only allowed directly after openElement(CharSequence) or attribute(java.lang.CharSequence, java.lang.CharSequence).

Parameters:
name - the attribute name, not null
value - the attribute value, not null
Throws:
InvalidXmlException - if the name is not valid for an xml attribute or if a value for the attribute has already been written
OperationNotAllowedException - if called after content(java.lang.CharSequence) or #closeElement() or before any call to {@link #openElement}
java.io.IOException

content

public void content(java.lang.CharSequence content)
             throws java.io.IOException
Writes content. Calling this method will automatically Note that this method does not use CDATA.

Specified by:
content in interface SieveToXml.Out
Parameters:
content - the content to write
Throws:
OperationNotAllowedException - if called before any call to openElement(java.lang.CharSequence) or after the first element has been closed
java.io.IOException - when output fails

closeElement

public void closeElement()
                  throws java.io.IOException
Closes the last element written.

Specified by:
closeElement in interface SieveToXml.Out
Throws:
OperationNotAllowedException - if called before any call to openElement(java.lang.CharSequence) or after the first element has been closed
java.io.IOException - when output fails

closeDocument

public void closeDocument()
                   throws java.io.IOException
Closes all pending elements. When appropriate, resources are also flushed and closed. No exception is raised when called upon a document whose root element has already been closed.

Throws:
OperationNotAllowedException - if called before any call to openElement(java.lang.CharSequence)
java.io.IOException

attribute

public void attribute(java.lang.CharSequence localName,
                      java.lang.CharSequence uri,
                      java.lang.CharSequence prefix,
                      java.lang.CharSequence value)
               throws java.io.IOException
Description copied from interface: SieveToXml.Out
Outputs a attribute.

Specified by:
attribute in interface SieveToXml.Out
value - unescaped XML attribute content, not null
Throws:
java.io.IOException - when output fails

openElement

public void openElement(java.lang.CharSequence localName,
                        java.lang.CharSequence uri,
                        java.lang.CharSequence prefix)
                 throws java.io.IOException
Description copied from interface: SieveToXml.Out
Starts an XML element.

Specified by:
openElement in interface SieveToXml.Out
Throws:
java.io.IOException - when output fails


Copyright © 2008-2009 The Apache Software Foundation. All Rights Reserved.