org.writersforge.catalan.process.workers.javabean
Class BeanToXmlCommand

java.lang.Object
  extended byorg.writersforge.catalan.process.workers.BaseMetadataHolder
      extended byorg.writersforge.catalan.process.commands.BaseCommand
          extended byorg.writersforge.catalan.process.workers.javabean.BeanToXmlCommand
All Implemented Interfaces:
ICommand, IMetadataHolder

public class BeanToXmlCommand
extends BaseCommand

Implementation of "bean-to-xml" command.

A helper 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.

This class can also be used as a standalone utility, outside the context of a worker runtime, by calling the convertBean() method directly.

Author:
jsheets

Constructor Summary
BeanToXmlCommand()
          Creates a new instance of BeanToXmlCommand.
 
Method Summary
 org.writersforge.bellows.Datum convertBean(java.lang.Object node, org.writersforge.bellows.util.PropertyName.PropertyStyle style, boolean collapse)
          Converts an arbitrary JavaBean object into a Bellows XML tree.
 void run(CommandContext context)
          Invokes this command against the given workspace with the given runtime properties.
 
Methods inherited from class org.writersforge.catalan.process.workers.BaseMetadataHolder
getMetadata, setOptionalProperties, setRequiredProperties, validateProperties, validateType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.writersforge.catalan.process.workers.IMetadataHolder
getMetadata, validateProperties, validateType
 

Constructor Detail

BeanToXmlCommand

public BeanToXmlCommand()
                 throws MetadataException
Creates a new instance of BeanToXmlCommand.

Throws:
MetadataException - if unable to initialize metadata
Method Detail

run

public void run(CommandContext context)
         throws ProcessException
Invokes this command against the given workspace with the given runtime properties. The owning Worker should verify that all required properties are present before invoking run().

Parameters:
context - command context
Throws:
ProcessException - if a fatal error occurs during processing

convertBean

public org.writersforge.bellows.Datum convertBean(java.lang.Object node,
                                                  org.writersforge.bellows.util.PropertyName.PropertyStyle style,
                                                  boolean collapse)
Converts an arbitrary JavaBean object into a Bellows XML tree.

Parameters:
node - JavaBean object
style - XML naming style
collapse - true to represent properties as XML attributes, or false to represent them as nested elements
Returns:
XML version of the JavaBean
See Also:
PropertyName.PropertyStyle