net.sourceforge.barbecue
Class Modulo10

java.lang.Object
  extended bynet.sourceforge.barbecue.Modulo10

public class Modulo10
extends java.lang.Object

Modulo 10 Check Sum class.

Author:
James Jenner

Method Summary
static int getMod10CheckDigit(java.lang.String data, int weightOdd)
          Calculates a modulo 10 check digit based on the passed numeric data.
static int getMod10CheckDigit(java.lang.String data, int weightEven, int weightOdd)
          Calculates a modulo 10 check digit based on the passed numeric data.
static int getMod10CheckDigit(java.lang.String data, int weightEven, int weightOdd, boolean beginsEven)
          Calculates a modulo 10 check digit based on the passed numeric data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getMod10CheckDigit

public static int getMod10CheckDigit(java.lang.String data,
                                     int weightEven,
                                     int weightOdd,
                                     boolean beginsEven)
                              throws java.lang.NumberFormatException
Calculates a modulo 10 check digit based on the passed numeric data. The calculated check sum is determined using the weighted values, if there is a need for no weight to be applied against the odd and/or even characters then use the value 1. If a non-numeric value is within the data then NumberFormatException will be thrown.

Parameters:
data - The data to encode into a Modulo 10 check digit
weightEven - Every even digit will be multiplied by this value
weightOdd - Every odd digit will be multiplied by this value
beginsEven - true if the first numeric data is to be treated as even, false if the first digit is to be treated as odd
Returns:
the numeric value of the check digit calculated
Throws:
java.lang.NumberFormatException
See Also:
getMod10CheckDigit(String, int, int), getMod10CheckDigit(String, int)

getMod10CheckDigit

public static int getMod10CheckDigit(java.lang.String data,
                                     int weightEven,
                                     int weightOdd)
                              throws java.lang.NumberFormatException
Calculates a modulo 10 check digit based on the passed numeric data. The calculated check sum is determined using the weighted values, if there is a need for no weight to be applied against the odd and/or even characters then use the value 1. If a non-numeric value is within the data then NumberFormatException will be thrown. The first value of data is treated as even.

Parameters:
data - The data to encode into a Modulo 10 check digit
weightEven - Every even digit will be multiplied by this value
weightOdd - Every odd digit will be multiplied by this value false if the first digit is to be treated as odd
Returns:
the numeric value of the check digit calculated
Throws:
java.lang.NumberFormatException
See Also:
getMod10CheckDigit(String, int)

getMod10CheckDigit

public static int getMod10CheckDigit(java.lang.String data,
                                     int weightOdd)
                              throws java.lang.NumberFormatException
Calculates a modulo 10 check digit based on the passed numeric data. The only weight available is odd, this is a common usage. If a non-numeric value is within the data then NumberFormatException will be thrown. The first value of data is treated as even.

Parameters:
data - The data to encode into a Modulo 10 check digit
weightOdd - Every odd digit will be multiplied by this value
Returns:
the numeric value of the check digit calculated
Throws:
java.lang.NumberFormatException
See Also:
getMod10CheckDigit(String, int, int)


Copyright © 2003-2007 barbecue.sourceforge.net. All Rights Reserved.