CreditCardPack

com.keyoti.creditCard.logic.ejb
Class CreditCardBean

java.lang.Object
  |
  +--com.keyoti.creditCard.logic.ejb.CreditCardBean

public abstract class CreditCardBean
extends Object
implements javax.ejb.EntityBean

CreditCardEJB Bean implementation class, mirrors CreditCard in functionality. Please consult the local (CreditCardLocal) and remote (CreditCard) component interfaces for general usage information.

Author:
Keyoti
See Also:
Serialized Form

Field Summary
protected  String cardVerificationNumber
          The card verification number, this is not persisted.
protected  javax.ejb.EntityContext context
           
 
Constructor Summary
CreditCardBean()
           
 
Method Summary
 void ejbActivate()
           
 String ejbCreate(String cardNumber)
           
 void ejbLoad()
           
 void ejbPassivate()
           
 void ejbPostCreate(String cardNumber)
           
 void ejbRemove()
           
 void ejbStore()
           
 String[] getBillingAddress()
          Gets the card billing address
 String getCardName()
          Gets the card name
 String getCardNumber()
          Gets the card number
 CardType getCardType()
          Gets the card type
 String getCardVerificationNumber()
          Gets the Card Verification Number, this is not be stored in long term persistence.
 String getComments()
          Gets the card comments
 Integer getExpiryMonth()
          Gets the expiry month
 Integer getExpiryYear()
          Gets the expiry year
abstract  String[] getIntBillingAddress()
          Gets the card billing address.
abstract  String getIntCardName()
          Gets the card owners name.
abstract  String getIntCardNumber()
          Gets the card number.
abstract  CardType getIntCardType()
          Gets the card type.
abstract  String getIntComments()
          Gets the card comments.
abstract  Integer getIntExpiryMonth()
          Gets the card expiry month (1->12).
abstract  Integer getIntExpiryYear()
          Gets the card expiry year (0->99).
abstract  Integer getIntIssueNumber()
          Gets the card issue number.
abstract  String getIntIssuer()
          Gets the card issuer.
abstract  Integer getIntStartMonth()
          Gets the card start month (1->12).
abstract  Integer getIntStartYear()
          Gets the card start year (0->99).
 Integer getIssueNumber()
          Gets the issue number
 String getIssuer()
          Gets the card issuer
 Integer getStartMonth()
          Gets the start month
 Integer getStartYear()
          Gets the start year
 boolean isCardNameValid()
          Determines if the card holders name is valid, this is a very simple method, that just checks if the card name field is longer than 0 chars and not null.
 boolean isCardNumberValid()
          Determines if the card number is valid, according to a MOD10 check and character validity check.
 boolean isCardTypeValid()
          Determines if the card type corresponds with the credit card number.
 boolean isCardVerificationNumberValid()
          Determines if the card verification number is 3 or 4 digits long and only includes numeric characters.
 boolean isExpiryMonthValid()
          Determines if the expiry month is valid, simply by checking that it is between 1 and 12 inclusive.
 boolean isExpiryYearValid()
          Determines if the expiry year is valid , simply by checking that it is between 0 and 99 inclusive (since credit card expiry dates are 2 digits long).
 boolean isMinimumValid()
          Convenience method, checks that card number, expiry date, type and card name are valid.
 boolean isStartMonthValid()
          Determines if the start month is valid, simply by checking that it is between 1 and 12 inclusive.
 boolean isStartYearValid()
          Determines if the start year is valid , simply by checking that it is between 0 and 99 inclusive (since credit card start dates are 2 digits long).
 void setBillingAddress(String[] billingAddress)
          Sets the card billingAddress array.
 void setCardName(String cardName)
          Sets the card owners name.
 void setCardType(CardType cardType)
          Sets the card type.
 void setCardVerificationNumber(String cvn)
          Sets the Card Verification Number (CVN), this is NOT stored in long term persistence.
 void setComments(String comments)
          Sets the card comments.
 void setEntityContext(javax.ejb.EntityContext ctx)
           
 void setExpiryMonth(int expiryMonth)
          Sets the card expiry date month, using setExpiryMonth(Integer).
 void setExpiryMonth(Integer expiryMonth)
          Sets the card expiry date month.
 void setExpiryYear(int expiryYear)
          Sets the card expiry date year, using setExpiryYear(Integer).
 void setExpiryYear(Integer expiryYear)
          Sets the card expiry date year, because credit cards usually specify 2 digit year values this is mirrored here.
