com.sun.enterprise.admin.cli
Class Parser

java.lang.Object
  extended by com.sun.enterprise.admin.cli.Parser

public class Parser
extends Object

The Parser object is used to parse the command line and verify that the command line is CLIP compliant.


Field Summary
private  boolean ignoreUnknown
           
private  List<String> operands
           
private  Collection<CommandModel.ParamModel> options
           
private  ParameterMap optionsMap
           
private static LocalStringsImpl strings
           
 
Constructor Summary
Parser(String[] args, int start, Collection<CommandModel.ParamModel> options, boolean ignoreUnknown)
          Parse the given command line arguments
 
Method Summary
 List<String> getOperands()
          Returns the list of operands.
 ParameterMap getOptions()
          Returns a Map with all the options.
private  CommandModel.ParamModel lookupLongOption(String s)
          Get ParamModel for long option name.
private  CommandModel.ParamModel lookupShortOption(char c)
          Get ParamModel for short option name.
private static boolean optionRequiresOperand(CommandModel.ParamModel opt)
          Does this option require an operand?
private  void parseCommandLine(String[] argv, int start)
          Parse the command line arguments according to CLIP.
private  void setOption(CommandModel.ParamModel opt, String value)
          Set the value for the option.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

optionsMap

private ParameterMap optionsMap

operands

private List<String> operands

options

private Collection<CommandModel.ParamModel> options

ignoreUnknown

private boolean ignoreUnknown

strings

private static final LocalStringsImpl strings
Constructor Detail

Parser

public Parser(String[] args,
              int start,
              Collection<CommandModel.ParamModel> options,
              boolean ignoreUnknown)
       throws CommandValidationException
Parse the given command line arguments

Parameters:
args - command line arguments
start - index in args to start parsing
options - the valid options to consider while parsing
ignoreUnknown - if true, unknown options are considered operands instead of generating an exception
Throws:
CommandValidationException - if command line parsing fails
Method Detail

parseCommandLine

private void parseCommandLine(String[] argv,
                              int start)
                       throws CommandValidationException
Parse the command line arguments according to CLIP.

Parameters:
argv - command line arguments
Throws:
CommandValidationException - if command line is invalid

getOptions

public ParameterMap getOptions()
Returns a Map with all the options. The Map is indexed by the long name of the option.

Returns:
options

getOperands

public List<String> getOperands()
Returns the list of operands.

Returns:
list of operands

toString

public String toString()
Overrides:
toString in class Object

lookupLongOption

private CommandModel.ParamModel lookupLongOption(String s)
Get ParamModel for long option name.


lookupShortOption

private CommandModel.ParamModel lookupShortOption(char c)
Get ParamModel for short option name.


optionRequiresOperand

private static boolean optionRequiresOperand(CommandModel.ParamModel opt)
Does this option require an operand?


setOption

private void setOption(CommandModel.ParamModel opt,
                       String value)
                throws CommandValidationException
Set the value for the option.

Throws:
CommandValidationException


Copyright © 2012 GlassFish Community. All Rights Reserved.