Concordance
Class FileInputReader

java.lang.Object
  extended by Concordance.FileInputReader

public class FileInputReader
extends java.lang.Object

Version:
1.00 The FileInputReader Class provides functionality to allow two text files to be processed. First an index file containing the words to be looked up is loaded in, this is followed by a reference text file. The results are stored in a HashTable to allow fast searching, the line numbers and context are also added to a LinkedList to provide more functionality.
Author:
Jonathan Field jof2@aber.ac.uk 073717922

Constructor Summary
FileInputReader()
           
 
Method Summary
 int getLineNumber()
           
 java.util.LinkedList<ConcordanceResult> getResultsList(java.lang.String selectedIndex)
          This method returns a LinkedList of ConcordanceResult, these contain the context and line numbers needed to provide extra information about the index word
 void processInputIndex(java.lang.String indexToLoad, java.lang.String textToLoad)
          This method creates an input stream to allow the index text file to be read in.
 void processInputText(java.lang.String textToLoad)
          Creates an input stream to read in a reference text file, this file is then tokenized (split up into individual words), this allows each word to be compared to the index words contained in the hashtable.
 java.util.Hashtable<java.lang.String,java.util.LinkedList<ConcordanceResult>> returnHashTable()
          Returns the HashTable
 java.util.ArrayList<java.lang.String> returnList()
          This method provides a sort, the items are added to an ArrayList and then Collections.sort() is called to sort them into alphabetical order, the sorted list is then returned to be displayed on the GUI.
 void setLineNumber(int lineNumber)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileInputReader

public FileInputReader()
Method Detail

processInputIndex

public void processInputIndex(java.lang.String indexToLoad,
                              java.lang.String textToLoad)
This method creates an input stream to allow the index text file to be read in. Each line is read in sequence, the index word is converted to lower case to allow for easier reference to the text later on. A default value is also given to the LinkedList as the lineNumbers are as of yet no appropriate The input stream is then closed and the next the next method is called to process the text file and compare it to the index words in the hashtable

Parameters:
indexToLoad - A String reference of a filepath to the desired index file to load in .txt format
textToLoad - A String reference of a filepath to the desired text file to load in .txt format

processInputText

public void processInputText(java.lang.String textToLoad)
                      throws java.io.IOException
Creates an input stream to read in a reference text file, this file is then tokenized (split up into individual words), this allows each word to be compared to the index words contained in the hashtable. If there is a match between a word being processed and a word in the hashtable then the line number and context are added to the hashtable.

Parameters:
textToLoad - A String reference of a filepath to the desired text file to load in .txt format
Throws:
java.io.IOException - Exception thrown if file is not found

returnHashTable

public java.util.Hashtable<java.lang.String,java.util.LinkedList<ConcordanceResult>> returnHashTable()
Returns the HashTable

Returns:
Returns the index HashTable

returnList

public java.util.ArrayList<java.lang.String> returnList()
This method provides a sort, the items are added to an ArrayList and then Collections.sort() is called to sort them into alphabetical order, the sorted list is then returned to be displayed on the GUI.

Returns:
Returns sorted list of index words

getResultsList

public java.util.LinkedList<ConcordanceResult> getResultsList(java.lang.String selectedIndex)
This method returns a LinkedList of ConcordanceResult, these contain the context and line numbers needed to provide extra information about the index word

Parameters:
selectedIndex - The selected index of a JList to show the users desired choice of index word
Returns:

getLineNumber

public int getLineNumber()

setLineNumber

public void setLineNumber(int lineNumber)