Class Plan


  • public class Plan
    extends java.lang.Object
    Plan containing all days that have some tasks planned. Plan also contains all regular tasks.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.TreeMap days
      All days planned for the future or when any worked happened in the past.
      private static Plan plan
      The only instance of Plan object in the system.
      private java.util.Vector regularTasks
      Set of all regular tasks planned for the future.
      static long UPLOAD_IN_5_MINUTES
      Upload diary file once in 5 minutes.
      static long UPLOAD_NOW
      Upload diary file right now.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Plan()
      Creates a new instance of plan
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addDay​(Day day)
      Adds new day to plan.
      void addRegularTask​(RegularTask regularTask)
      Adds new regular task to plan.
      void addRegularTasks​(Day day)
      Adds regular tasks to given day.
      void copyUnfinishedTasks()
      Copies all unfinished tasks from previous working day to today.
      static void createBackup()
      Creates a backup copy of current diary.
      private boolean existsDayBefore​(Day day)
      Finds out if there is any day in plan before specified day.
      java.util.Vector getCategories()
      Returns all categories that were used to date.
      Day getDay​(java.util.Date date)
      Returns day identified by given date.
      private Day getDay​(java.util.Date date, int offset)
      Returns day by given date and offset.
      Day getDayAfter​(Day day)
      Returns one day after given day.
      Day getDayBefore​(Day day)
      Returns one day before given day.
      java.lang.String getDayID​(java.util.Calendar calendar)
      Returns identification of day set in given calendar.
      java.util.Iterator getDays​(int scale)
      Returns iterator of days according to given period scale.
      static Plan getDefault()
      Returns the only available instance of plan.
      private java.lang.String getNextWeekToSave​(int savedYear, int savedWeek)
      Returns identification of next week to be saved after given week in format yyyy-ww e.g.
      java.util.Vector getRegularTasks()
      Returns vector of all regular tasks.
      boolean isFuture​(Day day)
      Checks if given day will be after today.
      boolean isToday​(Day day)
      Checks if given day represents today.
      static void loadPlan()
      Loads all planned days and history.
      static void loadRegularTasks()
      Loads plan of regular tasks.
      private java.lang.String loadThisWeekDiary()
      Returns string representing diary for this week.
      void removeRegularTask​(RegularTask regularTask)
      Removes existing regular task from plan.
      static boolean savePlan()
      Saves all days to XML files.
      static void saveRegularTasks()
      Saves all regular tasks.
      private boolean saveWeek​(int year, int week, boolean isBackup)
      Saves week with given index of year.
      void uploadDiary​(long uploadFrequency)
      Uploads current week diary to specified server via HTTP connection.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • days

        private java.util.TreeMap days
        All days planned for the future or when any worked happened in the past.
      • regularTasks

        private java.util.Vector regularTasks
        Set of all regular tasks planned for the future.
      • plan

        private static Plan plan
        The only instance of Plan object in the system.
      • UPLOAD_IN_5_MINUTES

        public static long UPLOAD_IN_5_MINUTES
        Upload diary file once in 5 minutes.
      • UPLOAD_NOW

        public static long UPLOAD_NOW
        Upload diary file right now.
    • Constructor Detail

      • Plan

        private Plan()
        Creates a new instance of plan
    • Method Detail

      • getDefault

        public static Plan getDefault()
        Returns the only available instance of plan.
        Returns:
        The only instance of Plan object in system.
      • addDay

        public void addDay​(Day day)
        Adds new day to plan.
        Parameters:
        day - New day to be added to plan.
      • getDay

        public Day getDay​(java.util.Date date)
        Returns day identified by given date.
        Parameters:
        date - Date that will be used to find the day.
        Returns:
        Day with given date.
      • getDayBefore

        public Day getDayBefore​(Day day)
        Returns one day before given day.
        Parameters:
        day - Day whose predecessor should be found.
        Returns:
        Day before given day.
      • getDayAfter

        public Day getDayAfter​(Day day)
        Returns one day after given day.
        Parameters:
        day - Day whose ancessor should be found.
        Returns:
        Day after given day.
      • getDays

        public java.util.Iterator getDays​(int scale)
        Returns iterator of days according to given period scale.
        Parameters:
        scale - Period whose days to return. Either week or all time.
        Returns:
        Iterator of days from previous week or all days.
      • getDay

        private Day getDay​(java.util.Date date,
                           int offset)
        Returns day by given date and offset.
        Parameters:
        date - Date whose day should be returned.
        offset - Relative difference in days from specified date e.g. 0 if date exactly should be returned.
        Returns:
        Day based on date and offset.
      • getDayID

        public java.lang.String getDayID​(java.util.Calendar calendar)
        Returns identification of day set in given calendar.
        Parameters:
        calendar - Calendar preset to some day.
        Returns:
        Identification of day e.g. "2005_02_17"
      • isToday

        public boolean isToday​(Day day)
        Checks if given day represents today.
        Parameters:
        day - Day that should be checked.
        Returns:
        True if given day represents today otherwise false.
      • isFuture

        public boolean isFuture​(Day day)
        Checks if given day will be after today.
        Parameters:
        day - Day that should be checked.
        Returns:
        True if given day represents some day after today otherwise false.
      • addRegularTask

        public void addRegularTask​(RegularTask regularTask)
        Adds new regular task to plan.
        Parameters:
        regularTask - New regular task to be added to plan.
      • removeRegularTask

        public void removeRegularTask​(RegularTask regularTask)
        Removes existing regular task from plan.
        Parameters:
        regularTask - Regular task to be removed from plan.
      • getRegularTasks

        public java.util.Vector getRegularTasks()
        Returns vector of all regular tasks.
        Returns:
        Vector of all regular tasks.
      • createBackup

        public static void createBackup()
        Creates a backup copy of current diary.
      • savePlan

        public static boolean savePlan()
        Saves all days to XML files.
        Returns:
        True if plan was saved successfully, false otherwise
      • uploadDiary

        public void uploadDiary​(long uploadFrequency)
        Uploads current week diary to specified server via HTTP connection.
      • getNextWeekToSave

        private java.lang.String getNextWeekToSave​(int savedYear,
                                                   int savedWeek)
        Returns identification of next week to be saved after given week in format yyyy-ww e.g. 2019-45
        Parameters:
        savedYear - Index of year whose week has already been saved.
        savedWeek - Index of week that has already been saved.
        Returns:
        Identification of next week to save in yyyy-ww format or null if there is no more day in plan after given week.
      • saveWeek

        private boolean saveWeek​(int year,
                                 int week,
                                 boolean isBackup)
        Saves week with given index of year.
        Parameters:
        year - Index of year whose week should be saved.
        week - Index of week in given year to be saved.
        isBackup - If true backup will be created otherwise common diary file.
        Returns:
        True if week was successfully saved, false otherwise.
      • loadPlan

        public static void loadPlan()
                             throws java.lang.Exception
        Loads all planned days and history.
        Throws:
        java.lang.Exception - Exception thrown whenever any problem while loading plan occurs.
      • saveRegularTasks

        public static void saveRegularTasks()
        Saves all regular tasks.
      • loadRegularTasks

        public static void loadRegularTasks()
                                     throws java.lang.Exception
        Loads plan of regular tasks.
        Throws:
        java.lang.Exception - Exception thrown whenever any problem while loading regular tasks occurs.
      • copyUnfinishedTasks

        public void copyUnfinishedTasks()
        Copies all unfinished tasks from previous working day to today.
      • addRegularTasks

        public void addRegularTasks​(Day day)
        Adds regular tasks to given day.
        Parameters:
        day - Day to be extended for regular tasks.
      • existsDayBefore

        private boolean existsDayBefore​(Day day)
        Finds out if there is any day in plan before specified day.
        Parameters:
        day - Day whose predecessor existence should be verified.
        Returns:
        True if any day before given day exists in plan. False otherwise.
      • getCategories

        public java.util.Vector getCategories()
        Returns all categories that were used to date.
        Returns:
        Vector of categories that were used to date.
      • loadThisWeekDiary

        private java.lang.String loadThisWeekDiary()
        Returns string representing diary for this week.
        Returns:
        String containing this week's data or null if something fails.