org.jagatoo.commandline
Class ArgumentsRegistry

java.lang.Object
  extended by org.jagatoo.commandline.ArgumentsRegistry

public class ArgumentsRegistry
extends java.lang.Object

Holds a distinct set of all known and valid arguments of a command line.


Constructor Summary
ArgumentsRegistry(java.lang.String name)
          Creates a new ArgumentsRegistry.
ArgumentsRegistry(java.lang.String name, java.lang.String headLine)
          Creates a new ArgumentsRegistry.
 
Method Summary
 void addArgument(Argument arg)
          Adds a new argument.
 boolean contains(char shortName)
          Checks whether an argument exists with the given short-name.
 boolean contains(java.lang.String longName)
          Checks whether an argument exists with the given long-name.
 void dump()
          Dumps all registered arguments to stdout with a maximum line width of 80.
 void dump(int maxLineWidth)
          Dumps all registered arguments to stdout.
 void dump(int maxLineWidth, java.io.PrintStream out)
          Dumps all registered arguments.
 void dump(java.io.PrintStream out)
          Dumps all registered arguments with a maximum line width of 80.
 Argument getArgument(char shortName)
          Gets the argument corresponding to the given short-name.
 Argument getArgument(java.lang.String longName)
          Gets the argument corresponding to the given long-name.
 java.lang.String getName()
          Gets this registry's name.
 void removeArgument(Argument arg)
          Removes an argument.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArgumentsRegistry

public ArgumentsRegistry(java.lang.String name,
                         java.lang.String headLine)
Creates a new ArgumentsRegistry.

Parameters:
name - the name (used in the dump() method.
headLine - if not null, the name is ignored in the dump() method and this String is dumped first.

ArgumentsRegistry

public ArgumentsRegistry(java.lang.String name)
Creates a new ArgumentsRegistry.

Parameters:
name - the name (used in the dump() method.
Method Detail

getName

public final java.lang.String getName()
Gets this registry's name.

Returns:
the name.

addArgument

public void addArgument(Argument arg)
Adds a new argument.

Parameters:
arg -

removeArgument

public void removeArgument(Argument arg)
Removes an argument.

Parameters:
arg -

contains

public final boolean contains(char shortName)
Checks whether an argument exists with the given short-name.

Parameters:
shortName -
Returns:
true, if it exists.

contains

public final boolean contains(java.lang.String longName)
Checks whether an argument exists with the given long-name.

Parameters:
longName -
Returns:
true, if it exists.

getArgument

public final Argument getArgument(char shortName)
Gets the argument corresponding to the given short-name.

Parameters:
shortName -
Returns:
the corresponding argument.

getArgument

public final Argument getArgument(java.lang.String longName)
Gets the argument corresponding to the given long-name.

Parameters:
longName -
Returns:
the corresponding argument.

dump

public void dump(int maxLineWidth,
                 java.io.PrintStream out)
Dumps all registered arguments.

Parameters:
maxLineWidth -

dump

public final void dump(int maxLineWidth)
Dumps all registered arguments to stdout.

Parameters:
maxLineWidth -

dump

public final void dump(java.io.PrintStream out)
Dumps all registered arguments with a maximum line width of 80.

Parameters:
out -

dump

public final void dump()
Dumps all registered arguments to stdout with a maximum line width of 80.