org.zaval.lw.mask
Class BasicMaskValidator

java.lang.Object
  |
  +--org.zaval.lw.mask.BasicMaskValidator
All Implemented Interfaces:
MaskValidator
Direct Known Subclasses:
LwSpinValidator

public class BasicMaskValidator
extends java.lang.Object
implements MaskValidator

This is an implementation of MaskValidator interface. This basic mask validator that is used by MaskedText as default if any other has not been set. The validator supports two mask elements types:

The mask can contains following letters:

The first two mask letters belong to letter mask type and the rest belongs to numeric mask type.

The table bellow shows different masks that can be combined using the validator:
Mask Shown Result (by LwMaskedTextField) Sample value
"nnnn-nnnn.nnn" "0000-0000.000" "1230-1020.220"
"(Aaaaa nnnn)" "(_____ 0000)" "(Abcde 1211)"
"#nnnn(digit)" "+0000(digit)" "-2331(digit)"


Field Summary
static int LETTER_TYPE
          This letter mask element type definition.
static int NUMERIC_TYPE
          This numeric mask element type definition.
 
Constructor Summary
BasicMaskValidator()
           
 
Method Summary
 java.lang.String completeValue(MaskElement e, java.lang.String newValue)
          Completes the new value for the specified mask element.
 char getBlankChar(char tag)
          Gets the blank character for the specified mask tag.
 int getTypeByTag(char tag)
          Gets the type for the specified mask tag.
 java.lang.Object getValueByElement(MaskElement e)
           
 boolean isHandledTag(char tag)
          Tests if the mask tag is handled with the validator.
 boolean isValidValue(MaskElement e, java.lang.String value)
          Tests if the specified value is valid for the mask element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LETTER_TYPE

public static final int LETTER_TYPE
This letter mask element type definition.

NUMERIC_TYPE

public static final int NUMERIC_TYPE
This numeric mask element type definition.
Constructor Detail

BasicMaskValidator

public BasicMaskValidator()
Method Detail

isHandledTag

public boolean isHandledTag(char tag)
Description copied from interface: MaskValidator
Tests if the mask tag is handled with the validator.
Specified by:
isHandledTag in interface MaskValidator
Following copied from interface: org.zaval.lw.mask.MaskValidator
Parameters:
tag - the mask tag.
Returns:
true if the mask handles the specified mask tag; otherwise false.

getBlankChar

public char getBlankChar(char tag)
Description copied from interface: MaskValidator
Gets the blank character for the specified mask tag. The blank char is used to fill mask value for the tag.
Specified by:
getBlankChar in interface MaskValidator
Following copied from interface: org.zaval.lw.mask.MaskValidator
Parameters:
tag - the mask tag.
Returns:
a blank character.

getTypeByTag

public int getTypeByTag(char tag)
Description copied from interface: MaskValidator
Gets the type for the specified mask tag. The method should returns -1 type if the tag is not bound with any type.
Specified by:
getTypeByTag in interface MaskValidator
Following copied from interface: org.zaval.lw.mask.MaskValidator
Parameters:
tag - the mask tag.
Returns:
a type.

isValidValue

public boolean isValidValue(MaskElement e,
                            java.lang.String value)
Description copied from interface: MaskValidator
Tests if the specified value is valid for the mask element.
Specified by:
isValidValue in interface MaskValidator
Following copied from interface: org.zaval.lw.mask.MaskValidator
Parameters:
e - the mask element.
newValue - the new value.
Returns:
true if the mask value is valid; otherwise false.

completeValue

public java.lang.String completeValue(MaskElement e,
                                      java.lang.String newValue)
Description copied from interface: MaskValidator
Completes the new value for the specified mask element.
Specified by:
completeValue in interface MaskValidator
Following copied from interface: org.zaval.lw.mask.MaskValidator
Parameters:
e - the mask element.
newValue - the new value.
Returns:
a new completed value.

getValueByElement

public java.lang.Object getValueByElement(MaskElement e)


Copyright © Zaval Creative Engineering Group, 2000-2005.
http://www.zaval.org