|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface StringParser
A StringParser is a class which can take a string and parse it into an object. The Formatter class and its subclasses implement this interface; some customer-defined classes under config may also implement this interface. It is used by the field defaulting framework to allow custom handling of string parsing. The parse() method takes a string and attempts to parse it into an object of the appropriate type. If the string can't be parsed, a ParseException is thrown. The value() method takes an arbitrary object and attempts to create an object of the appropriate type from it. In some cases the object returned may be the value itself (if it's already of the right type). Often, this method just converts the value to a string and calls parse(), returning a reasonable default value if a parse exception is caught.
Method Summary | |
---|---|
java.lang.Object |
getValue(java.lang.Object object)
Returns an object of the appropriate type for object. |
java.lang.Object |
parse(java.lang.String string)
Parses string into an object of the appropriate type. |
java.lang.Object |
parse(java.lang.String string,
java.util.Locale locale)
Parses string into an object of the appropriate type using the given locale. |
Method Detail |
---|
java.lang.Object parse(java.lang.String string) throws java.text.ParseException
string
- the string to be parsed
ParseExceptionunexpected
- error occurred while parsing
string
java.text.ParseException
java.lang.Object parse(java.lang.String string, java.util.Locale locale) throws java.text.ParseException
string
- the string to be parsedlocale
- the locale used when parsing the string
ParseExceptionunexpected
- error occurred while parsing
string
java.text.ParseException
java.lang.Object getValue(java.lang.Object object)
object
- The object being parsed
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |