uk.org.arlott.simon.hw.f24.lbsta
Class Log

java.lang.Object
  extended by uk.org.arlott.simon.hw.f24.lbsta.Log

public class Log
extends java.lang.Object

Maintains a log of events in a limited size list.


Field Summary
private  java.util.LinkedList<java.lang.String> log
          List of log events as strings.
private  int maxEntries
          Maximum number of log entries.
private  Network network
          A reference to the Network for the current time.
 
Constructor Summary
Log(int maxEntries, Network network)
          Creates a new Log object with the specified maximum number of entries.
 
Method Summary
 void add(java.lang.String text)
          Adds a string to the log, the time will be prepended automatically.
 void clear()
          Clears the log.
 java.lang.String[] get()
          Retrieves the whole log as an array of strings.
static java.lang.String makeTime(long now)
          Converts a time in milliseconds to hours, minutes and seconds.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private java.util.LinkedList<java.lang.String> log
List of log events as strings.


maxEntries

private int maxEntries
Maximum number of log entries.


network

private Network network
A reference to the Network for the current time.

Constructor Detail

Log

public Log(int maxEntries,
           Network network)
Creates a new Log object with the specified maximum number of entries.

Parameters:
maxEntries - Maximum number of log entries.
network - A reference to the Network.
Method Detail

add

public void add(java.lang.String text)
Adds a string to the log, the time will be prepended automatically.

Parameters:
text - Event text to be added to the log.

get

public java.lang.String[] get()
Retrieves the whole log as an array of strings.

Returns:
The log as an array.

clear

public void clear()
Clears the log.


makeTime

public static java.lang.String makeTime(long now)
Converts a time in milliseconds to hours, minutes and seconds.

Parameters:
now - The time value.
Returns:
A string in the form HH:MM:SS.