Class LogfileManager

java.lang.Object
  |
  +--LogfileManager

public class LogfileManager
extends java.lang.Object

Manager for the proxy logfile. Independent from the rest of program.


Field Summary
private  java.util.ArrayList client
           
private  java.util.ArrayList date
           
private  java.util.Date filedate
           
private  java.lang.String filename
           
private  int nLines
           
private  java.util.ArrayList request
           
private  java.util.ArrayList result
           
static int SORT_BY_CLIENT
           
static int SORT_BY_DATE
           
static int SORT_BY_REQUEST
           
static int SORT_BY_RESULT
           
 
Constructor Summary
LogfileManager(java.lang.String filename)
           
 
Method Summary
 void generateSortedLogs(java.lang.String output)
          Generates the sets of 4 sorted logs, one for every sort criteria.
private  void initialize()
          Initializes all fields.
private  void makeHtml(java.lang.String output, int sortMode)
          Generates an HTML document presenting the sorted log.
static long numValue(java.lang.String IPAddress)
          Transforms an IP address in its numerical value, eg. giving 193.55.61.191 as parameter will return 193055061191.
 void read()
          Reads a logfile in memory.
private  void sort(java.lang.String output, int sortMode)
          Creates a HTML sorted log.
private  void swap(int index1, int index2)
          Swaps two elements in all the four ArrayLists.
 void writeLine(java.lang.String action)
          Writes a line onto the logfile.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

SORT_BY_CLIENT

public static final int SORT_BY_CLIENT

SORT_BY_DATE

public static final int SORT_BY_DATE

SORT_BY_REQUEST

public static final int SORT_BY_REQUEST

SORT_BY_RESULT

public static final int SORT_BY_RESULT

filename

private java.lang.String filename

filedate

private java.util.Date filedate

client

private java.util.ArrayList client

date

private java.util.ArrayList date

request

private java.util.ArrayList request

result

private java.util.ArrayList result

nLines

private int nLines
Constructor Detail

LogfileManager

public LogfileManager(java.lang.String filename)
Method Detail

initialize

private void initialize()
Initializes all fields.

writeLine

public void writeLine(java.lang.String action)
               throws java.io.IOException
Writes a line onto the logfile.
Parameters:
action - the line to write on the logfile

read

public void read()
          throws java.io.FileNotFoundException,
                 java.io.IOException
Reads a logfile in memory.

sort

private void sort(java.lang.String output,
                  int sortMode)
           throws java.text.ParseException,
                  java.io.IOException
Creates a HTML sorted log.
Parameters:
output - a name _without_ the .html extension. The generated file will be named X.html, where X = [1,4] depends of the sort mode
sortMode - the sort criteria chosen: an integer among SORT_BY_CLIENT, SORT_BY_DATE, SORT_BY_REQUEST, SORT_BY_RESULT

swap

private void swap(int index1,
                  int index2)
Swaps two elements in all the four ArrayLists.

numValue

public static long numValue(java.lang.String IPAddress)
Transforms an IP address in its numerical value, eg. giving 193.55.61.191 as parameter will return 193055061191. Necessary when sorting IP addresses.

makeHtml

private void makeHtml(java.lang.String output,
                      int sortMode)
               throws java.io.IOException
Generates an HTML document presenting the sorted log.
Parameters:
output - a name _without_ the .html extension. The generated file will be named X.html, where X = [1,4] depends of the sort mode
sortMode - the sort criteria chosen: an integer among SORT_BY_CLIENT, SORT_BY_DATE, SORT_BY_REQUEST, SORT_BY_RESULT

generateSortedLogs

public void generateSortedLogs(java.lang.String output)
                        throws java.text.ParseException,
                               java.io.IOException
Generates the sets of 4 sorted logs, one for every sort criteria.