com.generationjava.io.xml
Class FormattingXmlWriter

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

public class FormattingXmlWriter
extends DelegatingXmlWriter

Formats Numbers and Dates on the fly.


Constructor Summary
FormattingXmlWriter(XmlWriter writer)
           
 
Method Summary
protected  String format(Object unknown)
           
 FormattingXmlWriter setDateFormat(DateFormat format)
          When a java.util.Date object is written, it will use this to format it.
 FormattingXmlWriter setNumberFormat(NumberFormat format)
          When a Number object is written, it will use this to format it.
 XmlWriter writeAttribute(String name, Object value)
          Write an attribute out for the current entity.
 XmlWriter writeEntityWithText(String name, Object text)
          A helper method.
 XmlWriter writeText(Object text)
          Output body text.
 
Methods inherited from class com.generationjava.io.xml.DelegatingXmlWriter
close, endEntity, getWriter, writeCData, writeComment, writeEmptyEntity, writeEntity, writeXmlVersion, writeXmlVersion, writeXmlVersion
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FormattingXmlWriter

public FormattingXmlWriter(XmlWriter writer)
Method Detail

setNumberFormat

public FormattingXmlWriter setNumberFormat(NumberFormat format)
When a Number object is written, it will use this to format it. If the argument is null then it uses .toString.


setDateFormat

public FormattingXmlWriter setDateFormat(DateFormat format)
When a java.util.Date object is written, it will use this to format it. If the argument is null then it uses .toString.


writeEntityWithText

public XmlWriter writeEntityWithText(String name,
                                     Object text)
                              throws IOException
Description copied from class: DelegatingXmlWriter
A helper method. It writes out an entity which contains only text.

Specified by:
writeEntityWithText in interface XmlWriter
Overrides:
writeEntityWithText in class DelegatingXmlWriter
Parameters:
name - String name of tag
text - String of text to go inside the tag
Throws:
IOException

writeText

public XmlWriter writeText(Object text)
                    throws IOException
Description copied from class: DelegatingXmlWriter
Output body text. Any xml characters are escaped.

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

writeAttribute

public XmlWriter writeAttribute(String name,
                                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
Throws:
IOException

format

protected String format(Object unknown)


Copyright © 2000-2007 OSJava. All Rights Reserved.