peer2me.util
Class Log

java.lang.Object
  extended by peer2me.util.Log

public class Log
extends java.lang.Object

A class for handling the information and feedback given by the framework. Will present the user/developer with a response system used to present information and debug-options. Embeds enumeration-funcionality and exposes methods for handling the log. ShowDate is default set to false

Author:
Tommy Bjoernsgaard

Constructor Summary
Log()
           
 
Method Summary
 void addElement(LogElementType type, java.lang.String text)
          Adds a new entry to the log
 LogElement getElementAt(int index)
          Gets a log-entry at the specified index.
 LogElement[] getElements()
          Gets all the log-entries as an array of LogElements
 LogElement[] getElements(LogElementType type)
          Gets all the log-entries as an array of LogElements based on the LogEntryType
 javax.microedition.lcdui.List getElementsAsList()
          Creates a javax.microedition.lcdui.List based on the elements in the log.
 javax.microedition.lcdui.List getElementsAsList(LogElementType type)
          Creates a javax.microedition.lcdui.List based on the the given elementtype and elements in the log.
 javax.microedition.lcdui.List getElementsAsList(java.lang.String title)
          Creates a javax.microedition.lcdui.List based on the elements in the log.
 javax.microedition.lcdui.List getElementsAsList(java.lang.String title, LogElementType type)
          Creates a javax.microedition.lcdui.List based on the the given elementtype and elements in the log.
 LogElement getFirstElement()
          Gets the first element added to the log.
static Log getInstance()
          Gets the current or creates a new instance of the log.
 LogElement getLastElement()
          Gets the last element added to the log.
 LogElement getNextElement()
          Gets the next LogElement from the log.
 LogElement getPreviousElement()
          Gets the previous LogElement from the log.
 boolean isShowDate()
          Gets true if date is to be shown, else false
 boolean isShowTime()
           
 boolean isTurnedOn()
           
 void setTurnedOn(boolean turnedOn)
           
 void showDate(boolean showDate)
          Sets if the date is to be shown in the log-entry
 void showTime(boolean showTime)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Log

public Log()
Method Detail

getInstance

public static Log getInstance()
Gets the current or creates a new instance of the log. In the first run, showDate is false.

Returns:
an object of Log

showDate

public void showDate(boolean showDate)
Sets if the date is to be shown in the log-entry

Parameters:
showDate - True if the date is to be shown, else false

showTime

public void showTime(boolean showTime)

isShowDate

public boolean isShowDate()
Gets true if date is to be shown, else false

Returns:
The value indicating if date is shown

isShowTime

public boolean isShowTime()

addElement

public void addElement(LogElementType type,
                       java.lang.String text)
Adds a new entry to the log

Parameters:
type - The type of entry;LogElementType
text - A description of the entry

getElementAt

public LogElement getElementAt(int index)
Gets a log-entry at the specified index. Throws an exception if the index is invalid.

Parameters:
index - The index of the log-entry
Returns:
The LogElement at the given index

getFirstElement

public LogElement getFirstElement()
Gets the first element added to the log.

Returns:
The first LogElement in the log

getLastElement

public LogElement getLastElement()
Gets the last element added to the log.

Returns:
The last LogElement in the log

getNextElement

public LogElement getNextElement()
Gets the next LogElement from the log. The pointer is then shifted on to the next element.

Returns:
The next LogElement in line

getPreviousElement

public LogElement getPreviousElement()
Gets the previous LogElement from the log. The pointer is then shifted on to the element before the element returned.

Returns:
The previous LogElement

getElements

public LogElement[] getElements()
Gets all the log-entries as an array of LogElements

Returns:
The array of LogElement

getElements

public LogElement[] getElements(LogElementType type)
Gets all the log-entries as an array of LogElements based on the LogEntryType

Parameters:
type - the type of log-entry to get
Returns:
The array of LogElement

getElementsAsList

public javax.microedition.lcdui.List getElementsAsList()
Creates a javax.microedition.lcdui.List based on the elements in the log. Can easily be added to a Display. The List is List.IMPLICIT.

Returns:
the List with the elements

getElementsAsList

public javax.microedition.lcdui.List getElementsAsList(LogElementType type)
Creates a javax.microedition.lcdui.List based on the the given elementtype and elements in the log. Can easily be added to a Display. The List is List.IMPLICIT.

Parameters:
The - type of log-entries to show
Returns:
the List with the elements

getElementsAsList

public javax.microedition.lcdui.List getElementsAsList(java.lang.String title)
Creates a javax.microedition.lcdui.List based on the elements in the log. Can easily be added to a Display. Custom title. The List is List.IMPLICIT.

Parameters:
title - the title of the List
Returns:
the List with the elements

getElementsAsList

public javax.microedition.lcdui.List getElementsAsList(java.lang.String title,
                                                       LogElementType type)
Creates a javax.microedition.lcdui.List based on the the given elementtype and elements in the log. Can easily be added to a Display. Custom title The List is List.IMPLICIT.

Parameters:
title - the title of the List
type - The type of log-entries to show
Returns:
the List with the elements

isTurnedOn

public boolean isTurnedOn()

setTurnedOn

public void setTurnedOn(boolean turnedOn)