File Source: day.java

         /* 
    P/P   *  Method: net.sourceforge.pebble.domain.Day__static_init
          */
     1  /*
     2   * Copyright (c) 2003-2006, Simon Brown
     3   * All rights reserved.
     4   *
     5   * Redistribution and use in source and binary forms, with or without
     6   * modification, are permitted provided that the following conditions are met:
     7   *
     8   *   - Redistributions of source code must retain the above copyright
     9   *     notice, this list of conditions and the following disclaimer.
    10   *
    11   *   - Redistributions in binary form must reproduce the above copyright
    12   *     notice, this list of conditions and the following disclaimer in
    13   *     the documentation and/or other materials provided with the
    14   *     distribution.
    15   *
    16   *   - Neither the name of Pebble nor the names of its contributors may
    17   *     be used to endorse or promote products derived from this software
    18   *     without specific prior written permission.
    19   *
    20   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    21   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    22   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    23   * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
    24   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    25   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    26   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    27   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    28   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    29   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    30   * POSSIBILITY OF SUCH DAMAGE.
    31   */
    32  package net.sourceforge.pebble.domain;
    33  
    34  import net.sourceforge.pebble.comparator.ReverseBlogEntryIdComparator;
    35  
    36  import java.util.*;
    37  
    38  /**
    39   * Represents a blog at a daily level. This manages a collection of BlogEntry instances.
    40   *
    41   * @author    Simon Brown
    42   */
    43  public class Day extends TimePeriod implements Permalinkable {
    44  
    45    /** the parent, Month instance */
    46    private Month month;
    47  
    48    /** an integer representing the day that this Day is for */
    49    private int day;
    50  
    51    /** the collection of blog entry keys */
    52    private List<String> blogEntries = new ArrayList<String>();
    53    private List<String> publishedBlogEntries = new ArrayList<String>();
    54    private List<String> unpublishedBlogEntries = new ArrayList<String>();
    55  
    56    /**
    57     * Creates a new Day for the specified month and day.
    58     *
    59     * @param month   a Month instance representing the month
    60     * @param day     an int representing the day
    61     */
    62    Day(Month month, int day) {
             /* 
    P/P       *  Method: void net.sourceforge.pebble.domain.Day(Month, int)
              * 
              *  Preconditions:
              *    month != null
              *    month.month >= -231+1
              *    month.year != null
              *    init'ed(month.year.year)
              * 
              *  Presumptions:
              *    net.sourceforge.pebble.domain.Month:getBlog(...)@63 != null
              * 
              *  Postconditions:
              *    (soft) this.blog != null
              *    this.blogEntries == &new ArrayList(Day#1)
              *    init'ed(this.date)
              *    this.day == day
              *    init'ed(this.day)
              *    this.month == month
              *    this.month != null
              *    this.publishedBlogEntries == &new ArrayList(Day#2)
              *    this.unpublishedBlogEntries == &new ArrayList(Day#3)
              *    new ArrayList(Day#1) num objects == 1
              *    ...
              */
    63      super(month.getBlog());
    64  
    65      this.month = month;
    66      this.day = day;
    67      setDate(getCalendar().getTime());
    68  
    69  //    if (getBlog() instanceof Blog) {
    70  //      try {
    71  //        Blog blog = getBlog();
    72  //
    73  //        DAOFactory factory = DAOFactory.getConfiguredFactory();
    74  //        BlogEntryDAO dao = factory.getBlogEntryDAO();
    75  //        entries = dao.getBlogEntries(this);
    76  //        Collections.sort(entries, new BlogEntryComparator());
    77  //
    78  //        Iterator it = entries.iterator();
    79  //        while (it.hasNext()) {
    80  //          BlogEntry blogEntry = (BlogEntry)it.next();
    81  //
    82  //          if (blogEntry.isApproved()) {
    83  //            Iterator categories = blogEntry.getCategories().iterator();
    84  //            while (categories.hasNext()) {
    85  //              Category category = (Category)categories.next();
    86  //              category.addBlogEntry(blogEntry);
    87  //            }
    88  //            blog.getRootCategory().addBlogEntry(blogEntry);
    89  //
    90  //            // and the blog entry specific tags
    91  //            Iterator tags = blogEntry.getTagsAsList().iterator();
    92  //            while (tags.hasNext()) {
    93  //              Tag tag = (Tag)tags.next();
    94  //              tag.addBlogEntry(blogEntry);
    95  //            }
    96  //          }
    97  //
    98  //          // tell the owning blog that we might have some more recent
    99  //          // comments and TrackBacks
   100  //          Iterator comments = blogEntry.getComments().iterator();
   101  //          while (comments.hasNext()) {
   102  //            blog.getResponseManager().addRecentComment((Comment)comments.next());
   103  //          }
   104  //          Iterator trackBacks = blogEntry.getTrackBacks().iterator();
   105  //          while (trackBacks.hasNext()) {
   106  //            blog.getResponseManager().addRecentTrackBack((TrackBack)trackBacks.next());
   107  //          }
   108  //
   109  //          // now that the entries have been loaded, enable events
   110  //          // so that listeners get notified when they change
   111  //          blogEntry.setEventsEnabled(true);
   112  //        }
   113  //      } catch (PersistenceException e) {
   114  //        e.printStackTrace();
   115  //      }
   116  //    }
   117    }
   118  
   119    /**
   120     * Gets a Calendar object representing today.
   121     *
   122     * @return    a Calendar instance
   123     */
   124    private Calendar getCalendar() {
   125  
   126      // and set the actual date for this day
             /* 
    P/P       *  Method: Calendar getCalendar()
              * 
              *  Preconditions:
              *    this.blog != null
              *    init'ed(this.day)
              *    this.month != null
              *    this.month.month >= -231+1
              *    this.month.year != null
              *    init'ed(this.month.year.year)
              * 
              *  Presumptions:
              *    net.sourceforge.pebble.domain.Blog:getCalendar(...)@127 != null
              * 
              *  Postconditions:
              *    (soft) return_value != null
              */
   127      Calendar cal = getBlog().getCalendar();
   128      cal.set(Calendar.YEAR, getMonth().getYear().getYear());
   129      cal.set(Calendar.MONTH, getMonth().getMonth() - 1);
   130      cal.set(Calendar.DAY_OF_MONTH, getDay());
   131      cal.set(Calendar.HOUR_OF_DAY, 12);
   132      cal.set(Calendar.MINUTE, 0);
   133      cal.set(Calendar.SECOND, 0);
   134      cal.set(Calendar.MILLISECOND, 0);
   135  
   136      return cal;
   137    }
   138  
   139    /**
   140     * Gets a reference to the parent Month instance.
   141     *
   142     * @return  a Month instance
   143     */
   144    public Month getMonth() {
             /* 
    P/P       *  Method: Month getMonth()
              * 
              *  Preconditions:
              *    init'ed(this.month)
              * 
              *  Postconditions:
              *    return_value == this.month
              *    init'ed(return_value)
              */
   145      return month;
   146    }
   147  
   148    /**
   149     * Gets the day that this Day is for.
   150     *
   151     * @return    an int representing the day in the month
   152     */
   153    public int getDay() {
             /* 
    P/P       *  Method: int getDay()
              * 
              *  Preconditions:
              *    init'ed(this.day)
              * 
              *  Postconditions:
              *    return_value == this.day
              *    init'ed(return_value)
              */
   154      return day;
   155    }
   156  
   157    /**
   158     * Gets the permalink to display all entries for this Day.
   159     *
   160     * @return  an absolute URL
   161     */
   162    public String getPermalink() {
             /* 
    P/P       *  Method: String getPermalink()
              * 
              *  Preconditions:
              *    this.blog != null
              * 
              *  Postconditions:
              *    return_value != null
              * 
              *  Preconditions:
              *    this.blog.permalinkProvider != null
              *    (soft) net/sourceforge/pebble/domain/BlogManager.instance != null
              *    (soft) init'ed(net/sourceforge/pebble/domain/BlogManager.instance.multiBlog)
              *    (soft) init'ed(this.blog.id)
              * 
              *  Test Vectors:
              *    java.lang.String:length(...)@164: {0}, {1..232-1}
              *    getPermalink(...)@163: Addr_Set{null}, Inverse{null}
              */
   163      String s = getBlog().getPermalinkProvider().getPermalink(this);
   164      if (s != null && s.length() > 0) {
   165        return getBlog().getUrl() + s.substring(1);
   166      } else {
   167        return "";
   168      }
   169    }
   170  
   171    /**
   172     * Gets a Collection containing all the blog entries for this day.
   173     *
   174     * @return    an ordered List of BlogEntry instances
   175     */
   176    public List<String> getBlogEntries() {
             /* 
    P/P       *  Method: List getBlogEntries()
              * 
              *  Preconditions:
              *    init'ed(this.blogEntries)
              * 
              *  Postconditions:
              *    return_value == &new ArrayList(getBlogEntries#1)
              *    new ArrayList(getBlogEntries#1) num objects == 1
              */
   177      return new ArrayList<String>(blogEntries);
   178    }
   179  
   180    public int getNumberOfBlogEntries() {
             /* 
    P/P       *  Method: int getNumberOfBlogEntries()
              * 
              *  Preconditions:
              *    this.publishedBlogEntries != null
              * 
              *  Postconditions:
              *    init'ed(return_value)
              */
   181      return publishedBlogEntries.size();
   182    }
   183  
   184    public synchronized void addPublishedBlogEntry(String blogEntryId) {
             /* 
    P/P       *  Method: void addPublishedBlogEntry(String)
              * 
              *  Preconditions:
              *    this.blogEntries != null
              *    this.publishedBlogEntries != null
              *    this.unpublishedBlogEntries != null
              * 
              *  Test Vectors:
              *    java.util.List:contains(...)@185: {1}, {0}
              *    java.util.List:contains(...)@191: {1}, {0}
              */
   185      if (!publishedBlogEntries.contains(blogEntryId)) {
   186        publishedBlogEntries.add(blogEntryId);
   187        Collections.sort(publishedBlogEntries, new ReverseBlogEntryIdComparator());
   188      }
   189      unpublishedBlogEntries.remove(blogEntryId);
   190  
   191      if (!blogEntries.contains(blogEntryId)) {
   192        // and add to the aggregated view
   193        blogEntries.add(blogEntryId);
   194        Collections.sort(blogEntries, new ReverseBlogEntryIdComparator());
   195      }
   196    }
   197  
   198    public synchronized void addUnpublishedBlogEntry(String blogEntryId) {
             /* 
    P/P       *  Method: void addUnpublishedBlogEntry(String)
              * 
              *  Preconditions:
              *    this.blogEntries != null
              *    this.publishedBlogEntries != null
              *    this.unpublishedBlogEntries != null
              * 
              *  Test Vectors:
              *    java.util.List:contains(...)@199: {1}, {0}
              *    java.util.List:contains(...)@205: {1}, {0}
              */
   199      if (!unpublishedBlogEntries.contains(blogEntryId)) {
   200        unpublishedBlogEntries.add(blogEntryId);
   201        Collections.sort(unpublishedBlogEntries, new ReverseBlogEntryIdComparator());
   202      }
   203      publishedBlogEntries.remove(blogEntryId);
   204  
   205      if (!blogEntries.contains(blogEntryId)) {
   206        // and add to the aggregated view
   207        blogEntries.add(blogEntryId);
   208        Collections.sort(blogEntries, new ReverseBlogEntryIdComparator());
   209      }
   210    }
   211  
   212    public synchronized void removeBlogEntry(BlogEntry blogEntry) {
             /* 
    P/P       *  Method: void removeBlogEntry(BlogEntry)
              * 
              *  Preconditions:
              *    blogEntry != null
              *    this.blogEntries != null
              *    this.publishedBlogEntries != null
              *    this.unpublishedBlogEntries != null
              */
   213      publishedBlogEntries.remove(blogEntry.getId());
   214      unpublishedBlogEntries.remove(blogEntry.getId());
   215      blogEntries.remove(blogEntry.getId());
   216    }
   217  
   218  //  /**
   219  //   * Gets a Collection containing all the blog entries for this day and the
   220  //   * specified category.
   221  //   *
   222  //   * @param   category    a Category instance, or null
   223  //   * @return    an ordered List of BlogEntry instances
   224  //   */
   225  //  public List getEntries(Category category) {
   226  //    if (category == null) {
   227  //      return this.getEntries();
   228  //    } else {
   229  //      List blogEntries = new ArrayList();
   230  //      Iterator it = getEntries().iterator();
   231  //      while (it.hasNext()) {
   232  //        BlogEntry blogEntry = (BlogEntry)it.next();
   233  //        if (blogEntry.inCategory(category)) {
   234  //          blogEntries.add(blogEntry);
   235  //        }
   236  //      }
   237  //      return blogEntries;
   238  //    }
   239  //  }
   240  
   241  //  /**
   242  //   * Gets a Collection containing all the blog entries for this day and the
   243  //   * specified tag.
   244  //   *
   245  //   * @param     tag    a Strng
   246  //   * @return    an ordered List of BlogEntry instances
   247  //   */
   248  //  public List getEntries(String tag) {
   249  //    if (tag == null) {
   250  //      return this.getEntries();
   251  //    } else {
   252  //      List blogEntries = new ArrayList();
   253  //      Iterator it = getEntries().iterator();
   254  //      while (it.hasNext()) {
   255  //        BlogEntry blogEntry = (BlogEntry)it.next();
   256  //        if (blogEntry.hasTag(tag)) {
   257  //          blogEntries.add(blogEntry);
   258  //        }
   259  //      }
   260  //      return blogEntries;
   261  //    }
   262  //  }
   263  
   264  //  /**
   265  //   * Gets a specific blog entry.
   266  //   *
   267  //   * @param entryId   the blog entry id
   268  //   * @return  the corresponding BlogEntry instance, or null if a BlogEntry
   269  //   *          with the specified id doesn't exist
   270  //   */
   271  //  public BlogEntry getEntry(String entryId) {
   272  //    Iterator it = entries.iterator();
   273  //    BlogEntry blogEntry;
   274  //    while (it.hasNext()) {
   275  //      blogEntry = (BlogEntry)it.next();
   276  //      if (blogEntry.getId().equals(entryId)) {
   277  //        return blogEntry;
   278  //      }
   279  //    }
   280  //    return null;
   281  //  }
   282  
   283  //  /**
   284  //   * Adds a given blog entry.
   285  //   *
   286  //   * @param entry   the BlogEntry instance to add
   287  //   */
   288  //  public synchronized void addEntry(BlogEntry entry) {
   289  //    if (entry == null) {
   290  //      return;
   291  //    }
   292  //
   293  //    BlogEntry existing = getEntry(entry.getId());
   294  //    if (existing != null && existing != entry) {
   295  //      // there is already an entry with the same ID, so increment and try again
   296  //      entry.setDate(new Date(entry.getDate().getTime() + 1));
   297  //      addEntry(entry);
   298  //    } else if (!entries.contains(entry)) {
   299  //      entries.add(entry);
   300  //      Collections.sort(entries, new BlogEntryComparator());
   301  //      entry.setDay(this);
   302  //      entry.setType(BlogEntry.PUBLISHED);
   303  //
   304  //      // now that the entries have been loaded, enable events
   305  //      // so that listeners get notified when they change
   306  //      entry.setEventsEnabled(true);
   307  //
   308  //      // and notify listeners
   309  //      ((Blog)getBlog()).getEventDispatcher().fireBlogEntryEvent(new BlogEntryEvent(entry, BlogEntryEvent.BLOG_ENTRY_ADDED));
   310  //    }
   311  //  }
   312  
   313  //  /**
   314  //   * Removes a given blog entry.
   315  //   *
   316  //   * @param entry   the BlogEntry instance to remove
   317  //   */
   318  //  public synchronized void removeEntry(BlogEntry entry) {
   319  //    if (entry != null) {
   320  //      getBlog().getEventDispatcher().fireBlogEntryEvent(new BlogEntryEvent(entry, BlogEntryEvent.BLOG_ENTRY_REMOVED));
   321  //      entries.remove(entry);
   322  //      entry.setDay(null);
   323  //    }
   324  //  }
   325  
   326    /**
   327     * Determines whether this day has entries.
   328     *
   329     * @return    true if this blog contains entries, false otherwise
   330     */
   331    public boolean hasBlogEntries() {
             /* 
    P/P       *  Method: bool hasBlogEntries()
              * 
              *  Preconditions:
              *    this.publishedBlogEntries != null
              * 
              *  Postconditions:
              *    init'ed(return_value)
              */
   332      return !publishedBlogEntries.isEmpty();
   333    }
   334  
   335    /**
   336     * Gets the Day instance for the previous day.
   337     *
   338     * @return    a Day instance
   339     */
   340    public Day getPreviousDay() {
             /* 
    P/P       *  Method: Day getPreviousDay()
              * 
              *  Preconditions:
              *    init'ed(this.day)
              *    this.month != null
              *    (soft) this.day <= this.month.dailyBlogs.length + 1
              *    (soft) this.month.dailyBlogs != null
              *    (soft) this.month.dailyBlogs.length >= 1
              *    (soft) init'ed(this.month.dailyBlogs[...])
              *    (soft) init'ed(this.month.lastDayInMonth)
              *    (soft) this.month.year != null
              *    (soft) this.month.year.blog != null
              *    (soft) this.month.year.months != null
              * 
              *  Postconditions:
              *    init'ed(return_value)
              * 
              *  Preconditions:
              *    (soft) this.month.month <= 13
              *    (soft) this.month.month <= this.month.year.months.length + 1
              *    (soft) this.month.year.blog.years != null
              *    (soft) init'ed(this.month.year.months[...])
              *    (soft) this.month.year.year >= -231+1
              * 
              *  Postconditions:
              *    init'ed(new ArrayList(Day#1) num objects)
              *    init'ed(new ArrayList(Day#2) num objects)
              *    init'ed(new ArrayList(Day#3) num objects)
              *    init'ed(new Day(Month#2) num objects)
              *    init'ed(new Day(Month#2).blog)
              *    init'ed(new Day(Month#2).blogEntries)
              *    init'ed(new Day(Month#2).date)
              *    init'ed(new Day(Month#2).day)
              *    init'ed(new Day(Month#2).month)
              *    init'ed(new Day(Month#2).publishedBlogEntries)
              *    ...
              */
   341      return month.getBlogForPreviousDay(this);
   342    }
   343  
   344    /**
   345     * Gets the Day instance for the next day.
   346     *
   347     * @return    a Day instance
   348     */
   349    public Day getNextDay() {
             /* 
    P/P       *  Method: Day getNextDay()
              * 
              *  Preconditions:
              *    init'ed(this.day)
              *    this.day - this.month.lastDayInMonth in -232+1..6_442_450_943
              *    this.month != null
              *    init'ed(this.month.lastDayInMonth)
              *    (soft) this.day < this.month.dailyBlogs.length
              *    (soft) this.month.dailyBlogs != null
              *    (soft) this.month.dailyBlogs.length >= 1
              *    (soft) init'ed(this.month.dailyBlogs[...])
              *    (soft) this.month.month - this.month.year.months.length in {-Inf..-1, 12..232-1}
              *    (soft) this.month.year != null
              *    ...
              * 
              *  Postconditions:
              *    init'ed(return_value)
              * 
              *  Preconditions:
              *    (soft) this.month.month >= 0
              *    (soft) this.month.year.blog.years != null
              *    (soft) init'ed(this.month.year.months[...])
              *    (soft) this.month.year.year <= 232-2
              * 
              *  Postconditions:
              *    init'ed(new ArrayList(Day#1) num objects)
              *    init'ed(new ArrayList(Day#2) num objects)
              *    init'ed(new ArrayList(Day#3) num objects)
              *    init'ed(new Day(Month#2) num objects)
              *    init'ed(new Day(Month#2).blog)
              *    init'ed(new Day(Month#2).blogEntries)
              *    init'ed(new Day(Month#2).date)
              *    init'ed(new Day(Month#2).day)
              *    init'ed(new Day(Month#2).month)
              *    init'ed(new Day(Month#2).publishedBlogEntries)
              *    ...
              */
   350      return month.getBlogForNextDay(this);
   351    }
   352  
   353    /**
   354     * Gets the blog entry posted previous (before) to the one specified.
   355     *
   356     * @param   blogEntry   a BlogEntry
   357     * @return  the previous BlogEntry, or null if one doesn't exist
   358     */
   359    public String getPreviousBlogEntry(String blogEntry) {
             /* 
    P/P       *  Method: String getPreviousBlogEntry(String)
              * 
              *  Preconditions:
              *    this.publishedBlogEntries != null
              * 
              *  Postconditions:
              *    init'ed(return_value)
              * 
              *  Test Vectors:
              *    java.util.List:indexOf(...)@360: {-231..-1}, {0..232-3}
              */
   360      int index = publishedBlogEntries.indexOf(blogEntry);
   361      if (index >= 0 && index < (publishedBlogEntries.size()-1)) {
   362        return publishedBlogEntries.get(index+1);
   363      } else {
   364        return null;
   365      }
   366    }
   367  
   368    /**
   369     * Gets the first entry that was posted on this day.
   370     *
   371     * @return    a BlogEntry instance, or null is no entries have been posted
   372     */
   373    public String getFirstBlogEntry() {
             /* 
    P/P       *  Method: String getFirstBlogEntry()
              * 
              *  Preconditions:
              *    this.publishedBlogEntries != null
              * 
              *  Presumptions:
              *    java.util.List:size(...)@375 >= -231+1
              * 
              *  Postconditions:
              *    init'ed(return_value)
              * 
              *  Test Vectors:
              *    java.util.List:isEmpty(...)@374: {1}, {0}
              */
   374      if (!publishedBlogEntries.isEmpty()) {
   375        return publishedBlogEntries.get(publishedBlogEntries.size()-1);
   376      } else {
   377        return null;
   378      }
   379    }
   380  
   381    /**
   382     * Gets the last entry that was posted on this day.
   383     *
   384     * @return    a BlogEntry instance, or null is no entries have been posted
   385     */
   386    public String getLastBlogEntry() {
             /* 
    P/P       *  Method: String getLastBlogEntry()
              * 
              *  Preconditions:
              *    this.publishedBlogEntries != null
              * 
              *  Postconditions:
              *    init'ed(return_value)
              * 
              *  Test Vectors:
              *    java.util.List:isEmpty(...)@387: {1}, {0}
              */
   387      if (!publishedBlogEntries.isEmpty()) {
   388        return publishedBlogEntries.get(0);
   389      } else {
   390        return null;
   391      }
   392    }
   393  
   394    /**
   395     * Gets the blog entry posted next (afterwards) to the one specified.
   396     *
   397     * @param blogEntry   a BlogEntry
   398     * @return  the next BlogEntry, or null if one doesn't exist
   399     */
   400    public String getNextBlogEntry(String blogEntry) {
             /* 
    P/P       *  Method: String getNextBlogEntry(String)
              * 
              *  Preconditions:
              *    this.publishedBlogEntries != null
              * 
              *  Postconditions:
              *    init'ed(return_value)
              * 
              *  Test Vectors:
              *    java.util.List:lastIndexOf(...)@401: {-231..0}, {1..232-1}
              */
   401      int index = publishedBlogEntries.lastIndexOf(blogEntry);
   402      if (index > 0 && index <= publishedBlogEntries.size()) {
   403        return publishedBlogEntries.get(index-1);
   404      } else {
   405        return null;
   406      }
   407    }
   408  
   409    public Date getStartOfDay() {
             /* 
    P/P       *  Method: Date getStartOfDay()
              * 
              *  Preconditions:
              *    this.blog != null
              *    init'ed(this.day)
              *    this.month != null
              *    this.month.month >= -231+1
              *    this.month.year != null
              *    init'ed(this.month.year.year)
              * 
              *  Postconditions:
              *    init'ed(return_value)
              */
   410      Calendar cal = getCalendar();
   411      cal.set(Calendar.HOUR_OF_DAY, 0);
   412      cal.set(Calendar.MINUTE, 0);
   413      cal.set(Calendar.SECOND, 0);
   414      cal.set(Calendar.MILLISECOND, 1);
   415  
   416      return cal.getTime();
   417    }
   418  
   419    public Date getEndOfDay() {
             /* 
    P/P       *  Method: Date getEndOfDay()
              * 
              *  Preconditions:
              *    this.blog != null
              *    init'ed(this.day)
              *    this.month != null
              *    this.month.month >= -231+1
              *    this.month.year != null
              *    init'ed(this.month.year.year)
              * 
              *  Postconditions:
              *    init'ed(return_value)
              */
   420      Calendar cal = getCalendar();
   421      cal.set(Calendar.HOUR_OF_DAY, 23);
   422      cal.set(Calendar.MINUTE, 59);
   423      cal.set(Calendar.SECOND, 59);
   424      cal.set(Calendar.MILLISECOND, 999);
   425  
   426      return cal.getTime();
   427    }
   428  
   429    /**
   430     * Determines if the this Day is before (in the calendar) the
   431     * specified Day.
   432     *
   433     * @return  true if this instance represents an earlier month than the
   434     *          specified Day instance, false otherwise
   435     */
   436    public boolean before(Day day) {
             /* 
    P/P       *  Method: bool before(Day)
              * 
              *  Preconditions:
              *    day != null
              *    init'ed(day.date)
              *    this.date != null
              * 
              *  Postconditions:
              *    init'ed(return_value)
              */
   437      return getDate().before(day.getDate());
   438    }
   439  
   440  }








SofCheck Inspector Build Version : 2.22510
day.java 2010-Jun-25 19:40:32
day.class 2010-Jul-19 20:23:40