public class Runtime
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected Printer |
console
The console printer.
|
protected Printer |
errConsole
The error console printer.
|
protected int |
errors
The error count.
|
protected java.util.Map<java.lang.String,xtc.util.Option> |
externalMap
The map from external names to options.
|
static java.lang.String |
INPUT_DIRECTORY
The internal name for the input directory option.
|
static java.lang.String |
INPUT_ENCODING
The internal name for the intput encoding option.
|
protected java.util.Map<java.lang.String,xtc.util.Option> |
internalMap
The map from internal names to options.
|
protected java.util.List<xtc.util.Option> |
optionList
The list of command line options.
|
protected java.util.Map<java.lang.String,java.lang.Object> |
options
The actual options.
|
static java.lang.String |
OUTPUT_DIRECTORY
The internal name for the output directory option.
|
static java.lang.String |
OUTPUT_ENCODING
The internal name for the output encoding option.
|
protected int |
warnings
The warning count.
|
| Constructor and Description |
|---|
Runtime()
Create a new runtime.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
add(xtc.util.Option option)
Add the specified option.
|
Runtime |
att(java.lang.String external,
java.lang.String internal,
boolean multiple,
java.lang.String description)
Declare an attribute-valued command line option.
|
Runtime |
bool(java.lang.String external,
java.lang.String internal,
boolean value,
java.lang.String description)
Declare a boolean command line option.
|
protected void |
check(xtc.util.Option option,
java.lang.Object value)
Check that the specified value is valid for the specified option.
|
protected void |
check(java.lang.String external,
java.lang.String internal)
Check that no option with the specified names exits.
|
Printer |
console()
Get a printer to the console.
|
Runtime |
dir(java.lang.String external,
java.lang.String internal,
boolean multiple,
java.lang.String description)
Declare a directory-valued command line option.
|
Printer |
errConsole()
Get a printer to the error console.
|
void |
error()
Record an error reported through another means.
|
void |
error(java.lang.String msg)
Print the specified error message.
|
void |
error(java.lang.String msg,
Node n)
Print the specified error message.
|
int |
errorCount()
Get the current error count.
|
void |
exit()
Exit the tool.
|
Runtime |
file(java.lang.String external,
java.lang.String internal,
boolean multiple,
java.lang.String description)
Declare a file-valued command line option.
|
long |
freeMemory()
Get an estimate of free memory.
|
java.util.List<Attribute> |
getAttributeList(java.lang.String name)
Get the attribute list value of the specified option.
|
java.io.File |
getFile(java.lang.String name)
Get the file value of the specified option.
|
java.util.List<java.io.File> |
getFileList(java.lang.String name)
Get the file list value of the specified option.
|
int |
getInt(java.lang.String name)
Get the integer value of the specified option.
|
java.util.List<?> |
getList(java.lang.String name)
Get the list value of the specified option.
|
java.io.File |
getOutputDirectory()
Get this runtime's output directory.
|
java.io.Reader |
getReader(java.io.File file)
Get a reader for the specified file.
|
java.io.Reader |
getReader(java.io.InputStream in)
Get a reader for the specified input stream.
|
java.lang.String |
getString(java.lang.String name)
Get the string value of the specified option.
|
java.lang.Object |
getValue(java.lang.String name)
Get the value of the specified option.
|
java.io.Writer |
getWriter(java.io.File file)
Get a writer for the specified file.
|
java.io.Writer |
getWriter(java.io.OutputStream in)
Get a writer for the specified output stream.
|
boolean |
hasPrefixValue(java.lang.String prefix)
Determine whether any option with the specified prefix has a
value.
|
boolean |
hasValue(java.lang.String name)
Determine whether the specified option has a value.
|
void |
initDefaultValues()
Initialize all options without values to their defaults.
|
void |
initFlags(boolean value)
Initialize all boolean options without values to the specified
value.
|
void |
initFlags(java.lang.String prefix,
boolean value)
Initialize all boolean options with the specified prefix and
without values to the specified value.
|
java.io.File |
locate(java.lang.String path)
Locate the specified file.
|
Runtime |
number(java.lang.String external,
java.lang.String internal,
int value,
java.lang.String description)
Declare an integer-valued command line option.
|
void |
printOptions()
Print a description of all command line options to the console.
|
int |
process(java.lang.String[] args)
Process the specified command line arguments.
|
boolean |
seenError()
Determine whether errors have been reported.
|
void |
setConsole(Printer console)
Update the printer to the console.
|
void |
setErrConsole(Printer console)
Update the printer to the error console.
|
void |
setValue(java.lang.String name,
boolean value)
Set the value of the specified boolean-valued option.
|
void |
setValue(java.lang.String name,
java.lang.Object value)
Set the value of the specified option.
|
boolean |
test(java.lang.String name)
Test the value of the specified boolean option.
|
void |
warning()
Record a warning reported through another means.
|
void |
warning(java.lang.String msg)
Print the specified warning message.
|
void |
warning(java.lang.String msg,
Node n)
Print the specified warning message.
|
Runtime |
word(java.lang.String external,
java.lang.String internal,
boolean multiple,
java.lang.String description)
Declare a word-valued command line option.
|
public static final java.lang.String INPUT_DIRECTORY
public static final java.lang.String OUTPUT_DIRECTORY
public static final java.lang.String INPUT_ENCODING
public static final java.lang.String OUTPUT_ENCODING
protected Printer console
protected Printer errConsole
protected final java.util.List<xtc.util.Option> optionList
protected final java.util.Map<java.lang.String,xtc.util.Option> externalMap
protected final java.util.Map<java.lang.String,xtc.util.Option> internalMap
protected final java.util.Map<java.lang.String,java.lang.Object> options
protected int errors
protected int warnings
public Runtime()
public Printer console()
public void setConsole(Printer console)
console - The new console.public Printer errConsole()
public void setErrConsole(Printer console)
console - The new error console.public long freeMemory()
protected void check(java.lang.String external,
java.lang.String internal)
external - The external name.internal - The internal name.java.lang.IllegalArgumentException - Signals that an option with
the external or interal name already exists.protected void add(xtc.util.Option option)
optionList, externalMap, and internalMap fields.option - The option.public Runtime bool(java.lang.String external, java.lang.String internal, boolean value, java.lang.String description)
external - The external name.internal - The internal name.value - The default value.description - The description.java.lang.IllegalArgumentException - Signals that an option with
the external or interal name already exists.public Runtime word(java.lang.String external, java.lang.String internal, boolean multiple, java.lang.String description)
external - The external name.internal - The internal name.multiple - The flag for multiple occurrences.description - The description.java.lang.IllegalArgumentException - Signals that an option with
the external or interal name already exists.public Runtime number(java.lang.String external, java.lang.String internal, int value, java.lang.String description)
external - The external name.internal - The internal name.value - The default value.description - The description.java.lang.IllegalArgumentException - Signals that an option with
the external or interal name already exists.public Runtime file(java.lang.String external, java.lang.String internal, boolean multiple, java.lang.String description)
external - The external name.internal - The internal name.multiple - The flag for multiple occurrences.description - The description.java.lang.IllegalArgumentException - Signals that an option with
the external or interal name already exists.public Runtime dir(java.lang.String external, java.lang.String internal, boolean multiple, java.lang.String description)
external - The external name.internal - The internal name.multiple - The flag for multiple occurrences.description - The description.java.lang.IllegalArgumentException - Signals that an option with
the external or interal name already exists.public Runtime att(java.lang.String external, java.lang.String internal, boolean multiple, java.lang.String description)
external - The external name.internal - The internal name.multiple - The flag for multiple occurrences.description - The description.java.lang.IllegalArgumentException - Signals that an option with
the external or interal name already exists.public void printOptions()
public int process(java.lang.String[] args)
args - The arguments.public void initDefaultValues()
null if no multiple occurrences are allowed and the
empty list otherwise.public void initFlags(boolean value)
value - The value.public void initFlags(java.lang.String prefix,
boolean value)
prefix - The prefix.value - The value.public boolean hasValue(java.lang.String name)
name - The internal name.true if the option has a value.public boolean hasPrefixValue(java.lang.String prefix)
prefix - The prefix.true if any option with the prefix has a
value.public java.lang.Object getValue(java.lang.String name)
name - The internal name.java.lang.IllegalArgumentException - Signals that the option has no
value.public boolean test(java.lang.String name)
name - The internal name.java.lang.IllegalArgumentException - Signals that the corresponding
option has no value.java.lang.ClassCastException - Signals that the corresponding option
does not have a boolean value.public int getInt(java.lang.String name)
name - The internal name.java.lang.IllegalArgumentException - Signals that the corresponding
option has no value.java.lang.ClassCastException - Signals that the corresponding option
does not have an integer value.public java.lang.String getString(java.lang.String name)
name - The internal name.java.lang.IllegalArgumentException - Signals that the corresponding
option has no value.java.lang.ClassCastException - Signals that the corresponding option
does not have an integer value.public java.io.File getFile(java.lang.String name)
name - The internal name.java.lang.IllegalArgumentException - Signals that the corresponding
option has no value.java.lang.ClassCastException - Signals that the corresponding option
does not have a file value.public java.util.List<?> getList(java.lang.String name)
name - The internal name.java.lang.IllegalArgumentException - Signals that the corresponding
option has no value.java.lang.ClassCastException - Signals that the corresponding option
does not have a list value.public java.util.List<Attribute> getAttributeList(java.lang.String name)
name - The internal name.java.lang.IllegalArgumentException - Signals that the corresponding
option has no value.java.lang.ClassCastException - Signals that the corresponding option
does not have an attribute list value.public java.util.List<java.io.File> getFileList(java.lang.String name)
name - The internal name.java.lang.IllegalArgumentException - Signals that the corresponding
option has no value.java.lang.ClassCastException - Signals that the corresponding option
does not have a file list value.protected void check(xtc.util.Option option,
java.lang.Object value)
option - The option.value - The value.java.lang.IllegalArgumentException - Signals that the value is
invalid.public void setValue(java.lang.String name,
java.lang.Object value)
name - The internal name.value - The value.java.lang.IllegalArgumentException - Signals an unrecognized option
or an invalid value.public void setValue(java.lang.String name,
boolean value)
name - The internal name.value - The value.java.lang.IllegalArgumentException - Signals an unrecognized option
or not a boolean-valued option.public java.io.File locate(java.lang.String path)
throws java.io.FileNotFoundException
path - The (relative) file path.java.io.FileNotFoundException - Signals that the specified file could not be found.INPUT_DIRECTORYpublic java.io.Reader getReader(java.io.File file)
throws java.io.IOException
file - The file.java.io.IOException - Signals an I/O error.INPUT_ENCODINGpublic java.io.Reader getReader(java.io.InputStream in)
throws java.io.UnsupportedEncodingException
in - The input stream.java.io.UnsupportedEncodingException - Signals that this runtime's encoding is not valid.INPUT_ENCODINGpublic java.io.File getOutputDirectory()
OUTPUT_DIRECTORYpublic java.io.Writer getWriter(java.io.File file)
throws java.io.IOException
file - The file.java.io.IOException - Signals an I/O error.OUTPUT_ENCODINGpublic java.io.Writer getWriter(java.io.OutputStream in)
throws java.io.UnsupportedEncodingException
in - The output stream.java.io.UnsupportedEncodingException - Signals that this runtime's encoding is not valid.OUTPUT_ENCODINGpublic boolean seenError()
true if errors have been reported.public int errorCount()
public void error()
public void error(java.lang.String msg)
msg - The error message.public void error(java.lang.String msg,
Node n)
msg - The error message.n - The offending node.public void warning()
public void warning(java.lang.String msg)
msg - The warning message.public void warning(java.lang.String msg,
Node n)
msg - The warning message.n - The offending node.public void exit()
Copyright © 2014. All Rights Reserved.