Title: Xref.java
Course: CPS 261: Advanced Java Concepts ~ DL & MM MASTER

Xref.java


import tools.*;
import java.util.*;

class Xref
{
    MyInput input;
    MyOutput output;
    SortedList list = new SortedList();

    // This routine reads in the File and generates the
    // Line Numbered Listing.  This routine also parses for tokens
    // and adds them to the SortedList class

    void parseFile()
    {
        // Read in your Input File one line at a time and
        // generate your numbered listing.
        // Also for each line read, use the StringTokenizer to
        // strip out the delimiters and leave just words.
        // Note that you will still have to throw out numbers.
        // Anything that has a digit for the first character
        // should be thrown out.
        // Each word needs to be added to the SortedList



    }

    // This routine creates the Cross Reference Map.
    // It mostly just walks through the Sorted List output
    // and generates output.  Note that it generates different
    // output depending on whether this is the first entry for
    // a given word or a subsequent word entry.

    void dumpXref()
    {
       // Print out the Xref Banner with *******, etc.
       // Walk through the Sorted List one WordInfo record at
       // a time.  If you look at either the main routine
       // or the toString routine in SortedList
       // you will see some clues on how to walk through list.
       // You will need to detect when the WordInfo records change
       // to a new word.  This can be done with the sameWord
       // routine in WordInfo.
       // Format as closely as you can to the sample output.
       // When a line should have no more than 5 line numbers on it.
       // If multiple lines are required to display the line numbers,
       // the subsequent lines start indented 10 spaces in.


    }
    void process(String inputFilename, String outputFilename)
    {
        // Open up input and output files

        parseFile(); // to parse the File
        dumpXref();  // to generate the Xref map

        //Close input and output files
    }

    public static void main(String[] args)
    {
       // Get the input and output filenames from the args array
       // If args contains no parameters, exit with an error message
       // If args contains 1 parameter send output to screen.
       //    First parameter contains input file.
       // If args contains 2 parameters send output to second filename
    }
}