org.writersforge.catalan.transform
Class BeanToXml

java.lang.Object
  |
  +--org.writersforge.catalan.transform.BaseNodeProcessor
        |
        +--org.writersforge.catalan.transform.BeanToXml
All Implemented Interfaces:
org.writersforge.bellows.traverse.NodeProcessor

public class BeanToXml
extends BaseNodeProcessor

A processor which converts each input node into an XML tree. Input nodes of a fundamental type like Integer or String are converted into a single Datum element. Composite JavaBean input nodes are recursed and converted into a closely mapped XML tree. The XML naming conventions can be controlled by parameters, e.g., <theRoot>, <TheRoot>, <the-root>, <the_root>, <THE-ROOT>, or <THE_ROOT>. Complex types like arrays and embedded JavaBeans will always manifest as element content, but primitive JavaBean properties can be configured to show up as attributes or as element content.

Author:
jsheets

Constructor Summary
BeanToXml()
          Creates a new instance of BeanToXml.
BeanToXml(boolean collapse, org.writersforge.bellows.util.PropertyName.PropertyStyle style)
          Creates a new instance of BeanToXml with the specified collapse and naming style.
 
Method Summary
 java.util.List processNode(java.lang.Object node)
          Process a single node.
 
Methods inherited from class org.writersforge.catalan.transform.BaseNodeProcessor
addLeftover, end, getLeftovers, getNodes, start
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BeanToXml

public BeanToXml()
Creates a new instance of BeanToXml.


BeanToXml

public BeanToXml(boolean collapse,
                 org.writersforge.bellows.util.PropertyName.PropertyStyle style)
Creates a new instance of BeanToXml with the specified collapse and naming style.

Parameters:
collapse - true to collapse simple properties into XML attributes on bean's element, or false to declare simple properties as full elements inside the bean's element
style - the property naming style to use when creating XML elements and attributes
Method Detail

processNode

public java.util.List processNode(java.lang.Object node)
Process a single node. The processing action can be any arbitrary task, such as text replacement, data restructuring, or even statistical gathering. The processor should return a processed version of the node; this can be the same object untouched, or the same object modified, or a new set of objects.

Parameters:
node - the node to process
Returns:
a List of processing results (can be empty)