reader
Class HTMLReader

java.lang.Object
  extended by reader.HTMLReader
All Implemented Interfaces:
Reader
Direct Known Subclasses:
DeadAIMReader

public abstract class HTMLReader
extends java.lang.Object
implements Reader

Defines the required methods for a class that Reads from a log file formatted in a certain way.


Field Summary
protected  FontState fs
          Keeps track of what state the font is in.
protected  java.lang.String line
          The next line of input of input from the file passed to loadFile(String).
protected  int lineNumber
          The line number that line represents in the file.
protected  java.io.BufferedReader reader
          The link to the file passed to loadFile(String).
protected  java.util.Vector<Session> sessions
          The Sessions stored in this log file.
 
Constructor Summary
protected HTMLReader()
          Creates a new FontState object.
 
Method Summary
protected  void eat(java.lang.String tag, java.lang.String errmsg)
          Eats the passed tag from line.
protected  void eatBodyTag()
          Eats the body tag and parses the parameters it contains.
protected  java.lang.String extractTag(java.lang.String line)
          Takes the passed String object and updates the fs object with the state of the font.
protected  void getNextLine()
          Gets the next line of the file.
 boolean loadFile(java.lang.String filename)
          This must be called at the top of the child class's loadFile(String) method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface reader.Reader
iterator
 

Field Detail

fs

protected FontState fs
Keeps track of what state the font is in. It is updated by calling extractTag(String) with String objects containing HTML tags at the front. Do not alter this variable directly unless you really know what you are doing and you have a good reason.


sessions

protected java.util.Vector<Session> sessions
The Sessions stored in this log file.


reader

protected java.io.BufferedReader reader
The link to the file passed to loadFile(String). Should only be read in loadFile(String). Will be null elsewhere.


line

protected java.lang.String line
The next line of input of input from the file passed to loadFile(String). Should only be referenced in loadFile(String).


lineNumber

protected int lineNumber
The line number that line represents in the file.

Constructor Detail

HTMLReader

protected HTMLReader()
Creates a new FontState object.

Method Detail

loadFile

public boolean loadFile(java.lang.String filename)
                 throws java.io.IOException
This must be called at the top of the child class's loadFile(String) method.

Specified by:
loadFile in interface Reader
Parameters:
filename - The name of the file to open and read from.
Returns:
true if successful, false otherwise.
Throws:
java.io.IOException - When an I/O error occurs.
See Also:
Reader.loadFile(String)

getNextLine

protected void getNextLine()
                    throws java.io.IOException
Gets the next line of the file. This updates the line and lineNumber members.

Throws:
java.io.IOException - if an I/O error occurs.

extractTag

protected java.lang.String extractTag(java.lang.String line)
                               throws java.lang.IllegalArgumentException,
                                      FileFormatException
Takes the passed String object and updates the fs object with the state of the font. There must be a valid tag at the front of the string. Recognized tags currently include: The resulting changes are recorded with the fs object.

Parameters:
line - The String with the tag at the front of it.
Returns:
The rest of the String minus the tag.
Throws:
java.lang.IllegalArgumentException - if line does not have an HTML tag at the front of it.
FileFormatException - if line is mal-formatted HTML.

eat

protected void eat(java.lang.String tag,
                   java.lang.String errmsg)
            throws java.io.IOException,
                   FileFormatException
Eats the passed tag from line. The tag must be the first thing to occur at the beginning of line (not including whitespace) otherwise the method will return null.

Parameters:
tag - The tag to be eaten.
errmsg - The error message to put in the FileFormatException if it needs to be thrown.
Throws:
java.io.IOException - if an I/O error occurs.
FileFormatException - If errmsg is not null and the line did not start with the tag.

eatBodyTag

protected void eatBodyTag()
                   throws java.io.IOException,
                          FileFormatException
Eats the body tag and parses the parameters it contains.

Throws:
java.io.IOException - If an I/O error occurs.
FileFormatException - If the <body> tag is formatted in an unexpected way.