1

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;
    }
4

1 Answer 1

0

For each line, it's mapping the original line to a processed version of the line, so later, you can access the processed version if you have the original.

1
  • I am not sure what you mean?
    – user3287264
    May 1, 2014 at 19:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.