abstract  void setIntBillingAddress(String[] billingAddress)
          Sets the card billing address.
abstract  void setIntCardName(String cardName)
          Sets the card owners name.
abstract  void setIntCardNumber(String cardNumber)
          Sets the card number.
abstract  void setIntCardType(CardType type)
          Sets the card type.
abstract  void setIntComments(String comments)
          Sets the card comments.
abstract  void setIntExpiryMonth(Integer month)
          Sets the card expiry month (1->12).
abstract  void setIntExpiryYear(Integer year)
          Sets the card expiry year (0->99).
abstract  void setIntIssueNumber(Integer iN)
          Sets the card issue number.
abstract  void setIntIssuer(String issuer)
          Sets the card issuer.
abstract  void setIntStartMonth(Integer month)
          Sets the card start month (1->12).
abstract  void setIntStartYear(Integer year)
          Sets the card start year (0->99).
 void setIssueNumber(int issueNumber)
          Sets the card issue number, using setIssueNumber(Integer).
 void setIssueNumber(Integer issueNumber)
          Sets the card issue number.
 void setIssuer(String issuer)
          Sets the card issuer's name.
 void setStartMonth(int startMonth)
          Sets the card start date month, using setStartMonth(Integer).
 void setStartMonth(Integer startMonth)
          Sets the card start date month.
 void setStartYear(int startYear)
          Sets the card start date year, using setStartYear(Integer).
 void setStartYear(Integer startYear)
          Sets the card start date year, because credit cards usually specify 2 digit year values this is mirrored here.
 void unsetEntityContext()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

context

protected javax.ejb.EntityContext context

cardVerificationNumber

protected String cardVerificationNumber
The card verification number, this is not persisted.
See Also:
setCardVerificationNumber(java.lang.String)
Constructor Detail

CreditCardBean

public CreditCardBean()
Method Detail

getIntCardNumber

public abstract String getIntCardNumber()
Gets the card number. This is an internally used method required by CMP2.0 and is not present in the local or remote component interface.

getIntExpiryMonth

public abstract Integer getIntExpiryMonth()
Gets the card expiry month (1->12). This is an internally used method required by CMP2.0 and is not present in the local or remote component interface.

getIntExpiryYear

public abstract Integer getIntExpiryYear()
Gets the card expiry year (0->99). This is an internally used method required by CMP2.0 and is not present in the local or remote component interface.

getIntStartMonth

public abstract Integer getIntStartMonth()
Gets the card start month (1->12). This is an internally used method required by CMP2.0 and is not present in the local or remote component interface.

getIntStartYear

public abstract Integer getIntStartYear()
Gets the card start year (0->99). This is an internally used method required by CMP2.0 and is not present in the local or remote component interface.

getIntIssueNumber

public abstract Integer getIntIssueNumber()
Gets the card issue number. This is an internally used method required by CMP2.0 and is not present in the local or remote component interface.

getIntCardName

public abstract String getIntCardName()
Gets the card owners name. This is an internally used method required by CMP2.0 and is not present in the local or remote component interface.

getIntCardType

public abstract CardType getIntCardType()
Gets the card type. This is an internally used method required by CMP2.0 and is not present in the local or remote component interface.

getIntIssuer

public abstract String getIntIssuer()
Gets the card issuer. This is an internally used method required by CMP2.0 and is not present in the local or remote component interface.

getIntComments

public abstract String getIntComments()
Gets the card comments. This is an internally used method required by CMP2.0 and is not present in the local or remote component interface.

getIntBillingAddress

public abstract String[] getIntBillingAddress()
Gets the card billing address. This is an internally used method required by CMP2.0 and is not present in the local or remote component interface.

setIntCardNumber

public abstract void setIntCardNumber(String cardNumber)
Sets the card number. This is an internally used method required by CMP2.0 and is not present in the local or remote component interface.

