org.opends.server.util.args
Class SubCommand

java.lang.Object
  extended by org.opends.server.util.args.SubCommand

public class SubCommand
extends java.lang.Object

This class defines a data structure for holding information about a subcommand that may be used with the subcommand argument parser. The subcommand has a name, a description, and a set of arguments.


Constructor Summary
SubCommand(SubCommandArgumentParser parser, java.lang.String name, boolean allowsTrailingArguments, int minTrailingArguments, int maxTrailingArguments, java.lang.String trailingArgsDisplayName, Message description)
          Creates a new subcommand with the provided information.
SubCommand(SubCommandArgumentParser parser, java.lang.String name, Message description)
          Creates a new subcommand with the provided information.
 
Method Summary
 void addArgument(Argument argument)
          Adds the provided argument for use with this subcommand.
 boolean allowsTrailingArguments()
          Indicates whether this sub-command will allow unnamed trailing arguments.
 Argument getArgument(java.lang.Character shortID)
          Retrieves the subcommand argument with the specified short identifier.
 Argument getArgument(java.lang.String longID)
          Retrieves the subcommand argument with the specified long identifier.
 Argument getArgumentForName(java.lang.String name)
          Retrieves the subcommand argument with the specified name.
 java.util.LinkedList<Argument> getArguments()
          Retrieves the set of arguments for this subcommand.
 Message getDescription()
          Retrieves the description for this subcommand.
 int getMaxTrailingArguments()
          Retrieves the maximum number of unnamed trailing arguments that may be provided.
 int getMinTrailingArguments()
          Retrieves the minimum number of unnamed trailing arguments that must be provided.
 java.lang.String getName()
          Retrieves the name of this subcommand.
 java.util.ArrayList<java.lang.String> getTrailingArguments()
          Retrieves the set of unnamed trailing arguments that were provided on the command line.
 java.lang.String getTrailingArgumentsDisplayName()
          Retrieves the trailing arguments display name.
 boolean isHidden()
          Indicates whether this subcommand should be hidden from the usage information.
 void setHidden(boolean isHidden)
          Specifies whether this subcommand should be hidden from the usage information.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SubCommand

public SubCommand(SubCommandArgumentParser parser,
                  java.lang.String name,
                  Message description)
           throws ArgumentException
Creates a new subcommand with the provided information. The subcommand will be automatically registered with the associated parser.

Parameters:
parser - The argument parser with which this subcommand is associated.
name - The name of this subcommand.
description - The description of this subcommand.
Throws:
ArgumentException - If the associated argument parser already has a subcommand with the same name.

SubCommand

public SubCommand(SubCommandArgumentParser parser,
                  java.lang.String name,
                  boolean allowsTrailingArguments,
                  int minTrailingArguments,
                  int maxTrailingArguments,
                  java.lang.String trailingArgsDisplayName,
                  Message description)
           throws ArgumentException
Creates a new subcommand with the provided information. The subcommand will be automatically registered with the associated parser.

Parameters:
parser - The argument parser with which this subcommand is associated.
name - The name of this subcommand.
allowsTrailingArguments - Indicates whether this parser allows unnamed trailing arguments to be provided.
minTrailingArguments - The minimum number of unnamed trailing arguments that must be provided. A value less than or equal to zero indicates that no minimum will be enforced.
maxTrailingArguments - The maximum number of unnamed trailing arguments that may be provided. A value less than or equal to zero indicates that no maximum will be enforced.
trailingArgsDisplayName - The display name that should be used as a placeholder for unnamed trailing arguments in the generated usage information.
description - The description of this subcommand.
Throws:
ArgumentException - If the associated argument parser already has a subcommand with the same name.
Method Detail

getName

public java.lang.String getName()
Retrieves the name of this subcommand.

Returns:
The name of this subcommand.

getDescription

public Message getDescription()
Retrieves the description for this subcommand.

Returns:
The description for this subcommand.

getArguments

public java.util.LinkedList<Argument> getArguments()
Retrieves the set of arguments for this subcommand.

Returns:
The set of arguments for this subcommand.

getArgument

public Argument getArgument(java.lang.Character shortID)
Retrieves the subcommand argument with the specified short identifier.

Parameters:
shortID - The short identifier of the argument to retrieve.
Returns:
The subcommand argument with the specified short identifier, or null if there is none.

getArgument

public Argument getArgument(java.lang.String longID)
Retrieves the subcommand argument with the specified long identifier.

Parameters:
longID - The long identifier of the argument to retrieve.
Returns:
The subcommand argument with the specified long identifier, or null if there is none.

getArgumentForName

public Argument getArgumentForName(java.lang.String name)
Retrieves the subcommand argument with the specified name.

Parameters:
name - The name of the argument to retrieve.
Returns:
The subcommand argument with the specified name, or null if there is no such argument.

addArgument

public void addArgument(Argument argument)
                 throws ArgumentException
Adds the provided argument for use with this subcommand.

Parameters:
argument - The argument to add for use with this subcommand.
Throws:
ArgumentException - If either the short ID or long ID for the argument conflicts with that of another argument already associated with this subcommand.

allowsTrailingArguments

public boolean allowsTrailingArguments()
Indicates whether this sub-command will allow unnamed trailing arguments. These will be arguments at the end of the list that are not preceded by either a long or short identifier and will need to be manually parsed by the application using this parser. Note that once an unnamed trailing argument has been identified, all remaining arguments will be classified as such.

Returns:
true if this sub-command allows unnamed trailing arguments, or false if it does not.

getMinTrailingArguments

public int getMinTrailingArguments()
Retrieves the minimum number of unnamed trailing arguments that must be provided.

Returns:
The minimum number of unnamed trailing arguments that must be provided, or a value less than or equal to zero if no minimum will be enforced.

getMaxTrailingArguments

public int getMaxTrailingArguments()
Retrieves the maximum number of unnamed trailing arguments that may be provided.

Returns:
The maximum number of unnamed trailing arguments that may be provided, or a value less than or equal to zero if no maximum will be enforced.

getTrailingArgumentsDisplayName

public java.lang.String getTrailingArgumentsDisplayName()
Retrieves the trailing arguments display name.

Returns:
Returns the trailing arguments display name.

getTrailingArguments

public java.util.ArrayList<java.lang.String> getTrailingArguments()
Retrieves the set of unnamed trailing arguments that were provided on the command line.

Returns:
The set of unnamed trailing arguments that were provided on the command line.

isHidden

public boolean isHidden()
Indicates whether this subcommand should be hidden from the usage information.

Returns:
true if this subcommand should be hidden from the usage information, or false if not.

setHidden

public void setHidden(boolean isHidden)
Specifies whether this subcommand should be hidden from the usage information.

Parameters:
isHidden - Indicates whether this subcommand should be hidden from the usage information.