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