hcrypto.analyzer
Class FrequencyTable

java.lang.Object
  |
  +--hcrypto.analyzer.FrequencyTable
All Implemented Interfaces:
Analyzer

public class FrequencyTable
extends java.lang.Object
implements Analyzer


Field Summary
static int MAX_CHARS
           
 
Fields inherited from interface hcrypto.analyzer.Analyzer
DECIPHER_LIMIT
 
Constructor Summary
FrequencyTable(java.lang.String text)
           
FrequencyTable(java.lang.String text, int alpha)
           
 
Method Summary
protected  java.lang.String charToString(char ch)
          Converts a nonprintable character to a string
 void count()
          Counts the characters in the text.
 int getAlphabeticsCount()
          Returns a count of just alphabetic characters
 int getCharCount()
          Returns a count of all characters.
 int getCount(int ch)
          Returns the count for a specific character
 FrequencyRecord[] getCryptogramFrequencies()
           
 int[] getFrequencies()
          returns the frequencies as an array
 int getHighestFreq()
          returns the highest frequency character
 int[] getHistogramData()
          Constructs an array of int out of the frequency tables
 java.lang.String getKHighestFreqChar(int k)
          returns the the kth highest frequency character
 java.lang.String getReport()
           
 FrequencyRecord[] getSortedCryptogramFrequencies()
           
 void print()
           
 void run()
          Everything is done in setup.
 void setAlphabetRange(int range)
          Sets alphabetRange to an ASCII subset.
 void setup(java.lang.String text)
          From the Analyzer interface.
protected  void sort()
          Uses the java.util.Arrays sort method to sort the frquencies and stores the results in sortedFrequencies.
 java.lang.String toString()
          Arranges the frequencies as a 2-D table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_CHARS

public static final int MAX_CHARS
Constructor Detail

FrequencyTable

public FrequencyTable(java.lang.String text)

FrequencyTable

public FrequencyTable(java.lang.String text,
                      int alpha)
Method Detail

setup

public void setup(java.lang.String text)
From the Analyzer interface.
Specified by:
setup in interface Analyzer

run

public void run()
Everything is done in setup.
Specified by:
run in interface Analyzer

getReport

public java.lang.String getReport()
Specified by:
getReport in interface Analyzer

setAlphabetRange

public void setAlphabetRange(int range)
Sets alphabetRange to an ASCII subset.

toString

public java.lang.String toString()
Arranges the frequencies as a 2-D table.
Overrides:
toString in class java.lang.Object

print

public void print()

count

public void count()
Counts the characters in the text.

getHighestFreq

public int getHighestFreq()
returns the highest frequency character

getKHighestFreqChar

public java.lang.String getKHighestFreqChar(int k)
returns the the kth highest frequency character

getCryptogramFrequencies

public FrequencyRecord[] getCryptogramFrequencies()

getSortedCryptogramFrequencies

public FrequencyRecord[] getSortedCryptogramFrequencies()

getFrequencies

public int[] getFrequencies()
returns the frequencies as an array

getHistogramData

public int[] getHistogramData()
Constructs an array of int out of the frequency tables

charToString

protected java.lang.String charToString(char ch)
Converts a nonprintable character to a string

getCharCount

public int getCharCount()
Returns a count of all characters.

getAlphabeticsCount

public int getAlphabeticsCount()
Returns a count of just alphabetic characters

getCount

public int getCount(int ch)
Returns the count for a specific character

sort

protected void sort()
Uses the java.util.Arrays sort method to sort the frquencies and stores the results in sortedFrequencies.