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

ISBN.java

Go to the documentation of this file.
00001 package net.threebit.utils.sosc ; 
00002 
00008 public class ISBN extends Validatable
00009 {   
00017     public ISBN(final String isbn)
00018     {
00019         super(isbn, "ISBN");
00020     }
00021 
00030         public boolean equals(Object o)
00031     {
00032        if (!(o instanceof ISBN))
00033        {
00034            return (false);
00035        }
00036        return (super.equals(o));
00037     }
00038 
00047     protected boolean checkDigits(final int[] digits)
00048     {
00049         int sum;
00050 
00051         sum = 0;                       
00052 
00053         for(int i = 0; i < (number.length() - 1); i++)
00054         {
00055             sum += digits[i] * (i + 1);
00056         }
00057                     
00058         if ((sum % 11) == digits[number.length() - 1])
00059         {
00060             return(true);
00061         }
00062         return (false);
00063     }
00064     
00072     public static boolean validate(String num)
00073     {             
00074         return (new ISBN(num).validate());
00075     }
00076     
00083     protected boolean checkSize()
00084     {
00085         return (10 == number.length());
00086     }
00087 }

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