hcrypto.analyzer
Class CryptoAnalyzer

java.lang.Object
  extended by hcrypto.analyzer.CryptoAnalyzer
All Implemented Interfaces:
Analyzer, java.lang.Runnable
Direct Known Subclasses:
AffineAnalyzer, CaesarAnalyzer, DigramAnalyzer, EnglishFacts, GaAnalyzer, NullAnalyzer, TestAnalyzer, VigenereAnalyzer, WordBasedAnalyzer

public class CryptoAnalyzer
extends java.lang.Object
implements Analyzer, java.lang.Runnable

Serves as the foundation for all cryptologic analyzers, including GA analyzers. It should be subclassed with a class containing extensions of its run() and setup() methods.


Field Summary
static int PERMUTATION
           
static int PLAYFAIR
           
static int RAILFENCE
           
static int SIMPLESUB
           
 
Fields inherited from interface hcrypto.analyzer.Analyzer
DECIPHER_LIMIT
 
Constructor Summary
CryptoAnalyzer()
          CryptoAnalyzer() -- Default constructor
CryptoAnalyzer(GaParameters params)
          CryptoAnalyzer() -- this constructor is given an object containing parameter settings
 
Method Summary
 java.lang.String getReport()
          Part of Analyzer interface.
static java.lang.String prettyPrint(java.lang.String s, int linelen)
          Inserts line breaks into a string.
 void run()
          Part of Analyzer and Runnable interface.
 void setup(java.lang.String text)
          setup() initializes the text and the result string.
 void setup(java.lang.String text, AnalyzerFrame f)
          setup() -- this version of setup was added to make the analyzer compatible with CryptoToolJ.
 void stopThread()
          Stops the analyzer.
 boolean threadIsStopped()
           
 java.lang.String toString()
          Every class should have a toString() method.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SIMPLESUB

public static final int SIMPLESUB
See Also:
Constant Field Values

PERMUTATION

public static final int PERMUTATION
See Also:
Constant Field Values

RAILFENCE

public static final int RAILFENCE
See Also:
Constant Field Values

PLAYFAIR

public static final int PLAYFAIR
See Also:
Constant Field Values
Constructor Detail

CryptoAnalyzer

public CryptoAnalyzer()
CryptoAnalyzer() -- Default constructor


CryptoAnalyzer

public CryptoAnalyzer(GaParameters params)
CryptoAnalyzer() -- this constructor is given an object containing parameter settings

Parameters:
params - -- an object containing param1=val1 param2=val2 ...
Method Detail

setup

public void setup(java.lang.String text,
                  AnalyzerFrame f)
setup() -- this version of setup was added to make the analyzer compatible with CryptoToolJ. It assigns the analyzer a window to display its results.


setup

public void setup(java.lang.String text)
setup() initializes the text and the result string. Note that for files containing test cryptograms, the solution is sometimes also provided following the $$$ marker.

Specified by:
setup in interface Analyzer

run

public void run()
Part of Analyzer and Runnable interface. Override this method in the subclass.

Specified by:
run in interface Analyzer
Specified by:
run in interface java.lang.Runnable

stopThread

public void stopThread()
Stops the analyzer. Part of Analyzer interface. Override this method in the subclass.


threadIsStopped

public boolean threadIsStopped()

getReport

public java.lang.String getReport()
Part of Analyzer interface.

Specified by:
getReport in interface Analyzer

toString

public java.lang.String toString()
Every class should have a toString() method.

Overrides:
toString in class java.lang.Object

prettyPrint

public static java.lang.String prettyPrint(java.lang.String s,
                                           int linelen)
Inserts line breaks into a string.

Parameters:
s - the string
linelen - the length of the line
Returns:
the input string with linebreaks inserted every linelen characters (roughly)