Class Task

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int PRIORITY_HIGH
      High level of task priority.
      static int PRIORITY_LOW
      Low level of task priority.
      static int PRIORITY_MEDIUM
      Medium level of task priority.
      static int STATE_DONE
      State representing already finished task.
      static int STATE_NEW
      State representing not started task.
      static int STATE_STARTED
      State 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
      void addDuration​(long duration)
      Adds time in ms that was additionally spent on task.
      void addNote​(java.lang.String note, boolean recordTime)
      Appends a timestamp and given note to notes of this task.
      void addPropertyChangeListener​(java.beans.PropertyChangeListener listener)
      Adds new listener to set of objects interested in this task.
      boolean automaticStart()
      Returns whether system should switch to task automatically.
      Task cloneTask()
      Returns clone of itself with time set to 0, empty notes and state set to STATE_NEW.
      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.
      java.lang.String getDescription()
      Returns description of this task.
      long getDuration()
      Returns time in ms that was already spent on task.
      java.lang.String getKeyword()
      Returns keyword of this task.
      java.util.Iterator getKeywordIterator()
      Returns keywords of this task.
      java.lang.String getNotes()
      Returns notes of this task.
      java.util.Date getNotificationTime()
      Returns time when system should warn about task or null if no warning is required.
      int getPriority()
      Returns priority of this task.
      static java.lang.String getPriority​(int priority)
      Returns priority of this task.
      int getState()
      Returns state of this task.
      static java.lang.String getState​(int state)
      Returns state of this task.
      boolean isIdleTask()
      Returns false meaning that the task does not measure idle time.
      boolean isRunning()
      Returns whether task is being worked on or not.
      boolean privateTask()
      Returns whether this task is private.
      void removePropertyChangeListener​(java.beans.PropertyChangeListener listener)
      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​(java.lang.String description)
      Sets description of this task.
      void setDuration​(long duration)
      Sets time in ms that was already spent on task.
      void setKeyword​(java.lang.String keyword)
      Sets keyword of this task.
      void setNotes​(java.lang.String notes)
      Sets notes of this task.
      void setNotificationTime​(java.util.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 startWork()
      Method called when user starts to work on task.
      void suspendWork()
      Method called when user temporarily stops to work on task.
      void tick()
      Method called by clock after one tick.
      java.lang.String toString()
      Return textual representation of task.
      void workDone()
      Method called when user finished to work on task.
      void write​(java.io.PrintStream stream)
      Writes task to given writer.
      void writeRepetition​(java.io.PrintStream stream)
      Writes information about repetition of task.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • 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.IOException
        Writes 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.IOException
        Writes 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:
        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 java.lang.String toString()
        Return textual representation of task.
        Overrides:
        toString in class java.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.