com.generationjava.io.xml
Class EmptyElementXmlWriter

java.lang.Object
  extended by com.generationjava.io.xml.DelegatingXmlWriter
      extended by com.generationjava.io.xml.EmptyElementXmlWriter
All Implemented Interfaces:
XmlWriter

public class EmptyElementXmlWriter
extends DelegatingXmlWriter

Has various strategies for dealing with null or empty-string values.


Field Summary
static Object EMPTY_MODE
          Considers null and an empty string to be 'empty'.
static Object IGNORE_EMPTY_MODE
          Ignores empty concepts and prints out all attributes/entities.
static Object NULL_EMPTY_MODE
          Only considers null to be empty, so empty strings are outputted.
 
Constructor Summary
EmptyElementXmlWriter(XmlWriter xmlwriter)
          Create an EmptyElementXmlWriter on top of an existing java.io.Writer.
 
Method Summary
 XmlWriter setEmptyMode(Object mode)
          The emptiness strategy to use.
 XmlWriter writeAttribute(String attr, Object value)
          Write an attribute out for the current entity.
 XmlWriter writeCData(String cdata)
          Write out a chunk of CDATA.
 XmlWriter writeComment(String comment)
          Write out a chunk of comment.
 XmlWriter writeEntity(String name)
          Begin to write out an entity.
 XmlWriter writeText(Object text)
          Output body text.
 
Methods inherited from class com.generationjava.io.xml.DelegatingXmlWriter
close, endEntity, getWriter, writeEmptyEntity, writeEntityWithText, writeXmlVersion, writeXmlVersion, writeXmlVersion
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IGNORE_EMPTY_MODE

public static final Object IGNORE_EMPTY_MODE
Ignores empty concepts and prints out all attributes/entities. So it will print out foo="null"


NULL_EMPTY_MODE

public static final Object NULL_EMPTY_MODE
Only considers null to be empty, so empty strings are outputted.


EMPTY_MODE

public static final Object EMPTY_MODE
Considers null and an empty string to be 'empty'. If somethign is empty, it will not output them. This is the default mode.

Constructor Detail

EmptyElementXmlWriter

public EmptyElementXmlWriter(XmlWriter xmlwriter)
Create an EmptyElementXmlWriter on top of an existing java.io.Writer.

Method Detail

setEmptyMode

public XmlWriter setEmptyMode(Object mode)
The emptiness strategy to use. Emptiness is when it decides that an element should be ignored.


writeEntity

public XmlWriter writeEntity(String name)
                      throws IOException
Description copied from class: DelegatingXmlWriter
Begin to write out an entity. Unlike the helper tags, this tag will need to be ended with the endEntity method.

Specified by:
writeEntity in interface XmlWriter
Overrides:
writeEntity in class DelegatingXmlWriter
Parameters:
name - String name of tag
Throws:
IOException

writeAttribute

public XmlWriter writeAttribute(String attr,
                                Object value)
                         throws IOException
Description copied from class: DelegatingXmlWriter
Write an attribute out for the current entity. Any xml characters in the value are escaped. Currently it does not actually throw the exception, but the api is set that way for future changes.

Specified by:
writeAttribute in interface XmlWriter
Overrides:
writeAttribute in class DelegatingXmlWriter
Parameters:
String - name of attribute.
Object - value of attribute.
Throws:
IOException

writeText

public XmlWriter writeText(Object text)
                    throws IOException
Output body text. Any xml characters are escaped.

Specified by:
writeText in interface XmlWriter
Overrides:
writeText in class DelegatingXmlWriter
Throws:
IOException

writeCData

public XmlWriter writeCData(String cdata)
                     throws IOException
Write out a chunk of CDATA. This helper method surrounds the passed in data with the CDATA tag.

Specified by:
writeCData in interface XmlWriter
Overrides:
writeCData in class DelegatingXmlWriter
Parameters:
String - of CDATA text.
Throws:
IOException

writeComment

public XmlWriter writeComment(String comment)
                       throws IOException
Write out a chunk of comment. This helper method surrounds the passed in data with the xml comment tag.

Specified by:
writeComment in interface XmlWriter
Overrides:
writeComment in class DelegatingXmlWriter
Parameters:
String - of text to comment.
Throws:
IOException


Copyright © 2000-2007 OSJava. All Rights Reserved.