net.sf.jga.fn.string
public class ParseFormat<R> extends AbstractUnaryFunctor<String,R> implements Serializable
Note that declaring the return type incorrectly can result in a ClassCastException being thrown when the functor is invoked: the compiler cannot check the return type.
Copyright © 2003 David A. Hall
Nested Class Summary | |
---|---|
interface | ParseFormat.Visitor
Interface for classes that may interpret a ParseFormat
predicate. |
Constructor Summary | |
---|---|
ParseFormat(Format format)
Builds a functor that will create instances of the given class by parsing
string argument with the given text format. |
Method Summary | |
---|---|
void | accept(Visitor v)
Calls the Visitor's visit(ParseFormat) method, if it
implements the nested Visitor interface. |
R | fn(String arg)
Parses the value from the given string, using the java.text.Format object
passed at construction.
|
Format | getFormat() |
String | toString() |
ParseFormat parser =
new ParseFormat(DateFormat.getDateInstance());
Throws: IllegalArgumentException if either argument is omitted
visit(ParseFormat)
method, if it
implements the nested Visitor interface.Parameters: arg formatted string to be parsed
Returns: the value that the string represented
Returns: the format used to parse values