org.apache.avalon.excalibur.cli
Class CLArgsParser
java.lang.Object
|
+--org.apache.avalon.excalibur.cli.CLArgsParser
- public final class CLArgsParser
- extends java.lang.Object
Parser for command line arguments.
This parses command lines according to the standard (?) of
gnu utilities.
Note: This is still used in 1.1 libraries so do not add 1.2+ dependancies.
- Author:
- Peter Donald
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TOKEN_SEPERATOR
protected static final int TOKEN_SEPERATOR
TOKEN_STRING
protected static final int TOKEN_STRING
ARG2_SEPERATORS
protected static final char[] ARG2_SEPERATORS
ARG_SEPERATORS
protected static final char[] ARG_SEPERATORS
NULL_SEPERATORS
protected static final char[] NULL_SEPERATORS
m_optionDescriptors
protected final CLOptionDescriptor[] m_optionDescriptors
m_options
protected final java.util.Vector m_options
m_control
protected final ParserControl m_control
m_errorMessage
protected java.lang.String m_errorMessage
m_unparsedArgs
protected java.lang.String[] m_unparsedArgs
ch
protected char ch
args
protected java.lang.String[] args
isLong
protected boolean isLong
argIndex
protected int argIndex
stringIndex
protected int stringIndex
stringLength
protected int stringLength
INVALID
protected static final int INVALID
m_lastChar
protected int m_lastChar
m_lastOptionId
protected int m_lastOptionId
m_option
protected CLOption m_option
m_state
protected int m_state
CLArgsParser
public CLArgsParser(java.lang.String[] args,
CLOptionDescriptor[] optionDescriptors,
ParserControl control)
- Create a parser that can deals with options and parses certain args.
- Parameters:
args[]
- the argsoptionDescriptors[]
- the option descriptors
CLArgsParser
public CLArgsParser(java.lang.String[] args,
CLOptionDescriptor[] optionDescriptors)
- Create a parser that can deals with options and parses certain args.
- Parameters:
args[]
- the argsoptionDescriptors[]
- the option descriptors
getUnparsedArgs
public java.lang.String[] getUnparsedArgs()
getArguments
public java.util.Vector getArguments()
- Retrieve a list of options that were parsed from command list.
- Returns:
- the list of options
getErrorString
public java.lang.String getErrorString()
- Retrieve an error message that occured during parsing if one existed.
- Returns:
- the error string
checkIncompatabilities
protected void checkIncompatabilities(java.util.Vector arguments)
throws java.text.ParseException
- Check for duplicates of an option.
It is an error to have duplicates unless appropriate flags is set in descriptor.
- Parameters:
arguments
- the arguments
checkIncompatable
protected void checkIncompatable(java.util.Vector arguments,
int[] incompatable,
int original)
throws java.text.ParseException
describeDualOption
protected java.lang.String describeDualOption(int id)
subArray
protected java.lang.String[] subArray(java.lang.String[] array,
int index,
int charIndex)
- Create a string array that is subset of input array.
The sub-array should start at array entry indicated by index. That array element
should only include characters from charIndex onwards.
- Parameters:
array[]
- the original arrayindex
- the cut-point in arraycharIndex
- the cut-point in element of array- Returns:
- the result array
parse
protected void parse()
throws java.text.ParseException
- Actually parse arguments
- Parameters:
args[]
- arguments
getOptionDescription
protected final java.lang.String getOptionDescription(CLOptionDescriptor descriptor)
peekAtChar
protected final char peekAtChar()
getChar
protected final char getChar()
nextToken
protected final CLArgsParser.Token nextToken(char[] seperators)
addOption
protected void addOption(CLOption option)
parseOption
protected void parseOption(CLOptionDescriptor descriptor,
java.lang.String optionString)
throws java.text.ParseException
parseShortOption
protected void parseShortOption()
throws java.text.ParseException
parseArguments
protected boolean parseArguments()
throws java.text.ParseException
parseNormal
protected void parseNormal()
throws java.text.ParseException
- Parse Options from Normal mode.
Copyright © 2001 Apache Jakarta Project. All Rights Reserved.