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

VariantFormatStr class

java.lang.Object
   +----borland.jbcl.model.ItemFormatter
           +----borland.jbcl.model.VariantFormatter
                   +----borland.jbcl.model.VariantFormatStr

About the VariantFormatStr class

Constructors  Properties  Methods  

The VariantFormatStr class extends the VariantFormatter class through the use of String patterns to control formatting and parsing. It can handle all Variant types. Other formatter classes exist that are built to handle a specific Variant type.

There are five different kinds of pattern strings which can be used. Each is distinct, and the fields from one cannot be used with another. The type used will be inferred from the Variant.type passed into the constructor. The types are:

See edit/display masks for information about using the various patterns.


VariantFormatStr constructors

VariantFormatStr properties

*Read-only properties **Write-only properties

Properties implemented in this class

Properties implemented in java.lang.Object

VariantFormatStr methods

Methods implemented in this class

Methods implemented in borland.jbcl.model.VariantFormatter

Methods implemented in java.lang.Object


VariantFormatStr constructors

VariantFormatStr(java.lang.String, int)

  public VariantFormatStr(java.lang.String pattern, int variantType)
Constructs a VariantFormatStr object that specifies the pattern used to format values and the type of data the object formats and parses.

Parameters:

pattern
The string of special characters uses to format values when using the format() method. If this value is null (or empty), the best default pattern is automatically selected based on the locale.
variantType
The Variant data type that is used by the format() and parse() methods.

VariantFormatStr(java.lang.String, int, java.util.Locale)

  public VariantFormatStr(java.lang.String pattern, int variantType, java.util.Locale locale)
Constructs a VariantFormatStr object that specifies the pattern used to format values, the type of data the object formats and parses, and the locale.

Parameters:

pattern
The string of special characters uses to format values when using the format() method. If this value is null (or empty), the best default pattern is automatically selected based on the locale.
variantType
The Variant data type that is used by the format() and parse() methods.
locale
The locale, which affects such things as what the currency sign looks like, how time and date data appears, and so on. If locale is null, the current default locale is used.

VariantFormatStr(java.lang.String, int, java.util.Locale, int, int, boolean)

  public VariantFormatStr(java.lang.String pattern, int variantType, java.util.Locale locale, int scale, int precision, boolean isCurrency)
Constructs a VariantFormatStr object that specifies the pattern used to format values, the type of data the object formats and parses, the locale, and other formatting information.

Parameters:

pattern
The string of special characters uses to format values when using the format() method. If this value is null (or empty), the best default pattern is automatically selected based on the locale.
variantType
The Variant data type that is used by the format() and parse() methods.
locale
The locale, which affects such things as what the currency sign looks like, how time and date data appears, and so on. If locale is null, the current default locale is used.
scale
Used for BigDecimal data types. Any value other than -1 selects the number of decimal digits used in formatting and parsing BigDecimal values. Note that pattern must still express the number of digits to be displayed.
precision
Must be -1. Currently, precision is not used.
isCurrency
Indicates that a numeric field is currency. If isCurrency is true, the data is a currency value.

VariantFormatStr properties

formatObj

 public Format getFormatObj()
Returns the JDK Format subclass associated with this formatter. A returned value of null is possible.

locale

 public Locale getLocale()
Returns the Locale object being used by this formatting class. The returned value will never be null.

pattern

 public String getPattern()
Returns the pattern used by this VariantFormatStr object for formatting and parsing. See edit/display patterns.

scale

 public int getScale()
Returns the current scale factor, which is relevant only for BigDecimal data.

variantType

 public int getVariantType()
Returns the Variant type for this VariantFormatStr object.

VariantFormatStr methods

buildTrueFormatMask(java.lang.String)

  public static final String buildTrueFormatMask(java.lang.String editMask)
Returns a pattern string, removing any Borland-specific extensions.

Parameters:

edit
The edit mask to be used for formatting and parsing the data.

format(borland.jbcl.util.Variant)

  public String format(borland.jbcl.util.Variant value)
Returns a formatted string from the value specified with the value parameter. format() uses the current pattern to format the value. format() does not support all data types, but an attempt is made to cast the Variant data into a type required by the formatting logic.

The returned formatted string could be empty if the input Variant was null or unassigned. A null is returned if the formatting fails.

Parameters:

value
The value to be formatted. If value isn't a Variant, the method throws the InvalidFormatException.

Overrides: borland.jbcl.model.VariantFormatter.format(Variant)

getDefaultPattern(int)

  protected String getDefaultPattern(int variantType)
Returns the default pattern used for formatting the data based on the Variant type and the current locale.

getSpecialObject(int)

  public Object getSpecialObject(int objType)
Retrieves the special object associated with a particular formatter. This is a general purpose routine to obtain specific booleans, characters, flags, and so on inside a formatter, but it is completely dependent on the formatter being used.

Parameters:

objType
Identifies which object in which formatter to retrieve. It can be ItemFormatter.FILLCHARACTER or ItemFormatter.REPLACECHARACTER. Fill characters are used to fill empty slots in the string. Replace characters replace fill characters on output.

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

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

  public void parse(java.lang.String stringValue, borland.jbcl.util.Variant value)
Parses a string using the current pattern and produces the appropriate value in the form of a Variant.

Parameters:

stringValue
The string to be parsed. A null of empty value returns a Variant object which is set to AssignedNull.
value
The Variant contains the result. Its type is determined by the variantType parameter in the class constructor.

Overrides: borland.jbcl.model.VariantFormatter.parse(java.lang.String, Variant)

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

  public void parse(java.lang.String stringValue, borland.jbcl.util.Variant value, int variantType)
Parses a string using the current pattern and produces the appropriate value in the form of a Variant.

Parameters:

stringValue
The string to be parsed. A null of empty value returns a Variant object which is set to AssignedNull.
value
The Variant contains the result.
variantType
Specifies the Variant type returned in the value parameter.

Overrides: borland.jbcl.model.VariantFormatter.parse(java.lang.String, Variant, int)

setPattern(java.lang.String)

  public String setPattern(java.lang.String pattern)
Sets the pattern used by this VariantFormatStr object to format and parse. See edit/display masks for information about specifying a pattern.

The prior pattern is returned.

Parameters:

pattern
The pattern that controls the formatting and parsing.

Overrides: borland.jbcl.model.VariantFormatter.setPattern(java.lang.String)

setSpecialObject(int, java.lang.Object)

  public Object setSpecialObject(int objType, java.lang.Object obj)
Sets the special object associated with a particular formatter. This is a general purpose routine to obtain specific booleans, characters, flags, and so on inside a formatter, but it is completely dependent on the formatter being used. setSpecialObject() returns the prior special object, which can be useful for restoring the original value after a temporary alteration.

Parameters:

objType
Identifies which object in which formatter to retrieve. It can be ItemFormatter.FILLCHARACTER or ItemFormatter.REPLACECHARACTER. Fill characters are used to fill empty slots in the string. Replace characters replace fill characters on output.
obj
Contains the object to be set. The type of the Object must match the expected type for the given objType; do not pass a null object.

Overrides: borland.jbcl.model.VariantFormatter.setSpecialObject(int, java.lang.Object)