All Packages Class Hierarchy This Package Previous Next Index
Class COM.taligent.widget.MaskCharacter
java.lang.Object
|
+----COM.taligent.widget.MaskCharacter
- public class MaskCharacter
- extends Object
- implements Serializable
A mask character used by the MaskedTextField to define
a mask and validate character input.
A series of pre-defined mask characters are given as
constants but you can define your own mask character
that accepts a set of "valid" characters as input.
For example, you can define a mask character of '#'
that only allows the numbers 0 through 9 to be entered.
That mask would be:
new MaskCharacter('#', "0-9");
The set of valid characters can be defined as a series
of single characters, a range of characters, or both.
For example, the following are all equivalent to "0-9":
- "0123456789"
- "0-456789"
- "0-45-9"
A translation sequence can also be specified in
order to convert the accepted character to a completely
different character. For example, you can specify a
mask that accepts lowercase characters but converts them
to uppercase by use of the following mask:
new MaskCharacter('^', "a-zA-Z", "A-ZA-Z");
You could even convert letters to their equivalent standard
telephone digit by use of the following mask:
new MaskCharacter('^', "a-cA-Cd-fD-Fetc", "2233etc");
Note: When specifying a translation sequence, it
is very important to have the same number of ranges as the
valid character sequence!
- Version:
- 1.0
- Author:
- Andy Clark, Taligent Inc.
- See Also:
- MaskedTextField
-
ALPHANUMERIC
- Alphanumeric chars, space not allowed ('@',"0-9a-zA-Z").
-
DIGITS
- Numeric digits, space not allowed ('#',"0-9").
-
LOWERCASE
- Lowercase Roman letters, space not allowed ('a',"a-z").
-
UPPERCASE
- Uppercase Roman letters, space not allowed ('A',"A-Z").
-
MaskCharacter(char, String)
- Constructs a character mask from the specified mask
character corresponding to the set of valid characters.
-
MaskCharacter(char, String, String)
- Constructs a character mask from the specified mask
character, valid characters set, and translation set.
-
getMaskCharacter()
- Returns the mask character.
-
getTranslation()
- Returns the translation sequence or null, if none is set.
-
getValidCharacters()
- Returns the valid characters string.
-
toString()
- Returns a string representation of this instance.
-
validateCharacter(char)
- Returns the validated character or -1 if character was
invalid
DIGITS
public static final MaskCharacter DIGITS
- Numeric digits, space not allowed ('#',"0-9").
LOWERCASE
public static final MaskCharacter LOWERCASE
- Lowercase Roman letters, space not allowed ('a',"a-z").
UPPERCASE
public static final MaskCharacter UPPERCASE
- Uppercase Roman letters, space not allowed ('A',"A-Z").
ALPHANUMERIC
public static final MaskCharacter ALPHANUMERIC
- Alphanumeric chars, space not allowed ('@',"0-9a-zA-Z").
MaskCharacter
public MaskCharacter(char maskchar,
String validchars)
- Constructs a character mask from the specified mask
character corresponding to the set of valid characters.
No translation of accepted characters is done.
- Parameters:
- maskchar - The mask character.
- validchars - The valid chars for this mask character.
MaskCharacter
public MaskCharacter(char maskchar,
String validchars,
String translation)
- Constructs a character mask from the specified mask
character, valid characters set, and translation set.
- Parameters:
- maskchar - The mask character.
- validchars - The valid chars for this mask character.
- translation - The translation chars for the valid chars.
getMaskCharacter
public char getMaskCharacter()
- Returns the mask character.
getValidCharacters
public String getValidCharacters()
- Returns the valid characters string.
getTranslation
public String getTranslation()
- Returns the translation sequence or null, if none is set.
validateCharacter
public synchronized int validateCharacter(char ch)
- Returns the validated character or -1 if character was
invalid
- Parameters:
- ch - The character to validate.
toString
public String toString()
- Returns a string representation of this instance.
- Overrides:
- toString in class Object
All Packages Class Hierarchy This Package Previous Next Index