things.common.commands
Class CommandLineProcessor

java.lang.Object
  extended by things.common.commands.CommandLineProcessor

public class CommandLineProcessor
extends java.lang.Object

A fancy command line processor. The rules are: There are values, options, and entities.

Entities are numbered by position and accessible from an ArrayList by number.

Values are not numbered, but are available in the entity map. Values differ from entities in that they have an exposed (not escaped or quoted) = (equal) sign. They are split into name/value pairs. If an = precedes or suffixes the term, it'll assume it is a name only-the value will be the same as the name. VALUES ARE NOT CASE SENSITIVE and the names are stored as LOWER CASE.

Options are one or more character flags preceded by a single dash. They are stored in their own map.

Quotes can enclose terms. Accent '`' (ASCII #96) is the escape. Double accent will escape itself. Carot (^) enclosed terms will be resolved against the property view. Backslash is the escape. Double backslash will escape itself.

Version:
1.0

Version History

EPG - Initial - 5 JUN 07
 
Author:
Erich P. Gatejen

Field Summary
static int ESCAPE_CHARACTER
          This is the escape character.
static int MAX_CHARACTER
          This is the largest (by value) character recognized.
static int NORMAL_CHARACTER
          A NORMAL_CHARCTER.
static int OPTION_CHARACTER
          This is the option character.
static int PROPERTY_CHARACTER
          This is the property character.
 
Constructor Summary
CommandLineProcessor()
           
 
Method Summary
 CommandLine process(java.io.Reader target, ThingsPropertyView properties)
          Process a command line.
 CommandLine process(java.lang.String[] target, ThingsPropertyView properties)
          Process a command line.
static CommandLine processStatic(java.io.Reader target, ThingsPropertyView properties)
          Process a command line.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_CHARACTER

public static final int PROPERTY_CHARACTER
This is the property character.

See Also:
Constant Field Values

ESCAPE_CHARACTER

public static final int ESCAPE_CHARACTER
This is the escape character.

See Also:
Constant Field Values

OPTION_CHARACTER

public static final int OPTION_CHARACTER
This is the option character.

See Also:
Constant Field Values

MAX_CHARACTER

public static final int MAX_CHARACTER
This is the largest (by value) character recognized. Anything else will be viewed as a NORMAL_CHARACTER during processing. This should not cause any problems for other character sets (as long as the functionally significant characters are the same--such as the carot).

See Also:
Constant Field Values

NORMAL_CHARACTER

public static final int NORMAL_CHARACTER
A NORMAL_CHARCTER. This really doesn't effect output.

See Also:
Constant Field Values
Constructor Detail

CommandLineProcessor

public CommandLineProcessor()
Method Detail

processStatic

public static CommandLine processStatic(java.io.Reader target,
                                        ThingsPropertyView properties)
                                 throws ThingsException
Process a command line. It'll process any 7-bit ASCII ok. It'll ignore all other characters. You should avoid the first character being a 0 byte (the value 0, not the character 0). This is a static method that will create an engine as needed. If you plan on doing this often, instantiate one yourself and use process() instead.

Parameters:
target - A Reader source.
properties - Properties for replacements.
Returns:
A CommandLine object
Throws:
ThingsException
See Also:
CommandLine

process

public CommandLine process(java.io.Reader target,
                           ThingsPropertyView properties)
                    throws ThingsException
Process a command line. It'll process any 7-bit ASCII ok. It'll ignore all other characters. You should avoid the first character being a 0 byte (the value 0, not the character 0). This is a static method that will create an engine as needed. If you plan on doing this often, instantiate one yourself and use process() instead.

Parameters:
target - A Reader source.
properties - Properties for replacements.
Returns:
A CommandLine opbject
Throws:
ThingsException
See Also:
CommandLine

process

public CommandLine process(java.lang.String[] target,
                           ThingsPropertyView properties)
                    throws ThingsException
Process a command line. It'll process any 7-bit ASCII ok. It'll ignore all other characters. You should avoid the first character being a 0 byte (the value 0, not the character 0). This is a static method that will create an engine as needed. If you plan on doing this often, instantiate one yourself and use process() instead.

Parameters:
target - As an array of strings.
properties - Properties for replacements.
Returns:
A CommandLine opbject
Throws:
ThingsException
See Also:
CommandLine


Things.