1 package prefuse.data.parser; 2 3 10 public class StringParser implements DataParser { 11 12 16 public Class getType() { 17 return String .class; 18 } 19 20 23 public String format(Object value) { 24 if ( value == null ) return null; 25 if ( !(value instanceof String ) ) 26 throw new IllegalArgumentException ( 27 "This class can only format Objects of type String."); 28 return (String )value; 29 } 30 31 34 public boolean canParse(String text) { 35 return true; 36 } 37 38 41 public Object parse(String text) throws DataParseException { 42 return text; 43 } 44 45 51 public String parseString(String text) throws DataParseException { 52 return text; 53 } 54 55 } | Popular Tags |