edu.toronto.cs.util
Class Clapi.Opt

java.lang.Object
  extended by edu.toronto.cs.util.Clapi.Opt
Direct Known Subclasses:
Clapi.BooleanOpt, Clapi.HelpOpt, Clapi.IntOpt, Clapi.StringOpt
Enclosing class:
Clapi

public abstract static class Clapi.Opt
extends java.lang.Object

Represents a command-line option.

This is the main deal: users of Clapi create instances of Opt subclasses, and ask the parser to parse. The subclasses of Opt are responsible for parsing their arguments and constructing the result data structure.


Constructor Summary
Clapi.Opt(Clapi.OptSpec _spec)
           
 
Method Summary
protected  void checkArity(Clapi.OptResult result)
           
 java.lang.Object get(Clapi.OptResult result)
           
abstract  Clapi.ArgumentParser getArgumentParser()
           
 java.lang.String getArgumentsSpec()
           
 java.util.List getList(Clapi.OptResult result)
           
 java.lang.Object[] getObjectArray(Clapi.OptResult result)
           
 java.util.List getOptionSpecifiers()
          Returns a list of strings containing human-readable descriptions of all the forms of this option.
 Clapi.OptSpec getSpec()
           
protected  java.lang.String getToken(edu.toronto.cs.util.Clapi.TokenStream in)
          Grab the given token.
 boolean isTerminal()
           
protected  void parseArguments(edu.toronto.cs.util.Clapi.TokenStream in, Clapi.OptResult optResult)
          Parses the arguments for this option, adding them to the OptResult data structure passed in.
 void printArgumentsSpec(java.io.PrintWriter out)
           
 java.lang.String tag()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Clapi.Opt

public Clapi.Opt(Clapi.OptSpec _spec)
Method Detail

isTerminal

public boolean isTerminal()

getSpec

public Clapi.OptSpec getSpec()

getArgumentParser

public abstract Clapi.ArgumentParser getArgumentParser()

parseArguments

protected void parseArguments(edu.toronto.cs.util.Clapi.TokenStream in,
                              Clapi.OptResult optResult)
                       throws Clapi.OptParseException

Parses the arguments for this option, adding them to the OptResult data structure passed in.

Consumes tokens from the input stream.

Throws:
Clapi.OptParseException

getToken

protected java.lang.String getToken(edu.toronto.cs.util.Clapi.TokenStream in)
                             throws Clapi.OptParseException
Grab the given token. If the token specified is outside of the token stream, throw a parse exception.

Throws:
Clapi.OptParseException

checkArity

protected void checkArity(Clapi.OptResult result)
                   throws Clapi.OptParseException
Throws:
Clapi.OptParseException

get

public java.lang.Object get(Clapi.OptResult result)

getList

public java.util.List getList(Clapi.OptResult result)

getObjectArray

public java.lang.Object[] getObjectArray(Clapi.OptResult result)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

tag

public java.lang.String tag()

getOptionSpecifiers

public java.util.List getOptionSpecifiers()
Returns a list of strings containing human-readable descriptions of all the forms of this option.


getArgumentsSpec

public java.lang.String getArgumentsSpec()

printArgumentsSpec

public void printArgumentsSpec(java.io.PrintWriter out)