peer2me.log
Class Log

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

public class Log
extends java.lang.Object

A class for handling the information and feedback given by the framework. Gives the user/developer 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 LogElement
 LogElement[] getElements(LogElementType type)
          Gets all the log-entries as an array of LogElement based on the LogElementType
 javax.microedition.lcdui.List getElementsAsList()
          Creates ajavax.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()
          Gets true if time is to be shown, else false
 boolean isTurnedOn()
          Gets if the log-functionality is turned on or not
 void setTurnedOn(boolean turnedOn)
          Sets if the log should be active
 void showDate(boolean showDate)
          Sets if the date should show in the log-entry
 void showTime(boolean showTime)
          Sets if the time should show in the log-entry
 
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 should show in the log-entry

Parameters:
showDate - true if should show, else false

showTime

public void showTime(boolean showTime)
Sets if the time should show in the log-entry

Parameters:
showTime - true if the time should show, else false

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()
Gets true if time is to be shown, else false

Returns:
The value indicating if time is shown

addElement

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

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

getElementAt

public LogElement getElementAt(int index)
Gets a log-entry at the specified index.

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. If there are no more elements, null is returned.

Returns:
The next LogElement in line, or null

getPreviousElement

public LogElement getPreviousElement()
Gets the previous LogElement from the log. The pointer is then shifted on to the element before the element returned. If there are no more elements, null is returned.

Returns:
The previous LogElement, or null

getElements

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

Returns:
The array of LogElement

getElements

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

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

getElementsAsList

public javax.microedition.lcdui.List getElementsAsList()
Creates ajavax.microedition.lcdui.List based on the elements in the log. Can easily be added to a javax.microedition.lcdui.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. a javax.microedition.lcdui.Display. The List is List.IMPLICIT.

Parameters:
type - 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 javax.microedition.lcdui.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. a javax.microedition.lcdui.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()
Gets if the log-functionality is turned on or not

Returns:
ture if the log i active, else false

setTurnedOn

public void setTurnedOn(boolean turnedOn)
Sets if the log should be active

Parameters:
turnedOn - true to activate the log, else false