LinkedHashMap Declared as such:
public class Search {
private LinkedHashMap<String, String> Pairs;
What is readSurnames() Method actually doing in reference to the LinkedHashMap?
Is an inputStream just basicaly a file, such as a txt file?
It is this line of code particularly confusing me:
Pairs.put(currentLine, processName(currentLine));
ReadSurnames:
/**
* Reads the surnames from the InputStream that was supplied on object
* creation
*/
public void readSurnames() {
String currentLine;
Scanner scanner = new Scanner(inputStream);
while (scanner.hasNext()) {
currentLine = scanner.nextLine();
Pairs.put(currentLine, processName(currentLine));
}
try {
inputStream.close();
scanner.close();
} catch (IOException e) {
System.err
.println("An error occured closing the input stream and scanner");
}
}
Process Name:
/**
* Takes an initial name and processed to produce a phonetic version that
* can be compared against other processed names
*
* @param name
* The original name unprocessed name
* @return The phonetic equivalent of the input name
*/
public String processName(String name) {
name = processNonAlphabetic(name);
name = processDiscardedLetters(name);
name = processEquivalentLetters(name);
name = processDuplicateEquivalentLetters(name);
return name;
}
LinkedHashMap
maintain the order in which the items are added in it.Pairs.put(currentLine, processName(currentLine));