org.umber.catalan.process.workers.text
Class BaseTextCommand

java.lang.Object
  extended byorg.umber.catalan.process.workers.BaseMetadataHolder
      extended byorg.umber.catalan.process.commands.BaseCommand
          extended byorg.umber.catalan.process.workers.text.BaseTextCommand
All Implemented Interfaces:
ICommand, IMetadataHolder
Direct Known Subclasses:
ChangeCaseCommand, ConcatenateCommand, ExtractCommand, FromAsciiCommand, MatchBracesCommand, NormalizeCommand, ReplaceCommand, ResolveCommand, SplitCommand, StripCommentsCommand, TextToXmlCommand, ToAsciiCommand, TokenizeCommand

public abstract class BaseTextCommand
extends BaseCommand

Common base class for text commands, for sharing common methods.

Author:
jsheets

Constructor Summary
BaseTextCommand(java.lang.String name, java.lang.String description)
          Creates a new instance of BaseTextCommand.
BaseTextCommand(java.lang.String name, java.lang.String description, PropertyInfo[] required, OptionalPropertyInfo[] optional)
          Creates a new instance of BaseTextCommand.
 
Method Summary
protected  java.lang.String[] convertToArray(java.util.List nodes)
          Loads String versions of all given nodes into a String array.
protected  java.lang.String extractText(java.lang.Object node)
          Extracts the text content from arbitrary node formats.
protected  java.lang.Object storeText(java.lang.Object node, java.lang.String text)
          Assigns the text to the node.
 
Methods inherited from class org.umber.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.umber.catalan.process.commands.ICommand
run
 
Methods inherited from interface org.umber.catalan.process.workers.IMetadataHolder
getMetadata, validateProperties, validateType
 

Constructor Detail

BaseTextCommand

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

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

BaseTextCommand

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

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

extractText

protected java.lang.String extractText(java.lang.Object node)
Extracts the text content from arbitrary node formats. Pulls PCDATA from XML nodes and converts unrecognized nodes with toString().

Parameters:
node - object to extract text from
Returns:
text form of node

storeText

protected java.lang.Object storeText(java.lang.Object node,
                                     java.lang.String text)
Assigns the text to the node. Usually just passes text through, but in the case of an XML node, sets the text as PCDATA content.

Parameters:
node - original target node
text - text content to store
Returns:
the node with text stored

convertToArray

protected java.lang.String[] convertToArray(java.util.List nodes)
Loads String versions of all given nodes into a String array.

Parameters:
nodes - input nodes
Returns:
array of nodes converted to Strings