setIntExpiryMonth

public abstract void setIntExpiryMonth(Integer month)
Sets the card expiry month (1->12). This is an internally used method required by CMP2.0 and is not present in the local or remote component interface.

setIntExpiryYear

public abstract void setIntExpiryYear(Integer year)
Sets the card expiry year (0->99). This is an internally used method required by CMP2.0 and is not present in the local or remote component interface.

setIntStartMonth

public abstract void setIntStartMonth(Integer month)
Sets the card start month (1->12). This is an internally used method required by CMP2.0 and is not present in the local or remote component interface.

setIntStartYear

public abstract void setIntStartYear(Integer year)
Sets the card start year (0->99). This is an internally used method required by CMP2.0 and is not present in the local or remote component interface.

setIntIssueNumber

public abstract void setIntIssueNumber(Integer iN)
Sets the card issue number. This is an internally used method required by CMP2.0 and is not present in the local or remote component interface.

setIntCardName

public abstract void setIntCardName(String cardName)
Sets the card owners name. This is an internally used method required by CMP2.0 and is not present in the local or remote component interface.

setIntCardType

public abstract void setIntCardType(CardType type)
Sets the card type. This is an internally used method required by CMP2.0 and is not present in the local or remote component interface.

setIntIssuer

public abstract void setIntIssuer(String issuer)
Sets the card issuer. This is an internally used method required by CMP2.0 and is not present in the local or remote component interface.

setIntComments

public abstract void setIntComments(String comments)
Sets the card comments. This is an internally used method required by CMP2.0 and is not present in the local or remote component interface.

setIntBillingAddress

public abstract void setIntBillingAddress(String[] billingAddress)
Sets the card billing address. This is an internally used method required by CMP2.0 and is not present in the local or remote component interface.

getCardNumber

public String getCardNumber()
Gets the card number

getCardName

public String getCardName()
Gets the card name

getCardType

public CardType getCardType()
Gets the card type

getExpiryMonth

public Integer getExpiryMonth()
Gets the expiry month

getExpiryYear

public Integer getExpiryYear()
Gets the expiry year

getIssueNumber

public Integer getIssueNumber()
Gets the issue number

getStartMonth

public Integer getStartMonth()
Gets the start month

getStartYear

public Integer getStartYear()
Gets the start year

getComments

public String getComments()
Gets the card comments

getIssuer

public String getIssuer()
Gets the card issuer

getBillingAddress

public String[] getBillingAddress()
Gets the card billing address

getCardVerificationNumber

public String getCardVerificationNumber()
Gets the Card Verification Number, this is not be stored in long term persistence. It is a misuse to store this number because it is intended that it be verified by the issuer and not be held any where other than on the physical card.

setCardName

public void setCardName(String cardName)
Sets the card owners name.
Returns:
void
Throws:
NullPointerException - if cardName is null.
Preconditions:
cardName != null
Postconditions:
getCardName() == cardName

setCardType

public void setCardType(CardType cardType)
Sets the card type.
Returns:
void
Throws:
NullPointerException - if cardType is null.
Preconditions:
cardType != null
Postconditions:
getCardType() == cardType

setExpiryMonth

public void setExpiryMonth(Integer expiryMonth)
                    throws NullPointerException,
                           IllegalArgumentException
Sets the card expiry date month.
Returns:
void
Throws:
NullPointerException - if expiryMonth is null.
IllegalArgumentException - if 0 < expiryMonth <= 12 is not true.
Preconditions:
expiryMonth != null AND expiryMonth >= 1 AND expiryMonth <= 12
Postconditions:
getExpiryMonth() == expiryMonth AND isExpiryMonthValid() == true

setExpiryYear

public void setExpiryYear(Integer expiryYear)
Sets the card expiry date year, because credit cards usually specify 2 digit year values this is mirrored here. Expiry year must be between 0 and 99 inclusive, otherwise an IllegalArgumentException is thrown.
Returns:
void
Throws:
NullPointerException - if expiryYear is null.
IllegalArgumentException - if 0 <= expiryYear <= 99 is not true
Preconditions:
expiryYear != null AND expiryYear >= 0 AND expiryYear <= 99
Postconditions:
getExpiryYear() == expiryYear AND isExpiryYearValid() == true

