|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectuk.ac.starlink.task.LineEnvironment
public class LineEnvironment
Execution environment for use from the command line.
Arguments are supplied as LineWord
objects.
Field Summary | |
---|---|
static char |
INDIRECTION_CHAR
|
static int |
NUM_TRIES
|
Constructor Summary | |
---|---|
LineEnvironment()
Constructs a LineEnvironment without any additional initialisation. |
|
LineEnvironment(String[] args,
Parameter[] params)
Constructs a new LineEnvironment, initialising it with a set of command line arguments. |
Method Summary | |
---|---|
void |
acquireValue(Parameter param)
Obtains a legal value for a given parameter from the environment and sets the parameter's value accordingly. |
void |
checkParameters(Parameter[] params)
Checks that this environment's values are compatible with the given list of parameters. |
void |
clearValue(Parameter par)
Clears a value for a given parameter. |
String[] |
getAssignments()
Returns an array of strings, one for each parameter assignment which was actually used (via acquireValue(uk.ac.starlink.task.Parameter) )
for this environment. |
PrintStream |
getErrorStream()
Returns an output stream into which error or logging output from a task can be written. |
boolean |
getInteractive()
Determines whether we are running interactively. |
String[] |
getNames()
Returns an array of parameter names which have been specified. |
PrintStream |
getOutputStream()
Returns an output stream into which text output from a task can be written. |
String |
getParamHelp(Parameter param)
Returns the help string for a given parameter. |
boolean |
getPromptAll()
Determines whether all parameters which haven't received explicit values on the command line should be prompted for. |
String[] |
getUnused()
Returns a string containing any words of the input argument list which were never queried by the application to find their value. |
boolean |
isHidden(Parameter param)
Determines whether a parameter is "hidden", that is its value should not be revealed to prying eyes. |
boolean |
paramNameMatches(String envName,
Parameter param)
Indicates whether a parameter name supplied from the environment is a reference to a given parameter. |
void |
setErrorStream(PrintStream err)
Sets the destination stream for standard error. |
void |
setInteractive(boolean interactive)
Sets whether we are running interactively or not. |
void |
setOutputStream(PrintStream out)
Sets the destination stream for standard out. |
void |
setPromptAll(boolean prompt)
Sets whether all parameters which haven't received explicit values on the command line should be prompted for. |
void |
setWords(LineWord[] words)
Sets the words supplying the parameter values for this environment. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final char INDIRECTION_CHAR
public static final int NUM_TRIES
Constructor Detail |
---|
public LineEnvironment()
setWords(uk.ac.starlink.task.LineWord[])
must be made before
it is interrogated for values.
public LineEnvironment(String[] args, Parameter[] params) throws UsageException
name=value
, or
just value
for positional arguments.
If any of these refer to parameters not in the params
list, an exception will be thrown.
args
- command-line argumentsparams
- parameters that args
provide values for
UsageException
Method Detail |
---|
public void setWords(LineWord[] words)
words
- list of wordspublic String getParamHelp(Parameter param)
param
- parameter
param
public boolean isHidden(Parameter param)
param
- param
public void checkParameters(Parameter[] params) throws UsageException
params
- parameter list
UsageException
public String[] getNames()
Environment
getNames
in interface Environment
public void setInteractive(boolean interactive)
interactive
- whether we are running interactivelypublic boolean getInteractive()
public void setPromptAll(boolean prompt)
prompt
- whether to prompt for everythingpublic boolean getPromptAll()
public void clearValue(Parameter par)
Environment
clearValue
in interface Environment
par
- the Parameter whose value is to be clearedpublic void setOutputStream(PrintStream out)
out
- output streampublic void setErrorStream(PrintStream err)
err
- error streampublic PrintStream getOutputStream()
Environment
getOutputStream
in interface Environment
public PrintStream getErrorStream()
Environment
getErrorStream
in interface Environment
public void acquireValue(Parameter param) throws TaskException
Environment
This environment should obtain a value for the parameter par
in whatever way it sees fit, and must then call par's
Parameter.setValueFromString(uk.ac.starlink.task.Environment, java.lang.String)
method so that the parameter
knows what its new value is. If the setValueFromString call
throws a ParameterValueException the environment may
try to get another value (for instance by re-prompting the user)
or may give up and re-throw the exception.
acquireValue
in interface Environment
param
- the Parameter whose value is to be obtained and set
TaskException
public String[] getUnused()
public String[] getAssignments()
acquireValue(uk.ac.starlink.task.Parameter)
)
for this environment.
public boolean paramNameMatches(String envName, Parameter param)
The implementation in the LineEnvironment
class
performs case-insensitive matching against the
param.getName()
. This behaviour may be overridden
by subclasses to change the environment's behaviour.
envName
- parameter name from environmentparam
- parameter
envName
is considered to name
param
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |