Package pulse.tasks.logs
Class Log
- java.lang.Object
-
- pulse.util.UpwardsNavigable
-
- pulse.util.Group
-
- pulse.tasks.logs.Log
-
- All Implemented Interfaces:
Serializable,Descriptive
public class Log extends Group
ALogis used to track changes for a specificSearchTask, such as changes of status and/or data collection events.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Log(SearchTask task)Creates aLogfor thistaskthat will automatically storeTaskStatEvents and a list ofDataLogEntries in thread-safe collections.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(LogEntryListener l)LocalTimegetEnd()This is the time after the creation of theLogwhen a change of status toDONEhappened.IdentifiergetIdentifier()List<LogEntryListener>getListeners()List<LogEntry>getLogEntries()LocalTimegetStart()This is the time after the creation of theLogwhen a change of status toIN_PROGRESShappened.voidinitListeners()booleanisFinished()static booleanisGraphicalLog()Checks whether thisLogis verbose.booleanisStarted()Checks whether thisLoghas observed aTaskStateEventtriggered by a change of status of its respectiveSearchTasktoIN_PROGRESS.LogEntrylastEntry()Finds the last recorded entry in thisLog.static voidsetGraphicalLog(boolean verbose)Sets the verbose flag toverboselong[]timeTaken()Time taken where the first array element contains seconds [0] and the second contains milliseconds [1].StringtoString()Outputs all log entries consecutively.-
Methods inherited from class pulse.util.Group
access, children, contents, getDescriptor, getSimpleName, subgroups
-
Methods inherited from class pulse.util.UpwardsNavigable
addHierarchyListener, describe, getHierarchyListeners, getParent, identify, removeHierarchyListener, removeHierarchyListeners, setParent, specificAncestor, tellParent
-
-
-
-
Constructor Detail
-
Log
public Log(SearchTask task)
Creates aLogfor thistaskthat will automatically storeTaskStatEvents and a list ofDataLogEntries in thread-safe collections. This is done by adding aTaskListenerand aStatusChangeListenerto thetaskobject.- Parameters:
task- the task to be logged.
-
-
Method Detail
-
initListeners
public void initListeners()
- Overrides:
initListenersin classUpwardsNavigable
-
getListeners
public final List<LogEntryListener> getListeners()
-
addListener
public final void addListener(LogEntryListener l)
-
getIdentifier
public final Identifier getIdentifier()
-
isStarted
public boolean isStarted()
Checks whether thisLoghas observed aTaskStateEventtriggered by a change of status of its respectiveSearchTasktoIN_PROGRESS.- Returns:
trueif the start time is notnull
-
isFinished
public boolean isFinished()
-
toString
public String toString()
Outputs all log entries consecutively.
-
getStart
public LocalTime getStart()
This is the time after the creation of theLogwhen a change of status toIN_PROGRESShappened.- Returns:
- the start time
-
getEnd
public LocalTime getEnd()
This is the time after the creation of theLogwhen a change of status toDONEhappened.- Returns:
- the start time
-
lastEntry
public LogEntry lastEntry()
Finds the last recorded entry in thisLog.- Returns:
- last recorded entry.
-
isGraphicalLog
public static boolean isGraphicalLog()
Checks whether thisLogis verbose. Verbose logs stores all data entries and outputs them on request. This is useful to get an idea of how the search method works, how many iterations are taken to reach a converged value, etc.- Returns:
trueif the verbose flag is on
-
setGraphicalLog
public static void setGraphicalLog(boolean verbose)
Sets the verbose flag toverbose- Parameters:
verbose- the new value of the flag- See Also:
isGraphicalLog()
-
timeTaken
public long[] timeTaken()
Time taken where the first array element contains seconds [0] and the second contains milliseconds [1].- Returns:
- an array of long values that sum um to the time taken to process a task
-
-