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

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

public class XmlToBeanCommand
extends BaseCommand

Implementation of "xml-to-bean" command.

A command which converts each Datum input node into a JavaBean. Each XML-to-JavaBean conversion consists of two consecutive input data nodes: the target JavaBean class (as a fully qualified class name String or as a Class object); and the Datum tree itself. The processor will do its best to reconcile the XML content with the target Java class according to a very simple mapping between XML and JavaBean properties. Data that does not correlate with a JavaBean property or cannot be converted to the desired property type will be ignored.

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

Author:
jsheets

Constructor Summary
XmlToBeanCommand()
          Creates a new instance of XmlToBeanCommand.
 
Method Summary
 java.lang.Object convertXml(java.lang.Class beanClass, org.writersforge.bellows.Datum xml)
          Loads an XML tree into a JavaBean object from a Java Class.
 java.lang.Object convertXml(java.lang.String beanClassName, org.writersforge.bellows.Datum xml)
          Loads an XML tree into a JavaBean object from a fully qualified class String.
 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

XmlToBeanCommand

public XmlToBeanCommand()
Creates a new instance of XmlToBeanCommand.

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

convertXml

public java.lang.Object convertXml(java.lang.String beanClassName,
                                   org.writersforge.bellows.Datum xml)
Loads an XML tree into a JavaBean object from a fully qualified class String. This method can be called outside the context of a worker.

Parameters:
beanClassName - class name of root JavaBean object
xml - XML content
Returns:
the loaded JavaBean object

convertXml

public java.lang.Object convertXml(java.lang.Class beanClass,
                                   org.writersforge.bellows.Datum xml)
Loads an XML tree into a JavaBean object from a Java Class.

Parameters:
beanClass - class of root JavaBean object
xml - XML content
Returns:
the loaded JavaBean object