dgraham     2003/06/08 14:53:38

  Modified:    validator/src/share/org/apache/commons/validator
                        CreditCardValidator.java
  Log:
  Fixed urls and made minor changes to luhnCheck.
  
  Revision  Changes    Path
  1.8       +11 -14    
jakarta-commons/validator/src/share/org/apache/commons/validator/CreditCardValidator.java
  
  Index: CreditCardValidator.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/validator/src/share/org/apache/commons/validator/CreditCardValidator.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- CreditCardValidator.java  8 Jun 2003 21:32:29 -0000       1.7
  +++ CreditCardValidator.java  8 Jun 2003 21:53:38 -0000       1.8
  @@ -71,9 +71,10 @@
    * <code>CreditCardValidator ccv = new CreditCardValidator(CreditCardValidator.AMEX 
+ CreditCardValidator.VISA);</code>
    * configures the validator to only pass American Express and Visa cards. 
    * </p>
  - * Reference Sean M. Burke's 
  - * <a href="http://www.ling.nwu.edu/~sburke/pub/luhn_lib.pl";>script</a>.  More 
information
  - * also available <a href="http://www.merriampark.com/anatomycc.htm";>here</a>.
  + * For a similar implementation in Perl, reference Sean M. Burke's 
  + * <a href="http://www.speech.cs.cmu.edu/~sburke/pub/luhn_lib.html";>script</a>.  
  + * More information is also available 
  + * <a href="http://www.merriampark.com/anatomycc.htm";>here</a>.
    *
    * @author David Winterfeldt
    * @author James Turner
  @@ -176,7 +177,7 @@
        protected boolean luhnCheck(String cardNumber) {
                // number must be validated as 0..9 numeric first!!
                int digits = cardNumber.length();
  -             int oddoeven = digits & 1;
  +             int oddOrEven = digits & 1;
                long sum = 0;
                for (int count = 0; count < digits; count++) {
                        int digit = 0;
  @@ -187,7 +188,7 @@
                                return false;
                        }
   
  -                     if (((count & 1) ^ oddoeven) == 0) { // not
  +                     if (((count & 1) ^ oddOrEven) == 0) { // not
                                digit *= 2;
                                if (digit > 9) {
                                        digit -= 9;
  @@ -200,11 +201,7 @@
                        return false;
                }
   
  -             if (sum % 10 == 0) {
  -                     return true;
  -             }
  -
  -             return false;
  +             return (sum % 10 == 0);
        }
   
        /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to