setStartMonth

public void setStartMonth(Integer startMonth)
                   throws NullPointerException,
                          IllegalArgumentException
Sets the card start date month.
Returns:
void
Throws:
NullPointerException - if startMonth is null.
IllegalArgumentException - if 0 < startMonth <= 12 is not true.
Preconditions:
startMonth != null AND startMonth >= 1 AND startMonth <= 12
Postconditions:
getStartMonth() == startMonth AND isStartMonthValid() == true

setStartYear

public void setStartYear(Integer startYear)
Sets the card start date year, because credit cards usually specify 2 digit year values this is mirrored here. Start year must be between 0 and 99 inclusive, otherwise an IllegalArgumentException is thrown.
Returns:
void
Throws:
NullPointerException - if startYear is null.
IllegalArgumentException - if 0 <= startYear <= 99 is not true
Preconditions:
startYear != null AND startYear >= 0 AND startYear <= 99
Postconditions:
getStartYear() == startYear AND isStartYearValid() == true

setIssueNumber

public void setIssueNumber(Integer issueNumber)
Sets the card issue number.
Returns:
void
Throws:
NullPointerException - if issueNumber is null.
IllegalArgumentException - if 0 <= issueNumber <= 999 is not true.
Preconditions:
issueNumber != null AND issueNumber >=0 AND issueNumber <= 999
Postconditions:
getIssueNumber() == issueNumber

setExpiryMonth

public void setExpiryMonth(int expiryMonth)
                    throws IllegalArgumentException
Sets the card expiry date month, using setExpiryMonth(Integer).
Throws:
IllegalArgumentException - if 1<=expiryMonth<=12 is not true.
See Also:
setExpiryMonth(Integer)

setExpiryYear

public void setExpiryYear(int expiryYear)
                   throws IllegalArgumentException
Sets the card expiry date year, using setExpiryYear(Integer).
Throws:
IllegalArgumentException - if 0<=expiryYear<=99 is not true.
See Also:
setExpiryYear(Integer)

setStartMonth

public void setStartMonth(int startMonth)
                   throws IllegalArgumentException
Sets the card start date month, using setStartMonth(Integer).
Throws:
IllegalArgumentException - if 1<=startMonth<=12 is not true.
See Also:
setStartMonth(Integer)

setStartYear

public void setStartYear(int startYear)
                  throws IllegalArgumentException
Sets the card start date year, using setStartYear(Integer).
Throws:
IllegalArgumentException - if 0<=startYear<=99 is not true.
See Also:
setStartYear(Integer)

setIssueNumber

public void setIssueNumber(int issueNumber)
                    throws IllegalArgumentException
Sets the card issue number, using setIssueNumber(Integer).
Throws:
IllegalArgumentException - if 0<=issueNumber<=999 is not true.
See Also:
setIssueNumber(Integer)

setCardVerificationNumber

public void setCardVerificationNumber(String cvn)
                               throws IllegalArgumentException,
                                      NullPointerException
Sets the Card Verification Number (CVN), this is NOT stored in long term persistence. It is a misuse to store this number because it is intended that it be verified by the issuer and not be held any where other than on the physical card. The CVN must be either 3 or 4 digits in length or empty.
Parameters:
cvn - the card verification number String.
Returns:
void
Throws:
NullPointerException - if cvn is null.
IllegalArgumentException - if cvn is not 3 or 4 numeric characters or an empty String.
Preconditions:
cvn != null AND ((3 <= cvn.length() <= 4 AND cvn.equals(LuhnChecker.getDigitsOnly(cvn))) OR cvn == "" )
Postconditions:
getCardVerificationNumber() == cvn

setIssuer

public void setIssuer(String issuer)
Sets the card issuer's name. Notifies any property change listeners if new value is different to the current value.
Returns:
void
Throws:
NullPointerException - if issuer is null.
Preconditions:
issuer != null
Postconditions:
getIssuer() == issuer

setComments

