- java.lang.Object
-
- com.pragmatickm.task.model.TaskLog
-
- All Implemented Interfaces:
Iterable<TaskLog.Entry>
public class TaskLog extends Object implements Iterable<TaskLog.Entry>
A TaskLog is a persistent list of entries stored for a task. When the data is first accessed, it is read from an XML file. When the XML file updated, the data is re-read. When the data is changed, the XML file is re-written immediately.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TaskLog.Entry
static class
TaskLog.Status
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addEntry(TaskLog.Entry entry)
Adds a new entry to the log, writing the new XML file immediately.List<TaskLog.Entry>
getEntries()
Gets the set of all entries.List<TaskLog.Entry>
getEntries(Calendar scheduledOn)
Gets the entries grouped by "scheduledOn" value or empty list if there are none.Map<String,List<TaskLog.Entry>>
getEntriesByScheduledOnDate()
Gets a snapshot of the entries grouped by "scheduledOn" value.UnmodifiableCalendar
getFirstIncompleteScheduledOn(Calendar from, Recurring recurring)
Gets the first incomplete scheduled on date.TaskLog.Entry
getMostRecentEntry(Calendar scheduledOn)
Gets the most recent entry from the task log on the given date ornull
if none.static TaskLog
getTaskLog(PageRef xmlFile)
To avoid repetitive parsing, only one TaskLog is created for each unique PageRef.PageRef
getXmlFile()
Iterator<TaskLog.Entry>
iterator()
Iterates through a snapshot of the entries.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
getTaskLog
public static TaskLog getTaskLog(PageRef xmlFile)
To avoid repetitive parsing, only one TaskLog is created for each unique PageRef.
-
getXmlFile
public PageRef getXmlFile()
-
getEntries
public List<TaskLog.Entry> getEntries() throws IOException
Gets the set of all entries. This is a snapshot view and will not change even when the log has been updated. To get a new snapshot, call this method again.
Entries are in order by "on" time.
- Throws:
IOException
-
iterator
public Iterator<TaskLog.Entry> iterator()
Iterates through a snapshot of the entries.- Specified by:
iterator
in interfaceIterable<TaskLog.Entry>
- See Also:
getEntries()
-
getEntriesByScheduledOnDate
public Map<String,List<TaskLog.Entry>> getEntriesByScheduledOnDate() throws IOException
Gets a snapshot of the entries grouped by "scheduledOn" value. Has anull
key for any entries without a "scheduledOn" date. The cache key is the date in YYYY-MM-DD format.- Throws:
IOException
- See Also:
for cache key formatting
-
getEntries
public List<TaskLog.Entry> getEntries(Calendar scheduledOn) throws IOException
Gets the entries grouped by "scheduledOn" value or empty list if there are none. Supportsnull
for all entries without a "scheduledOn" date.- Throws:
IOException
-
addEntry
public void addEntry(TaskLog.Entry entry) throws IOException
Adds a new entry to the log, writing the new XML file immediately.- Throws:
IOException
-
getMostRecentEntry
public TaskLog.Entry getMostRecentEntry(Calendar scheduledOn) throws IOException
Gets the most recent entry from the task log on the given date ornull
if none.- Throws:
IOException
-
getFirstIncompleteScheduledOn
public UnmodifiableCalendar getFirstIncompleteScheduledOn(Calendar from, Recurring recurring) throws IOException
Gets the first incomplete scheduled on date.- Throws:
IOException
-
-