All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----java.text.Format
If formatting is unsuccessful, ClassCastException is returned when the Format cannot format the type of object, otherwise if there is something illformed about the the Unicode replacement character \\uFFFD is returned.
If there is no match when parsing, FormatException is thrown for the method that takes no ParseStatus. For the method that takes a ParseStatus, the startAt parameter is left unchanged.
Subclassing. All base classes that provide static functions that create objects for Locales must implement three statics:
public static Locale[] getAvailableLocales()
public static String getDisplayName(Locale objectLocale,
Locale displayLocale)
public static final String getDisplayName(Locale objectLocale)
public Format()
public final String format(Object obj)
Subclasses will override the StringBuffer version of format.
public abstract StringBuffer format(Object obj,
StringBuffer toAppendTo,
FormatStatus status)
StringBuffer format (Number obj, StringBuffer toAppendTo) Number parse (String str)These general routines allow polymorphic parsing and formatting for objects such as the ParameterFormat.
public abstract Object parseObject(String source,
ParseStatus status)
String format (Number obj);
String format (long obj);
String format (double obj);
Number parse (String str);
Before calling, set status.startAt to the offset you want to start parsing at in the source. After calling, status.startAt is the end of the text you parsed. If error occurs, startAt is unchanged.
When parsing, leading whitespace is discarded (with successful parse), while trailing whitespace is left as is.
Example: Parsing "_12_xy" (where _ represents a space) for a number, with startAt == 0 will result in the number 12, with status.startAt updated to 3 (just before the second space). Parsing a second time will result in a FormatException since "xy" is not a number, and leave startAt at 3.
Subclasses will typically supply specific parse methods that return different types of values. Since methods can't overload on return types, these will typically be named "parse", while this polymorphic method will always be called parseObject. Any parse method that does not take a status should throw FormatException when no text in the required format is at the start position.
public Object parseObject(String source) throws FormatException
All Packages Class Hierarchy This Package Previous Next Index