public void setComments(String comments)
Sets the card comments. Notifies any property change listeners if new value is different to the current value.
Returns:
void
Throws:
NullPointerException - if comments is null.
Preconditions:
comments != null
Postconditions:
getComments() == comments

setBillingAddress

public void setBillingAddress(String[] billingAddress)
Sets the card billingAddress array. Notifies any property change listeners if new value is different to the current value.
Returns:
void
Throws:
NullPointerException - if billingAddress is null.
IllegalArgumentException - if billingAddress.length > 5
Preconditions:
billingAddress != null
Postconditions:
getBillingAddress() == billingAddress

isCardNumberValid

public boolean isCardNumberValid()
Determines if the card number is valid, according to a MOD10 check and character validity check.
Returns:
true if the card number is valid, false if the card number is not valid (or has not been set yet).
Postconditions:
return == LuhnChecker.isValid(getCardNumber())

isCardNameValid

public boolean isCardNameValid()
Determines if the card holders name is valid, this is a very simple method, that just checks if the card name field is longer than 0 chars and not null.
Returns:
true if the card name field is a String with length > 0, false otherwise (including if null)
Postconditions:
return == getCardName().length() > 0

isStartMonthValid

public boolean isStartMonthValid()
Determines if the start month is valid, simply by checking that it is between 1 and 12 inclusive.

isStartYearValid

public boolean isStartYearValid()
Determines if the start year is valid , simply by checking that it is between 0 and 99 inclusive (since credit card start dates are 2 digits long).

isExpiryMonthValid

public boolean isExpiryMonthValid()
Determines if the expiry month is valid, simply by checking that it is between 1 and 12 inclusive.

isExpiryYearValid

public boolean isExpiryYearValid()
Determines if the expiry year is valid , simply by checking that it is between 0 and 99 inclusive (since credit card expiry dates are 2 digits long).

isCardTypeValid

public boolean isCardTypeValid()
Determines if the card type corresponds with the credit card number. Each card type has a pattern defined for the card number to obey, eg; MasterCard cards start "51xxxx"
Returns:
true if the card type is correct, false otherwise
See Also:
CardType

isCardVerificationNumberValid

public boolean isCardVerificationNumberValid()
Determines if the card verification number is 3 or 4 digits long and only includes numeric characters. Note: that only the card processor can determine if the card verification number is truly 'valid', this only provides pre-processing checks.
Returns:
true if card verification number is 3 or 4 digits long, false otherwise (including if getCardVerificationNumber() is null).
Postconditions:
return == (true AND getCardVerificationNumber() != null AND 3 <= getCardVerificationNumber().length() <= 4 AND LuhnChecker.getDigitsOnly(getCardVerificationNumber()).equals(getCardVerificationNumber())) OR false

isMinimumValid

public boolean isMinimumValid()
Convenience method, checks that card number, expiry date, type and card name are valid. Calls isCardNumberValid(), isExpiryMonthValid(), isExpiryYearValid(), isCardNameValid() and isCardTypeValid(). Fields are determined as valid according to the individual methods.
Returns:
true if all fields are valid, false otherwise.

ejbCreate

public String ejbCreate(String cardNumber)
                 throws javax.ejb.CreateException

ejbPostCreate

public void ejbPostCreate(String cardNumber)

ejbRemove

public void ejbRemove()
Specified by:
ejbRemove in interface javax.ejb.EntityBean

ejbActivate

public void ejbActivate()
Specified by:
ejbActivate in interface javax.ejb.EntityBean

ejbPassivate

public void ejbPassivate()
Specified by:
ejbPassivate in interface javax.ejb.EntityBean

setEntityContext

public void setEntityContext(javax.ejb.EntityContext ctx)
Specified by:
setEntityContext in interface javax.ejb.EntityBean

unsetEntityContext

public void unsetEntityContext()
Specified by:
unsetEntityContext in interface javax.ejb.EntityBean

ejbLoad

public void ejbLoad()
Specified by:
ejbLoad in interface javax.ejb.EntityBean

ejbStore

public void ejbStore()
Specified by:
ejbStore in interface javax.ejb.EntityBean

CreditCardPack

Copyright © 2002 Keyoti All Rights Reserved.