Package org.cesilko.rachota.core
Class Task
- java.lang.Object
-
- org.cesilko.rachota.core.Task
-
- All Implemented Interfaces:
ClockListener
- Direct Known Subclasses:
IdleTask,RegularTask
public class Task extends java.lang.Object implements ClockListener
Single task planned for particular day.
-
-
Field Summary
Fields Modifier and Type Field Description static intPRIORITY_HIGHHigh level of task priority.static intPRIORITY_LOWLow level of task priority.static intPRIORITY_MEDIUMMedium level of task priority.static intSTATE_DONEState representing already finished task.static intSTATE_NEWState representing not started task.static intSTATE_STARTEDState representing already started task.
-
Constructor Summary
Constructors Constructor Description Task(java.lang.String description, java.lang.String keyword, java.lang.String notes, int priority, int state, long duration, java.util.Date notificationTime, boolean automaticStart, boolean privateTask)Creates a new instance of Task
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDuration(long duration)Adds time in ms that was additionally spent on task.voidaddNote(java.lang.String note, boolean recordTime)Appends a timestamp and given note to notes of this task.voidaddPropertyChangeListener(java.beans.PropertyChangeListener listener)Adds new listener to set of objects interested in this task.booleanautomaticStart()Returns whether system should switch to task automatically.TaskcloneTask()Returns clone of itself with time set to 0, empty notes and state set to STATE_NEW.Taskcompare(Task task, int attribute, boolean ascendingOrder)Compare attributes with given task and return the one which is greater/smaller according to sorting order.java.lang.StringgetDescription()Returns description of this task.longgetDuration()Returns time in ms that was already spent on task.java.lang.StringgetKeyword()Returns keyword of this task.java.util.IteratorgetKeywordIterator()Returns keywords of this task.java.lang.StringgetNotes()Returns notes of this task.java.util.DategetNotificationTime()Returns time when system should warn about task or null if no warning is required.intgetPriority()Returns priority of this task.static java.lang.StringgetPriority(int priority)Returns priority of this task.intgetState()Returns state of this task.static java.lang.StringgetState(int state)Returns state of this task.booleanisIdleTask()Returns false meaning that the task does not measure idle time.booleanisRunning()Returns whether task is being worked on or not.booleanprivateTask()Returns whether this task is private.voidremovePropertyChangeListener(java.beans.PropertyChangeListener listener)Adds new listener to set of objects interested in this task.voidsetAutomaticStart(boolean automaticStart)Sets whether system should switch to task automatically.voidsetDescription(java.lang.String description)Sets description of this task.voidsetDuration(long duration)Sets time in ms that was already spent on task.voidsetKeyword(java.lang.String keyword)Sets keyword of this task.voidsetNotes(java.lang.String notes)Sets notes of this task.voidsetNotificationTime(java.util.Date notificationTime)Sets notification time when system should warn about task.voidsetPriority(int priority)Sets priority of this task.voidsetPrivateTask(boolean privateTask)Sets whether this task is private or not.voidsetState(int state)Sets state of this task.voidstartWork()Method called when user starts to work on task.voidsuspendWork()Method called when user temporarily stops to work on task.voidtick()Method called by clock after one tick.java.lang.StringtoString()Return textual representation of task.voidworkDone()Method called when user finished to work on task.voidwrite(java.io.PrintStream stream)Writes task to given writer.voidwriteRepetition(java.io.PrintStream stream)Writes information about repetition of task.
-
-
-
Field Detail
-
STATE_NEW
public static int STATE_NEW
State representing not started task.
-
STATE_STARTED
public static int STATE_STARTED
State representing already started task.
-
STATE_DONE
public static int STATE_DONE
State representing already finished task.
-
PRIORITY_HIGH
public static int PRIORITY_HIGH
High level of task priority.
-
PRIORITY_MEDIUM
public static int PRIORITY_MEDIUM
Medium level of task priority.
-
PRIORITY_LOW
public static int PRIORITY_LOW
Low level of task priority.
-
-
Constructor Detail
-
Task
public Task(java.lang.String description, java.lang.String keyword, java.lang.String notes, int priority, int state, long duration, java.util.Date notificationTime, boolean automaticStart, boolean privateTask)Creates a new instance of Task- Parameters:
description- Description of task.keyword- Arbitrary text for grouping tasks etc.notes- Any kind of additional information about task.priority- Priority of task.state- State of progress of task.duration- Time in ms that was already spent on task.notificationTime- Time when system should warn about task.automaticStart- Should system switch to task automatically ?privateTask- Is this task private ?
-
-
Method Detail
-
setDescription
public void setDescription(java.lang.String description)
Sets description of this task.- Parameters:
description- Description of task.
-
getDescription
public java.lang.String getDescription()
Returns description of this task.- Returns:
- Description of this task.
-
setKeyword
public void setKeyword(java.lang.String keyword)
Sets keyword of this task.- Parameters:
keyword- Keyword of task.
-
getKeyword
public java.lang.String getKeyword()
Returns keyword of this task.- Returns:
- Keyword of this task.
-
getKeywordIterator
public java.util.Iterator getKeywordIterator()
Returns keywords of this task.- Returns:
- Iterator of keyword tokens
-
setNotes
public void setNotes(java.lang.String notes)
Sets notes of this task.- Parameters:
notes- Notes of task.
-
getNotes
public java.lang.String getNotes()
Returns notes of this task.- Returns:
- Notes of this task.
-
addNote
public void addNote(java.lang.String note, boolean recordTime)Appends a timestamp and given note to notes of this task.- Parameters:
note- Note to be appended.recordTime- If true, timestamp will be inserted before the note.
-
setPriority
public void setPriority(int priority)
Sets priority of this task.- Parameters:
priority- Priority of task.
-
getPriority
public int getPriority()
Returns priority of this task.- Returns:
- Priority of this task as number.
-
getPriority
public static java.lang.String getPriority(int priority)
Returns priority of this task.- Parameters:
priority- Priority of task as number.- Returns:
- Priority of this task as text.
-
setState
public void setState(int state)
Sets state of this task.- Parameters:
state- State of task.
-
getState
public int getState()
Returns state of this task.- Returns:
- State of this task as number.
-
getState
public static java.lang.String getState(int state)
Returns state of this task.- Parameters:
state- State of task as number.- Returns:
- State of this task as text.
-
setDuration
public void setDuration(long duration)
Sets time in ms that was already spent on task.- Parameters:
duration- Time in ms that was already spent on task.
-
addDuration
public void addDuration(long duration)
Adds time in ms that was additionally spent on task.- Parameters:
duration- Time in ms that was additionally spent on task.
-
getDuration
public long getDuration()
Returns time in ms that was already spent on task.- Returns:
- Time in ms that was already spent on task.
-
setNotificationTime
public void setNotificationTime(java.util.Date notificationTime)
Sets notification time when system should warn about task.- Parameters:
notificationTime- Time when system should warn about task.
-
getNotificationTime
public java.util.Date getNotificationTime()
Returns time when system should warn about task or null if no warning is required.- Returns:
- Time when system should warn about task or null if no warning is required.
-
setAutomaticStart
public void setAutomaticStart(boolean automaticStart)
Sets whether system should switch to task automatically.- Parameters:
automaticStart- Should system switch to task automatically ?
-
automaticStart
public boolean automaticStart()
Returns whether system should switch to task automatically.- Returns:
- Should system switch to task automatically ?
-
setPrivateTask
public void setPrivateTask(boolean privateTask)
Sets whether this task is private or not.- Parameters:
privateTask- Is this private task or not ?
-
privateTask
public boolean privateTask()
Returns whether this task is private.- Returns:
- True if this task is private and false otherwise.
-
addPropertyChangeListener
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds new listener to set of objects interested in this task.- Parameters:
listener- Object interested in this task.
-
removePropertyChangeListener
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds new listener to set of objects interested in this task.- Parameters:
listener- Object interested in this task.
-
write
public void write(java.io.PrintStream stream) throws java.io.IOExceptionWrites task to given writer.- Parameters:
stream- Print stream where task will be written.- Throws:
java.io.IOException- Input/output exception thrown when some error during writing basic task information occurs.
-
writeRepetition
public void writeRepetition(java.io.PrintStream stream) throws java.io.IOExceptionWrites information about repetition of task.- Parameters:
stream- Print stream where task will be written.- Throws:
java.io.IOException- Input/output exception thrown when some error during writing repetition information occurs.
-
startWork
public void startWork()
Method called when user starts to work on task.
-
suspendWork
public void suspendWork()
Method called when user temporarily stops to work on task.
-
workDone
public void workDone()
Method called when user finished to work on task.
-
isRunning
public boolean isRunning()
Returns whether task is being worked on or not.- Returns:
- True if task is currently being worked on. False otherwise.
-
tick
public void tick()
Method called by clock after one tick. Task has to increase its working time.- Specified by:
tickin interfaceClockListener
-
compare
public Task compare(Task task, int attribute, boolean ascendingOrder)
Compare attributes with given task and return the one which is greater/smaller according to sorting order.- Parameters:
task- Task to be compared with.attribute- Property of task to be compared e.g. DayTableModel.TASK_PRIORITY.ascendingOrder- If true smaller task will be returned.- Returns:
- True or false depending on actual and given task resulting from their comparison based on given attribute and sorting order.
-
cloneTask
public Task cloneTask()
Returns clone of itself with time set to 0, empty notes and state set to STATE_NEW.- Returns:
- Task similar to this one except time, notes and state.
-
toString
public java.lang.String toString()
Return textual representation of task.- Overrides:
toStringin classjava.lang.Object- Returns:
- Description of task.
-
isIdleTask
public boolean isIdleTask()
Returns false meaning that the task does not measure idle time.- Returns:
- True if this is an idle task, false otherwise.
-
-