Package org.cesilko.rachota.core
Class Task
java.lang.Object
org.cesilko.rachota.core.Task
- All Implemented Interfaces:
ClockListener
- Direct Known Subclasses:
IdleTask
,RegularTask
Single task planned for particular day.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic int
High level of task priority.static int
Low level of task priority.static int
Medium level of task priority.static int
State representing already finished task.static int
State representing not started task.static int
State representing already started task. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDuration
(long duration) Adds time in ms that was additionally spent on task.void
Appends a timestamp and given note to notes of this task.void
Adds new listener to set of objects interested in this task.boolean
Returns whether system should switch to task automatically.Returns clone of itself with time set to 0, empty notes and state set to STATE_NEW.Compare attributes with given task and return the one which is greater/smaller according to sorting order.Returns description of this task.long
Returns time in ms that was already spent on task.Returns keyword of this task.Returns keywords of this task.getNotes()
Returns notes of this task.Returns time when system should warn about task or null if no warning is required.int
Returns priority of this task.static String
getPriority
(int priority) Returns priority of this task.int
getState()
Returns state of this task.static String
getState
(int state) Returns state of this task.boolean
Returns false meaning that the task does not measure idle time.boolean
Returns whether task is being worked on or not.boolean
Returns whether this task is private.void
Adds new listener to set of objects interested in this task.void
setAutomaticStart
(boolean automaticStart) Sets whether system should switch to task automatically.void
setDescription
(String description) Sets description of this task.void
setDuration
(long duration) Sets time in ms that was already spent on task.void
setKeyword
(String keyword) Sets keyword of this task.void
Sets notes of this task.void
setNotificationTime
(Date notificationTime) Sets notification time when system should warn about task.void
setPriority
(int priority) Sets priority of this task.void
setPrivateTask
(boolean privateTask) Sets whether this task is private or not.void
setState
(int state) Sets state of this task.void
Method called when user starts to work on task.void
Method called when user temporarily stops to work on task.void
tick()
Method called by clock after one tick.toString()
Return textual representation of task.void
workDone()
Method called when user finished to work on task.void
write
(PrintStream stream) Writes task to given writer.void
writeRepetition
(PrintStream stream) Writes information about repetition of task.
-
Field Details
-
STATE_NEW
public static int STATE_NEWState representing not started task. -
STATE_STARTED
public static int STATE_STARTEDState representing already started task. -
STATE_DONE
public static int STATE_DONEState representing already finished task. -
PRIORITY_HIGH
public static int PRIORITY_HIGHHigh level of task priority. -
PRIORITY_MEDIUM
public static int PRIORITY_MEDIUMMedium level of task priority. -
PRIORITY_LOW
public static int PRIORITY_LOWLow level of task priority.
-
-
Constructor Details
-
Task
public Task(String description, String keyword, String notes, int priority, int state, long duration, 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 Details
-
setDescription
Sets description of this task.- Parameters:
description
- Description of task.
-
getDescription
Returns description of this task.- Returns:
- Description of this task.
-
setKeyword
Sets keyword of this task.- Parameters:
keyword
- Keyword of task.
-
getKeyword
Returns keyword of this task.- Returns:
- Keyword of this task.
-
getKeywordIterator
Returns keywords of this task.- Returns:
- Iterator of keyword tokens
-
setNotes
Sets notes of this task.- Parameters:
notes
- Notes of task.
-
getNotes
Returns notes of this task.- Returns:
- Notes of this task.
-
addNote
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
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
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
Sets notification time when system should warn about task.- Parameters:
notificationTime
- Time when system should warn about task.
-
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
Adds new listener to set of objects interested in this task.- Parameters:
listener
- Object interested in this task.
-
removePropertyChangeListener
Adds new listener to set of objects interested in this task.- Parameters:
listener
- Object interested in this task.
-
write
Writes task to given writer.- Parameters:
stream
- Print stream where task will be written.- Throws:
IOException
- Input/output exception thrown when some error during writing basic task information occurs.
-
writeRepetition
Writes information about repetition of task.- Parameters:
stream
- Print stream where task will be written.- Throws:
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:
tick
in interfaceClockListener
-
compare
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
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
Return textual representation 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.
-