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":

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

Variable Index

 o ALPHANUMERIC
Alphanumeric chars, space not allowed ('@',"0-9a-zA-Z").
 o DIGITS
Numeric digits, space not allowed ('#',"0-9").
 o LOWERCASE
Lowercase Roman letters, space not allowed ('a',"a-z").
 o UPPERCASE
Uppercase Roman letters, space not allowed ('A',"A-Z").

Constructor Index

 o MaskCharacter(char, String)
Constructs a character mask from the specified mask character corresponding to the set of valid characters.
 o MaskCharacter(char, String, String)
Constructs a character mask from the specified mask character, valid characters set, and translation set.

Method Index

 o getMaskCharacter()
Returns the mask character.
 o getTranslation()
Returns the translation sequence or null, if none is set.
 o getValidCharacters()
Returns the valid characters string.
 o toString()
Returns a string representation of this instance.
 o validateCharacter(char)
Returns the validated character or -1 if character was invalid

Variables

 o DIGITS
 public static final MaskCharacter DIGITS
Numeric digits, space not allowed ('#',"0-9").

 o LOWERCASE
 public static final MaskCharacter LOWERCASE
Lowercase Roman letters, space not allowed ('a',"a-z").

 o UPPERCASE
 public static final MaskCharacter UPPERCASE
Uppercase Roman letters, space not allowed ('A',"A-Z").

 o ALPHANUMERIC
 public static final MaskCharacter ALPHANUMERIC
Alphanumeric chars, space not allowed ('@',"0-9a-zA-Z").

Constructors

 o 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.
 o 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.

Methods

 o getMaskCharacter
 public char getMaskCharacter()
Returns the mask character.

 o getValidCharacters
 public String getValidCharacters()
Returns the valid characters string.

 o getTranslation
 public String getTranslation()
Returns the translation sequence or null, if none is set.

 o validateCharacter
 public synchronized int validateCharacter(char ch)
Returns the validated character or -1 if character was invalid

Parameters:
ch - The character to validate.
 o 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