uk.org.jcam.util
Class Mask

java.lang.Object
  extended by uk.org.jcam.util.Mask

public class Mask
extends java.lang.Object

uk.org.jcam.util.Mask Utility class used to check Contents against Mask Statements It contains an abstract inner class abstractMask that is used to build the various Mask classes. There are three Mask classes dateMask, numberMask and String Mask. The key to the mask function is the convertToRegex method that takes the Mask and creates a Regular Expression that will check for the Mask The check method then simply uses the java.util.regex.Pattern method to check the input string against the pre-built mask. //TODO Mask - applyMask Currently the application of output Masks has not been implemented. //TODO Mask - input and output masks

Author:
robertmm 08-Jul-2003 17:43:44

Nested Class Summary
 class Mask.dateMask
           
 class Mask.MaskException
           
 class Mask.numberMask
          cam.util.numberMask Inner class extending the abstractMask class to implement the Number Mask functionality The following characters ar significant in Number Masks: 0 mandatory
 class Mask.stringMask
          cam.util.stringMask Inner class extending the abstractMask class to implement the String Mask functionality The following Characters are significant in String Masks: X for a mandatory character .
 
Field Summary
static java.lang.String MASK_DATE
           
static java.lang.String MASK_NUMBER
           
static java.lang.String MASK_STRING
           
 
Constructor Summary
Mask(java.lang.String mask, java.lang.String type)
          Mask
 
Method Summary
 java.lang.String apply(java.lang.String string)
          apply Takes the input string and changes it according to the output mask
 boolean check(java.lang.String string)
          check Calls the Masks check routine that will check the the input string against the Mask
 java.lang.String getExpandedMask()
          getExpandedMask Masks can contain shorthand statements indicating repeating character types.
 java.lang.String getRegex()
          getRegex Returns the Regular Expression that is created to implement the mask
 java.lang.String getType()
          getType Returns the type of Mask
static void setDebug(boolean b)
          setDebug
static void setTrace(boolean trace)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MASK_STRING

public static final java.lang.String MASK_STRING
See Also:
Constant Field Values

MASK_NUMBER

public static final java.lang.String MASK_NUMBER
See Also:
Constant Field Values

MASK_DATE

public static final java.lang.String MASK_DATE
See Also:
Constant Field Values
Constructor Detail

Mask

public Mask(java.lang.String mask,
            java.lang.String type)
     throws Mask.MaskException
Mask

Parameters:
mask - A String containing the mask
type - A String indicating the type of Mask either "Date", "Number" or "String"
Throws:
Mask.MaskException - Exception thrown by the mask constructor.
Method Detail

apply

public java.lang.String apply(java.lang.String string)
apply Takes the input string and changes it according to the output mask

Parameters:
string - A String to which the output mask should be applied
Returns:
The resulting String after the mask has been applied

check

public boolean check(java.lang.String string)
check Calls the Masks check routine that will check the the input string against the Mask

Parameters:
string - The String to be checked against the mask
Returns:
A boolean indicating success or failure. true is success.

getType

public java.lang.String getType()
getType Returns the type of Mask

Returns:
A string containing the inner class name of the Mask

getExpandedMask

public java.lang.String getExpandedMask()
getExpandedMask Masks can contain shorthand statements indicating repeating character types. The Mask is expanded upon creation. This method returns the expanded mask.

Returns:
a String containing the Mask after expansion.

getRegex

public java.lang.String getRegex()
getRegex Returns the Regular Expression that is created to implement the mask

Returns:
A String containing the Regular Expresion represention of the mask

setDebug

public static void setDebug(boolean b)
setDebug

Parameters:
b -

setTrace

public static void setTrace(boolean trace)
Parameters:
trace - The trace to set.