borland Packages Class Hierarchy dx.text Package
java.lang.Object +----com.borland.dx.text.ItemFormatter +----com.borland.dx.text.VariantFormatter +----com.borland.dx.text.ItemFormatStr
Properties Methods
ItemFormatter is an abstract class that is the superclass of several others used to format and parse various types of data. Because different data types typically require different kinds of handling, there are five basic parse/format types currently supported:
All Formatter classes have a format() method that returns a data object as a string, and they have a parse() method that analyzes a string value and returns a data object.
The ItemFormatter class has a pattern property used to access the edit/display mask patterns that are used to format and parse the data.
The most commonly used subclass is ItemFormatStr, which uses pattern strings based on the JDK Format conventions.
public Format getFormatObj()ItemFormatter is itself a layer on the JDK's Format interface. getFormatObj() provides access to the underlying Format object being used by a particular Formatter (which depends on the type of data being formatted). It returns the Format object being used (see JDK's description of Format, NumberFormat, DecimalFormat, and SimpleTimeFormat).
getFormatObj() returns null if the constructor could not accept the initial pattern.
public Locale getLocale()Returns the Locale currently being used by this Formatter. Currently, there is no way to change this locale once the Formatter has been created. The returned value is never null.
public String getPattern()Returns the pattern currently being used by this Formatter for parsing and formatting.
public abstract String format(Object value)Returns a String representing the given value stored in the supplied object. All reasonable attempts are made to "cast" the type found in the object into the appropriate type specified in the constructor of the implementing classes. A returned empty string indicates a null or empty input value. null means the formatting failed.
public Object getSpecialObject(int objType)Returns the value of the specified special object.
Some Formatter classes define special objects for their own use. You must know the internal details of the Format subclass being used to use getSpecialObject().
public abstract Object parse(String stringValue)Analyzes the given String and produces as output an Object containing the appropriate value. A null return value results when stringValue is null or empty.
public String setPattern(String pattern)Sets the pattern used for parsing and formatting to a new pattern, returning the old pattern. The new pattern must be of the same basic type associated with this type of Formatter. For example, if you used a Date/Time pattern in the constructor, you can't switch to a numeric pattern as each basic pattern type has its own data-dependent format() and parse() methods.
If the new pattern is null (or empty), setPattern() chooses a default pattern for the current locale.