|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.thehackerschoice.shagg.State
This class represents a state during the analysis of a set of serial a number. A state holds information about the used amount of serial numbers, algorithm, weights, and partition that matched a serial number. During further progress the hits of a state are increased if he matches another serial number.
In order to store the states in an efficient data structure this class implements the interface comparable and the states may be stored in a tree map or any other sorted map that sorts on comparable objects.
Field Summary | |
private int |
algorithm
|
private int |
amount
|
private int |
hits
|
private java.lang.String |
id
|
private int[] |
partition
|
private int[] |
weights
|
Constructor Summary | |
State(int[] w,
int a,
int[] p,
int l)
Construct a state. |
Method Summary | |
boolean |
check(int[] number,
CheckDigitAlgorithm[] a)
Checks a serial number against the data from this state. |
static java.util.Vector |
clear(java.util.Map t,
int limit)
Clear map from states that don't have enough hits. |
int |
compareTo(java.lang.Object s)
Compares two states. |
boolean |
equals(State s)
Check if two states are equal. |
private java.lang.String |
generateUniqueId()
Generates a unique id. |
int |
getAlgorithm()
Get algorithm of this state. |
int |
getAmout()
Get amount of serial numbers that were used generarting this state. |
int |
getHits()
Get hit counter. |
java.lang.String |
getId()
Get the unique id of this state. |
int |
getLength()
Get length of serial number. |
int[] |
getPartition()
Get partition of this state. |
int[] |
getWeights()
Get weights of this state. |
void |
hit()
Hit! Increase hit counter. |
void |
hit(java.util.Map t)
Find a state in a map and give it a hit. |
static State |
load(java.lang.String filename)
Load a state from a file. |
static java.util.Vector |
loadVector(java.lang.String filename)
Load vector of states from a file. |
void |
print(CheckDigitAlgorithm[] algorithms)
Print state. |
void |
save(java.lang.String filename)
Save a state to a file. |
static void |
saveVector(java.lang.String filename,
java.util.Vector v)
Save a vector of states to a file. |
Methods inherited from class java.lang.Object |
|
Field Detail |
private int[] weights
private int[] partition
private int algorithm
private int amount
private int hits
private java.lang.String id
Constructor Detail |
public State(int[] w, int a, int[] p, int l)
w
- Weights that matched.a
- Number of algorithm that matched.p
- Partition that matched.l
- Length of serial numberMethod Detail |
private java.lang.String generateUniqueId()
compareTo(java.lang.Object)
public void hit()
public int getAmout()
public int getHits()
public java.lang.String getId()
public int[] getWeights()
public int getAlgorithm()
public int[] getPartition()
public int getLength()
public boolean equals(State s)
s
- State to compare with this state.String.equals(java.lang.Object)
public int compareTo(java.lang.Object s)
s
- State to compare with this state.String.compareTo(java.lang.Object)
public void hit(java.util.Map t)
t
- MapMap
,
SortedMap
public static java.util.Vector clear(java.util.Map t, int limit)
t
- Map.limit
- Limit for hits.public void print(CheckDigitAlgorithm[] algorithms)
algorithms
- Array of check digit algorithmsnum
- Length of the serial number.CheckDigitAlgorithm
public static State load(java.lang.String filename) throws java.io.IOException, java.lang.ClassNotFoundException
filename
- Name of file.public void save(java.lang.String filename) throws java.io.IOException
filename
- Name of file.public static java.util.Vector loadVector(java.lang.String filename) throws java.io.IOException, java.lang.ClassNotFoundException
filename
- Name of file.public static void saveVector(java.lang.String filename, java.util.Vector v) throws java.io.IOException
filename
- Name of file.v
- Vector of states.public boolean check(int[] number, CheckDigitAlgorithm[] a)
number
- Serial numbera
- Check Digit algorithm to use
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |