org.thc.shagg
Class Laboratory

java.lang.Object
  |
  +--org.thc.shagg.Laboratory

public class Laboratory
extends java.lang.Object

This class is the laboratoy of THC-Shagg. The provided filename is loaded and parsed. The set of of retrieved serial numbers gets brute- forced with all implemented check digit algorithms, weights and partitions.

Version:
$Id: Laboratory.java,v 1.3 2003/07/18 10:08:05 plasmoid Exp $
Author:
Plasmoid (plasmoid@thc.org), THC
See Also:
CheckDigitAlgorithm

Field Summary
private  CheckDigitAlgorithm[] algorithms
           
private  PartitionSet partitionSet
           
private  int[][] serialNumbers
           
private  WeightSet weightSet
           
 
Constructor Summary
Laboratory(java.lang.String filename)
          Construct a shaggadalic object using the serial numbers from the provided file.
 
Method Summary
private  int[][] readSerialNumberFile(java.lang.String filename)
          Read all numbers from the given file.
 void work()
          Bruteforce through the serial numbers.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

algorithms

private CheckDigitAlgorithm[] algorithms

weightSet

private WeightSet weightSet

partitionSet

private PartitionSet partitionSet

serialNumbers

private int[][] serialNumbers
Constructor Detail

Laboratory

public Laboratory(java.lang.String filename)
Construct a shaggadalic object using the serial numbers from the provided file. If the file doesn't contain serial numbers or numbers of mixed type, Shagg will abort.
Parameters:
filename - File containing serial numbers of the same type.
Method Detail

readSerialNumberFile

private int[][] readSerialNumberFile(java.lang.String filename)
Read all numbers from the given file. This method looks for serial numbers in each line of the file. Non- digits are ignored and comments can be added to the file using the common tags "#" and ";". The length of the serial numbers is determined automatically. In case the user has already specified a length, it is check against the automatic one.
Parameters:
filename - Filename containing serial numbers.
Returns:
Array of serial numbers.

work

public void work()
Bruteforce through the serial numbers. This is the laboratories work horse. As described above every algorithm, weight, partition is checked against every number. Every combination that matches is called a "state" and stored in a red-black-tree (can be any databstructure with efficient insertion and searching, e.g. O(lg n).

After collecting all states, states that donnot match all serial number (failure tolerance may change this) are removed. In case the collection gets to be before the end, an emergency clear is issued.