org.writersforge.catalan.process.workers.xml
Class BaseQueryCommand

java.lang.Object
  extended byorg.writersforge.catalan.process.workers.BaseMetadataHolder
      extended byorg.writersforge.catalan.process.commands.BaseCommand
          extended byorg.writersforge.catalan.process.workers.xml.BaseQueryCommand
All Implemented Interfaces:
ICommand, IMetadataHolder
Direct Known Subclasses:
XmlCopyCommand, XmlExploderCommand, XmlInlineCommand, XmlInsertCommand, XmlRenameCommand, XmlStyleCommand, XmlTagCommand, XmlToAttributeCommand, XmlToElementCommand, XmlWrapCommand

public abstract class BaseQueryCommand
extends BaseCommand

Shared class for XML commands that select XML content with a "query" property.

Author:
jsheets

Constructor Summary
BaseQueryCommand(java.lang.String name, java.lang.String description)
          Creates a new instance of BaseQueryCommand.
BaseQueryCommand(java.lang.String name, java.lang.String description, PropertyInfo[] required, OptionalPropertyInfo[] optional)
          Creates a new instance of BaseQueryCommand.
 
Method Summary
protected  org.writersforge.bellows.Datum[] getDestinationNodes(org.writersforge.bellows.Datum xml, XmlCommonProperties props)
          Retrieves the XML elements declared in the "dest" property.
protected  org.writersforge.bellows.Datum[] getQueryNodes(org.writersforge.bellows.Datum xml, XmlCommonProperties props)
          Retrieves the XML elements declared in the "query" property.
protected abstract  void processXmlNode(org.writersforge.bellows.Datum root, java.util.List output, XmlCommonProperties props)
          Runs command on a single node of XML content.
 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

BaseQueryCommand

public BaseQueryCommand(java.lang.String name,
                        java.lang.String description)
Creates a new instance of BaseQueryCommand.

Parameters:
name - command name
description - user-friendly command description

BaseQueryCommand

public BaseQueryCommand(java.lang.String name,
                        java.lang.String description,
                        PropertyInfo[] required,
                        OptionalPropertyInfo[] optional)
Creates a new instance of BaseQueryCommand.

Parameters:
name - command name
description - user-friendly command description
required - property info for all required properties
optional - property info for all optional properties
Method Detail

getQueryNodes

protected org.writersforge.bellows.Datum[] getQueryNodes(org.writersforge.bellows.Datum xml,
                                                         XmlCommonProperties props)
Retrieves the XML elements declared in the "query" property.

Parameters:
xml - root XML element
props - runtime properties
Returns:
selected XML elements

getDestinationNodes

protected org.writersforge.bellows.Datum[] getDestinationNodes(org.writersforge.bellows.Datum xml,
                                                               XmlCommonProperties props)
Retrieves the XML elements declared in the "dest" property.

Parameters:
xml - root XML element
props - runtime properties
Returns:
selected XML elements

processXmlNode

protected abstract void processXmlNode(org.writersforge.bellows.Datum root,
                                       java.util.List output,
                                       XmlCommonProperties props)
                                throws ProcessException
Runs command on a single node of XML content. All content to be written back to the queue should be added to the output List.

Parameters:
root - xml root node
output - destination list
props - runtime properties
Throws:
ProcessException - if errors occur while processing XML node

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