ThinkUI Data Generator 1.0.2 API

thinkui.datagen.util
Class Luhn

java.lang.Object
  extended bythinkui.datagen.util.Luhn

public class Luhn
extends java.lang.Object

Implement the Luhn algorithm for checking validitity of values such as: SIN, credit card numbers, etc.


Constructor Summary
Luhn()
           
 
Method Summary
static int calcRemainder(java.lang.String number)
          Compute the remainder of the remainder of the number according to the Luhn algorithm.
static boolean isValid(java.lang.String number)
          Checks whether a string of digits is valid according to the Luhn algorithm.
static void main(java.lang.String[] args)
          Main entry point for the test harness.
static java.lang.String makeValid(java.lang.String number)
          Checks whether a string of digits is valid according to the Luhn algorithm.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Luhn

public Luhn()
Method Detail

calcRemainder

public static final int calcRemainder(java.lang.String number)
Compute the remainder of the remainder of the number according to the Luhn algorithm. If an empty string is specified, then 0 will be returned.

Parameters:
number - the String of digits to compute the Luhn remainder.
Returns:
the remainder as computed by the Luhn algorithm

isValid

public static final boolean isValid(java.lang.String number)
Checks whether a string of digits is valid according to the Luhn algorithm.

Parameters:
number - the String of digits to validate according the Luhn remainder.

main

public static final void main(java.lang.String[] args)
Main entry point for the test harness.

Parameters:
args - the command line arguments.

makeValid

public static final java.lang.String makeValid(java.lang.String number)
Checks whether a string of digits is valid according to the Luhn algorithm. If the input is not valid, the last digit is modified to correct the input.

Parameters:
number - the String of digits to validate according the Luhn remainder.
Returns:
the corrected digits that is valid according the Luhn remainder.

ThinkUI Data Generator 1.0.2 API

Copyright © 2007-2009. ThinkUI Software Inc. All rights reserved.