JIDE 3.5.15

com.jidesoft.field.creditcard
Class DefaultCreditCardMask

java.lang.Object
  extended by com.jidesoft.field.creditcard.DefaultCreditCardMask
All Implemented Interfaces:
CreditCardMask

public class DefaultCreditCardMask
extends Object
implements CreditCardMask

A default implementation of CreditCardMask to mask a credit card number by hiding a number of digits in the middle the number.


Constructor Summary
DefaultCreditCardMask()
           
DefaultCreditCardMask(int firstDigits, int lastDigits)
           
DefaultCreditCardMask(int firstDigits, int lastDights, char maskChar)
           
 
Method Summary
 int getFirstDigits()
          Gets the number of the first few digits that will be kept without being masked.
 int getLastDigits()
          Gets the number of the last few digits that will be kept without being masked.
 char getMaskChar()
          Gets the mask char.
 String mask(String cardNumber)
          Creates a masked version of the specified credit card number.
 void setFirstDigits(int firstDigits)
          Sets the number of the first few digits that will be kept without being masked.
 void setLastDigits(int lastDigits)
          Sets the number of the last few digits that will be kept without being masked.
 void setMaskChar(char maskChar)
          Sets the mask char.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultCreditCardMask

public DefaultCreditCardMask()

DefaultCreditCardMask

public DefaultCreditCardMask(int firstDigits,
                             int lastDigits)

DefaultCreditCardMask

public DefaultCreditCardMask(int firstDigits,
                             int lastDights,
                             char maskChar)
Method Detail

getFirstDigits

public int getFirstDigits()
Gets the number of the first few digits that will be kept without being masked.

Returns:
the number of the first few digits that will be kept without being masked.

setFirstDigits

public void setFirstDigits(int firstDigits)
Sets the number of the first few digits that will be kept without being masked.

Parameters:
firstDigits - the number of the first few digits that will be kept without being masked.

getLastDigits

public int getLastDigits()
Gets the number of the last few digits that will be kept without being masked.

Returns:
the number of the last few digits that will be kept without being masked.

setLastDigits

public void setLastDigits(int lastDigits)
Sets the number of the last few digits that will be kept without being masked.

Parameters:
lastDigits - the number of the last few digits that will be kept without being masked.

getMaskChar

public char getMaskChar()
Gets the mask char. The middle of the number will be replaced by this char.

Returns:
the mask char

setMaskChar

public void setMaskChar(char maskChar)
Sets the mask char. The middle of the number will be replaced by this char.

Parameters:
maskChar - A new mask char.

mask

public String mask(String cardNumber)
Creates a masked version of the specified credit card number. The mask includes a number of digits number in the head, a number of digits number in the tail and "*" in the middle. The number is determined by setFirstDigits(int) and setLastDigits(int).

Specified by:
mask in interface CreditCardMask
Parameters:
cardNumber - the credit card number to be masked
Returns:
the masked card number

JIDE 3.5.15