01: package prefuse.data.parser;
02:
03: /**
04: * Interface for data parsers, which parse data values from text Strings
05: * and generated formatted text Strings for data values.
06: *
07: * @author <a href="http://jheer.org">jeffrey heer</a>
08: */
09: public interface DataParser {
10:
11: /**
12: * Get the data type for the values parsed by this parser.
13: * @return the parsed data type for this parser as a Java Class instance
14: */
15: public Class getType();
16:
17: /**
18: * Get a String representation for the given value.
19: * @param value the object value to format
20: * @return a formatted String representing the input value
21: */
22: public String format(Object value);
23:
24: /**
25: * Indicates if the given text string can be successfully parsed by
26: * this parser.
27: * @param text the text string to check for parsability
28: * @return true if the string can be successfully parsed into this
29: * parser's data type, false otherwise
30: */
31: public boolean canParse(String text);
32:
33: /**
34: * Parse the given text string to a data value.
35: * @param text the text string to parse
36: * @return the parsed data value, which will be an instance of the
37: * Class returned by the {@link #getType()} method
38: * @throws DataParseException if an error occurs during parsing
39: */
40: public Object parse(String text) throws DataParseException;
41:
42: } // end of interface DataParser
|