borland Packages  Class Hierarchy  dx.text Package 

ItemFormatter class (abstract)

java.lang.Object
   +----com.borland.dx.text.ItemFormatter
           +----com.borland.dx.text.VariantFormatter
           +----com.borland.dx.text.ItemFormatStr

About the ItemFormatter class

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:

ItemFormatter has defined constants for each of these:

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.


ItemFormatter properties

*Read-only properties **Write-only properties

Properties implemented in this class

Properties implemented in java.lang.Object

ItemFormatter methods

Methods implemented in this class

Methods implemented in java.lang.Object


ItemFormatter properties

formatObj

 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.

locale

 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.

pattern

 public String getPattern()
Returns the pattern currently being used by this Formatter for parsing and formatting.

ItemFormatter methods

format(java.lang.Object)

  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.

Parameters:

value
The value to be formatted to a String.

getSpecialObject(int)

  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().

Parameters:

objType
The special object type to return.

parse(java.lang.String)

  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.

Parameters:

stringValue
The string to be parsed.

setPattern(java.lang.String)

  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.

Parameters:

pattern
The new pattern to be used for formatting and parsing.