com.purpletech.util
Class StringConverter
java.lang.Object
|
+--com.purpletech.util.StringConverter
- public class StringConverter
- extends java.lang.Object
Converts a String into a given object type (and back again).
Supports factories, so if you have a custom type, you can add it,
e.g.
stringconverter.setFactory(Foo.class,
new StringConverter.Factory() {
public Object fromString(String value) {
return new Foo(value);
}
public String toString(Object obj) {
return ((Foo)obj).getStringValue();
}
});
- Author:
- Alex Chaffee (alex@jguru.com)
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
dateFormat
public static java.text.DateFormat dateFormat
factories
protected java.util.Map factories
argString
protected static java.lang.Class[] argString
StringConverter
public StringConverter()
setFactory
public void setFactory(java.lang.Object type,
StringConverter.Factory factory)
getFactory
public StringConverter.Factory getFactory(java.lang.Object type)
printParseException
public static void printParseException(java.io.PrintWriter out,
java.lang.String s,
java.text.ParseException p)
fromString
public java.lang.Object fromString(java.lang.String string,
java.lang.Object type)
throws java.text.ParseException
- Parameters:
string - the string to parsetype - the type of parsing to be done (usually the class object, although it could be a string key for, e.g., dates)
java.text.ParseException
toString
public java.lang.String toString(java.lang.Object object)
toString
public java.lang.String toString(java.lang.Object object,
java.lang.Object type)