edu.rice.cs.drjava.config
Class VectorOption<T>

java.lang.Object
  extended by edu.rice.cs.drjava.config.OptionParser<T>
      extended by edu.rice.cs.drjava.config.Option<Vector<T>>
          extended by edu.rice.cs.drjava.config.VectorOption<T>
All Implemented Interfaces:
FormatStrategy<Vector<T>>, ParseStrategy<Vector<T>>

public class VectorOption<T>
extends Option<Vector<T>>

Abstract class defining behavior shared by all configuration options with values of type Vector. VectorOption now allows empty strings, i.e. "[,]" is a vector of two empty strings. "[]" will be interpreted as a vector of one empty string, and "" is an empty vector.

Version:
$Id: VectorOption.java 5175 2010-01-20 08:46:32Z mgricken $

Field Summary
 char delim
           
 String footer
           
protected  FormatStrategy<T> formatter
           
 String header
           
protected  ParseStrategy<T> parser
           
 
Fields inherited from class edu.rice.cs.drjava.config.Option
listeners
 
Fields inherited from class edu.rice.cs.drjava.config.OptionParser
defaultValue, map, name
 
Constructor Summary
  VectorOption(String key, Option<T> strategy, String header, char delim, String footer, Vector<T> def)
           
  VectorOption(String key, Option<T> option, Vector<T> def)
          Defaults the "header", "footer", and "delim" fields to open bracket, close bracket, and comma, repsectively.
private VectorOption(String key, ParseStrategy<T> parser, FormatStrategy<T> formatter, String header, char delim, String footer, Vector<T> def)
           
 
Method Summary
 String format(Vector<T> v)
          Formats the Vector v.
 Vector<T> parse(String s)
          The ability to parse a string to an object of type T.
 
Methods inherited from class edu.rice.cs.drjava.config.Option
addListener, getDefaultString, getString, notifyListeners, removeListener
 
Methods inherited from class edu.rice.cs.drjava.config.OptionParser
getDefault, getName, getOption, remove, setOption, setString, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parser

protected ParseStrategy<T> parser

formatter

protected FormatStrategy<T> formatter

header

public final String header

delim

public final char delim

footer

public final String footer
Constructor Detail

VectorOption

private VectorOption(String key,
                     ParseStrategy<T> parser,
                     FormatStrategy<T> formatter,
                     String header,
                     char delim,
                     String footer,
                     Vector<T> def)
Parameters:
key - The name of this option.
parser - the parsing strategy for an element in this option
formatter - the formatting strategy for an element in this option

VectorOption

public VectorOption(String key,
                    Option<T> strategy,
                    String header,
                    char delim,
                    String footer,
                    Vector<T> def)

VectorOption

public VectorOption(String key,
                    Option<T> option,
                    Vector<T> def)
Defaults the "header", "footer", and "delim" fields to open bracket, close bracket, and comma, repsectively.

Parameters:
key - The name of this option.
option - The object that knows how to parse and format an element of type T.
Method Detail

parse

public Vector<T> parse(String s)
Description copied from class: OptionParser
The ability to parse a string to an object of type T. All concrete versions of this class must override this method to provide some sort of parser implementation.

Specified by:
parse in interface ParseStrategy<Vector<T>>
Specified by:
parse in class OptionParser<Vector<T>>
Parameters:
s - The String to be parsed.
Returns:
An instance of Vector represented by "s".
Throws:
IllegalArgumentException - if "s" is not formatted according to the method Vector.toString().

format

public String format(Vector<T> v)
Formats the Vector v. The overall String format is determined by the method Vector.tString(), but each element of the vector is formatted by calling formatElement().

Specified by:
format in interface FormatStrategy<Vector<T>>
Overrides:
format in class Option<Vector<T>>
Parameters:
v - The Vector to be formatted.
Returns:
A String representing "v".