net.sf.fikin.pojostate.format
Class XmlStateFormat

java.lang.Object
  extended by java.text.Format
      extended by net.sf.fikin.pojostate.StateFormat
          extended by net.sf.fikin.pojostate.format.PropertiesStateFormat
              extended by net.sf.fikin.pojostate.format.XmlStateFormat
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class XmlStateFormat
extends PropertiesStateFormat

Print a State object in an XML format.

XML schema is located at TODO created on Mar 7, 2007

Since:
Version:
$Revision: 1.2 $
Author:
fiykov
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.text.Format
java.text.Format.Field
 
Field Summary
static java.lang.String NS_PS_URI
          namespace of pojo-state XSD
 
Constructor Summary
XmlStateFormat()
           
 
Method Summary
 void format(java.lang.Object obj, java.lang.Object out)
          format the object as an XML output.
 void format(State state, org.xml.sax.ContentHandler out)
          TODO Output stream is not closed!
 void format(State state, java.io.PrintWriter out)
          TODO Output stream is not closed!
 java.lang.String getXmlStylesheetType()
           
 java.lang.String getXmlStylesheetURI()
           
 boolean isPrintStartEndDoc()
          if set to true it will call ContentHandler.startDocument() and ContentHandler.endDocument() prior and after printing.
 boolean isPrintXmlStylesheet()
           
 void printFooter(State state, org.xml.sax.ContentHandler out)
          TODO
 void printHeader(State state, org.xml.sax.ContentHandler out)
          TODO
 void printProperty(Property property, org.xml.sax.ContentHandler out)
          TODO
protected  void printTag(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attrs, java.lang.String data, org.xml.sax.ContentHandler out)
          TODO
 void setPrintStartEndDoc(boolean printStartEndDoc)
           
 void setPrintXmlStylesheet(boolean printXsltInstruction)
          if set to true it will print "xslt" xml-instruction at the beginning of printing.
 void setXmlStylesheetType(java.lang.String xmlStylesheetType)
          set the xml stylesheet type it requires isPrintXmlStylesheet() to be true.
 void setXmlStylesheetURI(java.lang.String xmlStylesheetURI)
          set the xml stylesheet URI it requires isPrintXmlStylesheet() to be true.
 
Methods inherited from class net.sf.fikin.pojostate.format.PropertiesStateFormat
format, parseObject, printFooter, printHeader, printProperty
 
Methods inherited from class java.text.Format
clone, format, formatToCharacterIterator, parseObject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NS_PS_URI

public static final java.lang.String NS_PS_URI
namespace of pojo-state XSD

See Also:
Constant Field Values
Constructor Detail

XmlStateFormat

public XmlStateFormat()
Method Detail

getXmlStylesheetType

public java.lang.String getXmlStylesheetType()
Returns:
Returns the xmlStylesheetType, by default is "text/css"
See Also:
setXmlStylesheetType(String)

setXmlStylesheetType

public void setXmlStylesheetType(java.lang.String xmlStylesheetType)
set the xml stylesheet type

it requires isPrintXmlStylesheet() to be true.

Parameters:
xmlStylesheetType - The xmlStylesheetType to set.

getXmlStylesheetURI

public java.lang.String getXmlStylesheetURI()
Returns:
Returns the xmlStylesheetURI, by default is "pojo-state.css"
See Also:
setXmlStylesheetURI(String)

setXmlStylesheetURI

public void setXmlStylesheetURI(java.lang.String xmlStylesheetURI)
set the xml stylesheet URI

it requires isPrintXmlStylesheet() to be true.

Parameters:
xmlStylesheetURI - The xmlStylesheetURI to set.

isPrintStartEndDoc

public boolean isPrintStartEndDoc()
if set to true it will call ContentHandler.startDocument() and ContentHandler.endDocument() prior and after printing.

Returns:
Returns the printStartEndDoc, by default true

setPrintStartEndDoc

public void setPrintStartEndDoc(boolean printStartEndDoc)
Parameters:
printStartEndDoc - The printStartEndDoc to set.
See Also:
setPrintStartEndDoc(boolean)

isPrintXmlStylesheet

public boolean isPrintXmlStylesheet()
Returns:
Returns the printXsltInstruction, by default true
See Also:
setPrintXmlStylesheet(boolean)

setPrintXmlStylesheet

public void setPrintXmlStylesheet(boolean printXsltInstruction)
if set to true it will print "xslt" xml-instruction at the beginning of printing.

it requires isPrintStartEndDoc() to be true as well.

Parameters:
printXsltInstruction - The printXsltInstruction to set.

format

public void format(java.lang.Object obj,
                   java.lang.Object out)
            throws java.lang.IllegalArgumentException,
                   java.io.IOException
format the object as an XML output.

If output is not of type org.xml.sax.ContentHandler it fails to default implementation provided by PropertiesStateFormat.format(Object, Object).

Some of the printed XML properties (like directives, start-end document and such) can be influenced by th setter methods of this class.

Overrides:
format in class PropertiesStateFormat
Parameters:
obj - to format
out - to print to
Throws:
java.lang.IllegalArgumentException
java.io.IOException - in case when writting to output object failed

format

public void format(State state,
                   java.io.PrintWriter out)
            throws java.io.IOException
TODO

Output stream is not closed!

Overrides:
format in class PropertiesStateFormat
Parameters:
state -
out -
Throws:
java.io.IOException

format

public void format(State state,
                   org.xml.sax.ContentHandler out)
            throws java.io.IOException
TODO

Output stream is not closed!

Parameters:
state -
out -
Throws:
java.io.IOException

printHeader

public void printHeader(State state,
                        org.xml.sax.ContentHandler out)
                 throws org.xml.sax.SAXException
TODO

Parameters:
state -
out -
Throws:
org.xml.sax.SAXException

printFooter

public void printFooter(State state,
                        org.xml.sax.ContentHandler out)
                 throws org.xml.sax.SAXException
TODO

Parameters:
state -
out -
Throws:
org.xml.sax.SAXException

printProperty

public void printProperty(Property property,
                          org.xml.sax.ContentHandler out)
                   throws org.xml.sax.SAXException
TODO

Parameters:
property -
out -
Throws:
org.xml.sax.SAXException

printTag

protected void printTag(java.lang.String uri,
                        java.lang.String localName,
                        java.lang.String qName,
                        org.xml.sax.Attributes attrs,
                        java.lang.String data,
                        org.xml.sax.ContentHandler out)
                 throws org.xml.sax.SAXException
TODO

Parameters:
uri -
localName -
qName -
attrs -
data -
out -
Throws:
org.xml.sax.SAXException


Copyright © 2005 Nikolay Fiykov. All Rights Reserved.