Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

SIN.java

Go to the documentation of this file.
00001 package net.threebit.utils.sosc ; 
00002 
00008 public class SIN extends Validatable
00009 {
00017     public SIN(final String sin)
00018     {
00019        super(sin, "SIN");
00020     }
00021 
00030     public boolean equals(Object o)
00031     {
00032        if (!(o instanceof SIN))
00033        {
00034            return (false);
00035        }
00036        return (super.equals(o));
00037     }
00038         
00046     public static boolean validate(String num)
00047     {
00048          return(new SIN(num).validate());
00049     }
00050     
00060     protected boolean checkDigits(final int[] digits)
00061     {
00062         int sumEven;
00063         int sumOdd;
00064         int sum;
00065         
00066         sumEven = 0;
00067         sumOdd = 0;
00068         sum = 0;         
00069         
00070         for (int i = (number.length() - 2); i >= 0; i--)
00071         {
00076             if ((((number.length() - 2) - i) % 2) == 0)
00077             {
00078                 sumEven += Utils.add(digits[i] * 2);
00079             }
00080             else
00081             {
00082                 sumOdd += digits[i];
00083             }
00084         }
00085         
00086         sum = sumEven + sumOdd;
00087         
00088         while ((sum % 10) != 0)
00089         {
00090             sum++;
00091         }
00092         
00093         if ((sum - (sumEven + sumOdd)) == digits[number.length() - 1])
00094         {
00095             return(true);
00096         }
00097         return (false);
00098     }
00099         
00106     protected boolean checkSize()
00107     {
00108         return (9 == number.length());
00109     }
00110 }
00111 

Generated on Mon Jul 14 17:19:20 2003 for SOSC by doxygen1.2.15