borland.jbcl Packages  borland.jbcl Class Hierarchy  borland.jbcl.model 

VariantFormatter class (abstract)

java.lang.Object
   +----borland.jbcl.model.ItemFormatter
           +----borland.jbcl.model.VariantFormatter
                   +----borland.jbcl.model.VariantFormatStr
                   +----borland.jbcl.model.BigDecimalFormatter
                   +----borland.jbcl.model.BinaryFormatter
                   +----borland.jbcl.model.BooleanFormatter
                   +----borland.jbcl.model.DateFormatter
                   +----borland.jbcl.model.StringFormatter
                   +----borland.jbcl.model.TimeFormatter
                   +----borland.jbcl.model.TimestampFormatter
                   +----borland.jbcl.model.SimpleFormatter
                   +----borland.jbcl.model.LongFormatter
                   +----borland.jbcl.model.IntegerFormatter
                   +----borland.jbcl.model.DoubleFormatter

About the VariantFormatter class

Properties  Methods  
This general-purpose formatting class is a subclass of the abstract ItemFormatter that formats and parses Variant data. All classes in the dataset package use the VariantFormatter class exclusively.

VariantFormatter properties

*Read-only properties **Write-only properties

Properties implemented in this class

Properties implemented in java.lang.Object

VariantFormatter methods

Methods implemented in this class

Methods implemented in java.lang.Object


VariantFormatter properties

formatObj

 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.

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.

scale

 public int getScale()
Returns the scale being used for numeric formatting.

variantType

 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.

VariantFormatter methods

format(borland.jbcl.util.Variant)

  public abstract String format(borland.jbcl.util.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.

Parameters:

value
The value to be formatted to a String.

format(borland.jbcl.util.Variant, borland.jbcl.util.FastStringBuffer)

  public FastStringBuffer format(borland.jbcl.util.Variant value, borland.jbcl.util.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.

Parameters:

value
The value to be formatted. It will be cast to the appropriate type where possible (though the variant itself will not be altered).
buffer
A FastStringBuffer that receives the formatted text. null is not permitted.

format(java.lang.Object)

  public String format(java.lang.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.

Overrides: borland.jbcl.model.ItemFormatter.format(java.lang.Object)

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.

Overrides: borland.jbcl.model.ItemFormatter.getSpecialObject(int)

parse(borland.jbcl.util.Variant, char[], int, int)

  public void parse(borland.jbcl.util.Variant variant, char[]value, int offset, int len)
A high-speed parse that parses directly into a character array.

Parameters:

variant
The parsed value (may not be null).
value
The character array containing the text to parse.
offset
The zero-based offset into the character array.
len
The maximum number of characters in the array to use in the parse.

parse(java.lang.String)

  public Object parse(java.lang.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.

Overrides: borland.jbcl.model.ItemFormatter.parse(String)

parse(java.lang.String, borland.jbcl.util.Variant)

  public abstract void parse(java.lang.String stringValue, borland.jbcl.util.Variant value)
Analyzes the given String and produces as output a Variant containing the approriate value.

Parameters:

stringValue
The string to be parsed.
value
The Variant that receives the parsed result.

parse(java.lang.String, borland.jbcl.util.Variant, int)

  public void parse(java.lang.String stringValue, borland.jbcl.util.Variant value, int variantType)
An alternative form of parse() that allows the type of Variant returned to be specified.

Parameters:

stringValue
The string to be parsed. A null or empty stringValue returns a VariantAssignedNull variant.
value
The Variant that receives the resulting data.
variantType
The desired type of variant. If 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.

setPattern(java.lang.String)

  public String setPattern(java.lang.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.

setSpecialObject(int, java.lang.Object)

  public Object setSpecialObject(int charType, java.lang.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.

Parameters:

charType
The special object type. The possible values are VariantFormatter.FillChar, which is the fill character to fill blank slots, and VariantFormatter.Replacecharacter, which is used to replace FillChar on parse.
obj
The special object.