|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.actf.util.command.CLSwitch
public class CLSwitch
The CLSwitch class is used in conjuction with the CLArgumentProcessor to embody a
single command line switch. An implementation of IArgumentResolver
should be associated with any CLSwitch
.
CLArgumentProcessor
Constructor Summary | |
---|---|
CLSwitch(String name,
String desc,
Class type)
create a command line switch with the given name and type. |
|
CLSwitch(String name,
String desc,
Class type,
boolean required)
create a command line switch with the given name and type. |
|
CLSwitch(String name,
String desc,
Class type,
boolean required,
IArgumentResolver resolver)
create a command line switch with the given name and type. |
|
CLSwitch(String name,
String desc,
IArgumentResolver resolver)
create a command line switch with the given name and type. |
Method Summary | |
---|---|
IArgumentResolver |
getArgumentResolver()
|
String |
getDefaultValue()
|
String |
getDescription()
|
int |
getExpectedNumberOfArgs()
|
String |
getFullSwitchName()
returns the full switch name which is composed of its prefix followed by its name. |
String |
getName()
|
String |
getPrefix()
|
Object |
getResolvedValue()
returns the resolved value of the argument passed to the switch. |
String |
getValue()
returns the unresolved value or argument passed to the switch on the command line. |
Class |
getValueType()
returns the desired type of the value or agument corresponding to the swithh. |
boolean |
isRequired()
|
Object |
resolveValue(String arg)
resolve the value passed from the command line. |
void |
setArgumentResolver(IArgumentResolver resolver)
|
void |
setDefaultValue(String value)
|
void |
setDescription(String description)
|
void |
setExpectedNumberOfArgs(int args)
set the number of arguments expected by this switch. |
void |
setName(String name)
set the name of the switch. |
void |
setPrefix(String prefix)
set the command line switch's prefix. |
void |
setRequired(boolean required)
set to true if the switch and its corresponding value are required
for the application. |
void |
setToDefaultValue()
set the switch to its default value |
void |
setValue(String value)
|
void |
setValueType(Class type)
set the type of the value or argument to this switch. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CLSwitch(String name, String desc, Class type)
name
- -switch name (denoted with a hypthen (-) on the command line)desc
- - switch description or usagetype
- - type of resolved valuepublic CLSwitch(String name, String desc, IArgumentResolver resolver)
name
- -switch namedesc
- - switch description or usageresolver
- - argument resolverpublic CLSwitch(String name, String desc, Class type, boolean required)
org.eclipse.actf.util.command.DefaultArgumentResolver
is used to resolve switch values.
name
- -switch namedesc
- - switch description or usagetype
- - type of resolved valuerequired
- - whether or not this switch is required on the command lineDefaultArgumentResolver
public CLSwitch(String name, String desc, Class type, boolean required, IArgumentResolver resolver)
Resolver
interface.
name
- -switch namedesc
- - switch description or usagetype
- - type of resolved valuerequired
- - whether or not this switch is required on the command lineresolver
- - argument resolverMethod Detail |
---|
public String getName()
public void setName(String name)
name
- - The switch namepublic String getPrefix()
public void setPrefix(String prefix)
prefix
- - prefix for switchpublic String getFullSwitchName()
public String getDescription()
public void setDescription(String description)
description
- the help or description of the switch (appears in the usage message)public int getExpectedNumberOfArgs()
setExpectedNumberOfArgs(int)
public void setExpectedNumberOfArgs(int args)
main(String[])
method will be used for this switch. Supplying fewer than the number of expected
number of arguments on the command line is acceptable and additional arguments beyond the number of expected arguments
will be flagged.
args
- - expected number of arguments (default is 1)public boolean isRequired()
public void setRequired(boolean required)
true
if the switch and its corresponding value are required
for the application.
required
- true
if the switch is required, false
otherwisepublic Class getValueType()
IArgumentResolver is responsible for resolving the value or argument to this type.
- Returns:
- Returns the type of the value/argument of the switch
public void setValueType(Class type)
type
- the type to which the argument to this switch is to be resolvedgetValueType()
public String getValue()
public void setValue(String value)
value
- The argument or value given to the switch on the command linepublic Object resolveValue(String arg) throws Exception
arg
- - command line argument for this switch
Exception
public String getDefaultValue()
public void setDefaultValue(String value)
value
- The default value for this switch if no value is givenpublic void setToDefaultValue()
public Object getResolvedValue()
setType(Class)
method.
public IArgumentResolver getArgumentResolver()
public void setArgumentResolver(IArgumentResolver resolver)
resolver
- the argument resolved to be used
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |