borland Packages Class Hierarchy jbcl.util Package Index
java.lang.Object +----java.text.Format +----borland.jbcl.util.TextFormat
Variables Constructors Properties Methods
Implements Serializable, Cloneable
This method extends the basic Format class but allows for special formatting of text. Similar to other Format derivatives, it is based on a control pattern. The format of the control pattern is as follows:
Format: <pattern>; <keepLiterals>; <fillCharacter>; <replaceCharacter>
Parameters:
0 Digit 0:9, entry required, '+' and '-' not allowed 9 Digit 0:9, entry optional, '+' and '-' not allowed # Digit or space, entry optional, plus and minus signs allowed L Letter A:Z, entry required l Letter A:Z, entry optional ? Letter A:Z, entry optional A Letter A:Z or digit 0:9, entry required a letter A:Z or digit 0:9, entry optional C any character or space, entry required c Any character or space, entry optional & Any character or space, entry required < Causes all characters following to be converted to lowercase > Causes all characters following to be converted to uppercase ! Causes strings too short to fill from right to left \ Backslash escape -- allows any Unicode value to follow (e.g. "\u2003") ^ Initial place for cursor when editing begins ' Encloses a literal expression (for example, the pattern "990' units sold'" would display as "27 units sold") * Encloses a password encrypted string (for example the pattern "*AAAAaaaa*" would accept a password at least 4, and at most 8 alphanumeric characters). Characters typed or displayed appear as the '*' character
An example of a US phone number might be "!(999)000-0000"
Note: Each of the special fields (keepLiterals, fillCharacter, replaceCharacter) have their own setter and getter methods.
public static char NOT_A_CHAR = 0xffff
public TextFormat()Constructs a TextFormat object with no specified string pattern.
public TextFormat(java.lang.String pattern)Constructs a TextFormat object with the specified string pattern.
public char getFillCharacter() public void setFillCharacter(char c)Retrieves and sets the fill character used in the string.
Parameters:
public boolean getKeepLiterals() public void setKeepLiterals(boolean tf)Determines whether literals remain in the string when it is stored. keepLiterals is true when literals are stored; otherwise, it is false.
Parameters:
public char getReplaceCharacter() public void setReplaceCharacter(char c)Retrieves and sets the character that replaces the fill character when the string is parsed.
Parameters:
public void applyPattern(java.lang.String pattern)Sets the pattern to the specified value.
public final StringBuffer format(java.lang.Object obj, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)
Overrides: java.text.Format.format(Object, StringBuffer, FieldPosition)
public StringBuffer format(java.lang.String toBeFormatted, java.lang.StringBuffer result, java.text.FieldPosition pos)This method formats the given String (toBeFormatted) using the pattern associated with this object. If the input string has insufficient characters to fill the pattern, it is filled with the character indicated by the setFillChar() method. The result parameter is assigned the return value of this method.
public StringBuffer parse(java.lang.String text, java.text.ParsePosition pos)This method parses (or decomposes) a String using the existing pattern. It allocates a new StringBuffer and fills it with the parsed version of the text parameter.
public final Object parseObject(java.lang.String source, java.text.ParsePosition pos)
Parameters:
Overrides: java.text.Format.parseObject(String, ParsePosition)
public String toPattern()Returns the pattern used for formatting.