|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectlapis.Arguments
Nested Class Summary | |
protected static class |
Arguments.Name
Parameter name. |
static class |
Arguments.UsageException
Exception thrown when argument processing encounters an error. |
Field Summary | |
protected Vector |
argv
Argument list. |
protected int |
currArg
Index of current argument (returned by getElement()). |
static Debug |
debug
|
protected Document |
input
|
protected Interpreter |
interpreter
|
protected Object[] |
originalArgs
|
protected DocumentWriter |
output
|
protected String |
usageMessage
|
Constructor Summary | |
Arguments(Interpreter interpreter)
Make an empty Arguments object. |
Method Summary | |
Arguments |
add(String name,
Object value)
Add a name/value pair to the argument sequence. |
Arguments |
addArguments(Arguments args)
Concatenates another argument sequence to the argument sequence, consuming the other sequence entirely. |
Arguments |
addName(String name)
Add a parameter name to the argument sequence. |
Arguments |
addValue(Object arg)
Add a parameter value to the argument sequence. |
void |
consume(String name)
Handle a parameter common to all LAPIS tools. |
protected String |
getContextMessage()
Get a representation of the command line with the current argument position marked in it, to be printed with the usage message. |
Object |
getElement()
Get current argument (either name or value). |
DocumentFactory |
getFactory()
|
Document |
getInput()
Get input document specified by arguments. |
Interpreter |
getInterpreter()
|
Object[] |
getOriginalArguments()
|
DocumentWriter |
getOutput()
Get output stream specified by arguments. |
String |
getUsage()
Get usage message printed when an erroneous argument is found. |
boolean |
hasMoreElements()
Test whether argument enumeration is exhausted. |
boolean |
isName()
Test whether current argument is a name or a value. |
Object |
nextElement()
Get argument (either name or value) and advance to next argument. |
int |
nextInt()
Get next argument as an integer. |
String |
nextName()
Try to get argument as a parameter name and advance to next argument if successful. |
TC |
nextPattern()
Get next argument as a TC pattern. |
String |
nextString()
Get next argument as a String. |
Object |
nextValue()
Try to get argument as a parameter value and advance to next argument if successful. |
Arguments |
setInput(Document doc)
Set input document. |
Arguments |
setInput(Object obj)
Set input document. |
Arguments |
setOutput(DocumentWriter out)
Set output document. |
void |
setUsage(String message)
Set usage message printed when an erroneous argument is found. |
void |
usage()
Fire a UsageException containing the usage message set by setUsage(). |
void |
usage(String message)
Fire a UsageException containing the given message. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static Debug debug
protected Vector argv
protected int currArg
protected Object[] originalArgs
protected Interpreter interpreter
protected Document input
protected DocumentWriter output
protected String usageMessage
Constructor Detail |
public Arguments(Interpreter interpreter)
Method Detail |
public Arguments add(String name, Object value)
name
- Parameter name (may be null)value
- Parameter value (may be null)
public Arguments addName(String name)
public Arguments addValue(Object arg)
arg
- Parameter value
public Arguments addArguments(Arguments args)
args
- Arguments to add
public boolean hasMoreElements()
hasMoreElements
in interface Enumeration
public Object getElement()
Arguments.UsageException
- if no more argumentspublic boolean isName()
Arguments.UsageException
- if no more argumentspublic Object nextElement()
nextElement
in interface Enumeration
Arguments.UsageException
- if no more argumentspublic String nextName()
public Object nextValue()
public String nextString() throws Arguments.UsageException
Arguments.UsageException
- if next argument is a parameter name, not
a valuepublic int nextInt() throws Arguments.UsageException, NumberFormatException
Arguments.UsageException
- if next argument is a parameter name, not
a value
NumberFormatException
- if argument isn't an integerpublic TC nextPattern() throws Arguments.UsageException, TCParseException
Arguments.UsageException
- if next argument is a parameter name, not
a value, or if it's the wrong type
TCParseException
- if argument isn't understood
be loadedpublic void consume(String name) throws Exception
name
- Parameter name returned by nextName(). No
other nextX() call should have been made since the call to nextName().
Arguments.UsageException
- if not a common parameter
Exception
- if some other exception occurs in processing
the parameter.public Object[] getOriginalArguments()
public Document getInput()
Call after processing all arguments (and calling consume() on arguments that the tool doesn't want to handle).
public Arguments setInput(Document doc)
doc
- Input document
public Arguments setInput(Object obj) throws IOException
obj
- Object to convert to an input document
IOException
public DocumentWriter getOutput()
public Arguments setOutput(DocumentWriter out)
public Interpreter getInterpreter()
public DocumentFactory getFactory()
public String getUsage()
public void setUsage(String message)
public void usage()
Arguments.UsageException
- thrown alwayspublic void usage(String message)
message
- Usage message to include in thrown UsageException
Arguments.UsageException
- thrown alwaysprotected String getContextMessage()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |