Class Task

java.lang.Object
org.cesilko.rachota.core.Task
All Implemented Interfaces:
ClockListener
Direct Known Subclasses:
IdleTask, RegularTask

public class Task extends Object implements ClockListener
Single task planned for particular day.
  • Field Details

    • description

      private String description
      Short description of task.
    • keyword

      private String keyword
      Categories of task.
    • notes

      private String notes
      Long description of task.
    • priority

      private int priority
      Priority of task i.e. either High or Medium or Low.
    • state

      private int state
      State of task i.e. either New or Started or Done.
    • duration

      private long duration
      Total time in ms that was already spent on task.
    • notificationTime

      private Date notificationTime
      Time when system should warn about task.
    • automaticStart

      private boolean automaticStart
      Whether system should switch to task automatically.
    • timeStamp

      private Date timeStamp
      Time checkpoint used for exact calculation of time to be added to duration.
    • privateTask

      private boolean privateTask
      Whether this task is private i.e. its duration should not be counted to whole day duration.
    • propertyChangeSupport

      private PropertyChangeSupport propertyChangeSupport
      Class containing all registered listeners interested in task.
    • lastSaving

      private long lastSaving
      Time in miliseconds from previous saving of diary and settings files.
    • 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 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

      public void setDescription(String description)
      Sets description of this task.
      Parameters:
      description - Description of task.
    • getDescription

      public String getDescription()
      Returns description of this task.
      Returns:
      Description of this task.
    • setKeyword

      public void setKeyword(String keyword)
      Sets keyword of this task.
      Parameters:
      keyword - Keyword of task.
    • getKeyword

      public String getKeyword()
      Returns keyword of this task.
      Returns:
      Keyword of this task.
    • getKeywordIterator

      public Iterator getKeywordIterator()
      Returns keywords of this task.
      Returns:
      Iterator of keyword tokens
    • setNotes

      public void setNotes(String notes)
      Sets notes of this task.
      Parameters:
      notes - Notes of task.
    • getNotes

      public String getNotes()
      Returns notes of this task.
      Returns:
      Notes of this task.
    • addNote

      public void addNote(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 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 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(Date notificationTime)
      Sets notification time when system should warn about task.
      Parameters:
      notificationTime - Time when system should warn about task.
    • getNotificationTime

      public 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(PropertyChangeListener listener)
      Adds new listener to set of objects interested in this task.
      Parameters:
      listener - Object interested in this task.
    • removePropertyChangeListener

      public void removePropertyChangeListener(PropertyChangeListener listener)
      Adds new listener to set of objects interested in this task.
      Parameters:
      listener - Object interested in this task.
    • write

      public void write(PrintStream stream) throws IOException
      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

      public void writeRepetition(PrintStream stream) throws IOException
      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 interface ClockListener
    • 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 String toString()
      Return textual representation of task.
      Overrides:
      toString in class 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.