org.thc.shagg
Class Factory

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

public class Factory
extends java.lang.Object

This class is a factory that generates serial numbers. Information necessary are obtained from the supplied states file. Additionally a prefix can be specified to obtain more "natural" numbers.

Version:
$Id: Factory.java,v 1.4 2003/07/18 10:08:05 plasmoid Exp $
Author:
Plasmoid (plasmoid@thc.org), THC

Field Summary
private  CheckDigitAlgorithm[] algorithms
           
private  int length
           
private  int numbers
           
private  int[] prefix
           
private  State[] states
           
 
Constructor Summary
Factory(java.lang.String filename)
          Construct a factoy.
 
Method Summary
 int[] randomNumber()
          Generate a random number.
 void work()
          Generate serial numbers.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

states

private State[] states

numbers

private int numbers

length

private int length

algorithms

private CheckDigitAlgorithm[] algorithms

prefix

private int[] prefix
Constructor Detail

Factory

public Factory(java.lang.String filename)
Construct a factoy. Read in the states file and generate the requested amount of serial numbers.
Parameters:
filename - Filename of states
num - Amount of serial numbers to generate
Method Detail

work

public void work()
Generate serial numbers. This is currently a rather simple method. No real intelligence. The code generate random numbers and checks if they match the different states read from the filename provided to the construcor. If all states match, the numbers is printed to STDOUT.

randomNumber

public int[] randomNumber()
Generate a random number.
Parameters:
length - of number
Returns:
number as an array