borland Packages Class Hierarchy dx.text Package
java.lang.Object +----com.borland.dx.text.ItemFormatter +----com.borland.dx.text.VariantFormatter +----com.borland.dx.text.BigDecimalFormatter +----com.borland.dx.text.BinaryFormatter +----com.borland.dx.text.BooleanFormatter +----com.borland.dx.text.IntegerFormatter +----com.borland.dx.text.DateFormatter +----com.borland.dx.text.DoubleFormatter +----com.borland.dx.text.LongFormatter +----com.borland.dx.text.ObjectFormatter +----com.borland.dx.text.SimpleFormatter +----com.borland.dx.text.StringFormatter +----com.borland.dx.text.TimeFormatter +----com.borland.dx.text.TimestampFormatter +----com.borland.dx.text.VariantFormatStr
Properties Methods
This general-purpose formatting class is a subclass of the abstract ItemFormatter
that formats and parses Variant
data. All classes in the dx.dataset
package use the VariantFormatter
class exclusively.
public Format getFormatObj()
VariantFormatter
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 int getScale()Returns the scale being used for numeric formatting.
getScale()
always returns -1, meaning no scale is being used. Override this method if you want to use a different scale.
public abstract int getVariantType()Returns the
Variant
type being used by this Variant
Formatter. All calls to getVariantType()
will produce Variants
of this type. There is no setVariantType()
because there is a special version of parse()
, which allows the caller to request a particular returned Variant
type.
public abstract String format(Variant 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.
value
String
.
public FastStringBuffer format(Variant value, FastStringBuffer buffer)Constructs a
FastStringBuffer
representing the given value stored in the supplied Variant
. All reasonable attempts are made to "cast" the type found in the Variant into the appropriate type specified in the constructor of the subclasses. A returned empty string indicates a null or empty input value. A null return means the formatting failed.
value
Variant
itself will not be altered).
buffer
FastStringBuffer
that receives the formatted text. null is not permitted.
public 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.
value
String
.
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(
).
objType
public void parse(Variant variant, char[] value, int offset, int len)A high-speed parse that parses directly into a character array.
variant
value
offset
len
public 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.
stringValue
public abstract void parse(String stringValue, Variant value)Analyzes the given
String
and produces as output a Variant
containing the approriate value.
stringValue
value
Variant
that receives the parsed result.
public void parse(String stringValue, Variant value, int variantType)An alternative form of
parse()
that allows the type of Variant
returned to be specified.
stringValue
stringValue
returns a VariantAssignedNull
variant.
value
Variant
that receives the resulting data.
variantType
variantType
is zero or one of the VariantIsNull
types, the method chooses the default variant type specified at the time of the construction of VariantFormatter
.
public static final void setFromDouble(Variant value, int type, double val)Sets the variant using the specified double value.
value
type
Variant.FLOAT
type.
val
public static final void setFromInt(Variant value, int type, int val)Sets the variant using the specified int value.
value
type
Variant.BYTE
and Variant.SHORT
types.
val
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.
pattern
public Object setSpecialObject(int charType, Object obj)Some Formatter classes define special objects for their own use. This method allows them to be set. You must know the internal details of the Format subclass being used to use
setSpecialObject(
).
The returned value is the prior value of the object.
charType
VariantFormatter.FillChar
, which is the fill character to fill blank slots, and VariantFormatter.Replacecharacter
, which is used to replace FillChar
on parse.
obj