categoryindexlistener.java

### File Source: categoryindexlistener.java

             /*
        P/P   *  Method: net.sourceforge.pebble.index.CategoryIndexListener__static_init
              */
         1  package net.sourceforge.pebble.index;
         2
         3  import net.sourceforge.pebble.domain.BlogEntry;
         4  import net.sourceforge.pebble.api.event.blogentry.BlogEntryEvent;
         5  import net.sourceforge.pebble.api.event.blogentry.BlogEntryListener;
         6
         7  import java.beans.PropertyChangeEvent;
         8  import java.util.Iterator;
         9  import java.util.List;
        10
             /*
        P/P   *  Method: void net.sourceforge.pebble.index.CategoryIndexListener()
              */
        11  public class CategoryIndexListener implements BlogEntryListener {
        12
        13    /**
        14     * Called when a blog entry has been added.
        15     *
        16     * @param event a BlogEntryEvent instance
        17     */
        18    public void blogEntryAdded(BlogEntryEvent event) {
                 /*
        P/P       *  Method: void blogEntryAdded(BlogEntryEvent)
                  *
                  *  Preconditions:
                  *    event != null
                  *    (soft) net.sourceforge.pebble.domain.State__static_init.new State(State__static_init#5).name != null
                  *
                  *  Presumptions:
                  *    blogEntry.blog@20 != null
                  *    blogEntry.state@19 != null
                  *    blogEntry.state@20 != null
                  *    net.sourceforge.pebble.api.event.blogentry.BlogEntryEvent:getSource(...)@91 != null
                  *    getBlog(...).categoryIndex@20 != null
                  *    ...
                  *
                  *  Postconditions:
                  *    init'ed(new ArrayList(Category#1) num objects)
                  *    init'ed(new ArrayList(Category#2) num objects)
                  *    init'ed(new ArrayList(Category#3) num objects)
                  *    init'ed(new Category(getCategory#2) num objects)
                  *    possibly_updated(new Category(getCategory#2).blog)
                  *    init'ed(new Category(getCategory#2).blogEntries)
                  *    possibly_updated(new Category(getCategory#2).id)
                  *    init'ed(new Category(getCategory#2).name)
                  *    possibly_updated(new Category(getCategory#2).parent)
                  *    init'ed(new Category(getCategory#2).subCategories)
                  *    ...
                  */
        19      BlogEntry blogEntry = event.getBlogEntry();
        20      if (blogEntry.isPublished()) {
        21        blogEntry.getBlog().getCategoryIndex().index(blogEntry);
        22      }
        23    }
        24
        25    /**
        26     * Called when a blog entry has been removed.
        27     *
        28     * @param event a BlogEntryEvent instance
        29     */
        30    public void blogEntryRemoved(BlogEntryEvent event) {
                 /*
        P/P       *  Method: void blogEntryRemoved(BlogEntryEvent)
                  *
                  *  Preconditions:
                  *    event != null
                  *    (soft) net.sourceforge.pebble.domain.State__static_init.new State(State__static_init#5).name != null
                  *
                  *  Presumptions:
                  *    blogEntry.blog@32 != null
                  *    blogEntry.state@31 != null
                  *    net.sourceforge.pebble.api.event.blogentry.BlogEntryEvent:getSource(...)@91 != null
                  *    getBlog(...).categoryIndex@32 != null
                  *    getCategoryIndex(...).blog@32 != null
                  *
                  *  Postconditions:
                  *    init'ed(new ArrayList(Category#1) num objects)
                  *    init'ed(new ArrayList(Category#2) num objects)
                  *    init'ed(new ArrayList(Category#3) num objects)
                  *    init'ed(new Category(getCategory#2) num objects)
                  *    possibly_updated(new Category(getCategory#2).blog)
                  *    init'ed(new Category(getCategory#2).blogEntries)
                  *    possibly_updated(new Category(getCategory#2).id)
                  *    init'ed(new Category(getCategory#2).name)
                  *    possibly_updated(new Category(getCategory#2).parent)
                  *    possibly_updated(new Category(getCategory#2).subCategories)
                  *    ...
                  */
        31      BlogEntry blogEntry = event.getBlogEntry();
        32      if (blogEntry.isPublished()) {
        33        blogEntry.getBlog().getCategoryIndex().unindex(blogEntry);
        34      }
        35    }
        36
        37    /**
        38     * Called when a blog entry has been changed.
        39     *
        40     * @param event a BlogEntryEvent instance
        41     */
        42    public void blogEntryChanged(BlogEntryEvent event) {
                 /*
        P/P       *  Method: void blogEntryChanged(BlogEntryEvent)
                  *
                  *  Preconditions:
                  *    event != null
                  *    (soft) event.propertyChangeEvents != null
                  *    (soft) net.sourceforge.pebble.domain.State__static_init.new State(State__static_init#5).name != null
                  *
                  *  Presumptions:
                  *    blogEntry.blog@45 != null
                  *    blogEntry.blog@54 != null
                  *    blogEntry.state@43 != null
                  *    blogEntry.state@54 != null
                  *    java.beans.PropertyChangeEvent:getPropertyName(...)@50 != null
                  *    ...
                  *
                  *  Test Vectors:
                  *    java.lang.String:equals(...)@53: {0}, {1}
                  *    java.util.Iterator:hasNext(...)@48: {1}, {0}
                  *
                  *  Presumptions:
                  *    getBlog(...).categoryIndex@45 != null
                  *    getBlog(...).categoryIndex@54 != null
                  *    getCategoryIndex(...).blog@45 != null
                  *    getCategoryIndex(...).blog@54 != null
                  *
                  *  Postconditions:
                  *    init'ed(new ArrayList(Category#1) num objects)
                  *    init'ed(new ArrayList(Category#2) num objects)
                  *    init'ed(new ArrayList(Category#3) num objects)
                  *    init'ed(new Category(getCategory#2) num objects)
                  *    init'ed(new Category(getCategory#2).blog)
                  *    init'ed(new Category(getCategory#2).blogEntries)
                  *    init'ed(new Category(getCategory#2).id)
                  *    init'ed(new Category(getCategory#2).name)
                  *    init'ed(new Category(getCategory#2).parent)
                  *    init'ed(new Category(getCategory#2).subCategories)
                  *    ...
                  */
        43      BlogEntry blogEntry = event.getBlogEntry();
        44
        45      if (blogEntry.isPublished()) {
        46        List propertyChangeEvents = event.getPropertyChangeEvents();
        47        Iterator it = propertyChangeEvents.iterator();
        48        while (it.hasNext()) {
        49          PropertyChangeEvent pce = (PropertyChangeEvent)it.next();
        50          String property = pce.getPropertyName();
        51
        52          // only if the tags or categories change do we need to reindex the tags
        53          if (property.equals(BlogEntry.CATEGORIES_PROPERTY)) {
        54            blogEntry.getBlog().getCategoryIndex().unindex(blogEntry);
        55            blogEntry.getBlog().getCategoryIndex().index(blogEntry);
        56          }
        57        }
        58      }
        59    }
        60
        61    /**
        62     * Called when a blog entry has been published.
        63     *
        64     * @param event a BlogEntryEvent instance
        65     */
        66    public void blogEntryPublished(BlogEntryEvent event) {
                 /*
        P/P       *  Method: void blogEntryPublished(BlogEntryEvent)
                  *
                  *  Preconditions:
                  *    event != null
                  *    (soft) net.sourceforge.pebble.domain.State__static_init.new State(State__static_init#5).name != null
                  *
                  *  Presumptions:
                  *    blogEntry.blog@67 != null
                  *    blogEntry.state@67 != null
                  *    net.sourceforge.pebble.api.event.blogentry.BlogEntryEvent:getSource(...)@91 != null
                  *    getBlog(...).categoryIndex@67 != null
                  *    getCategoryIndex(...).blog@67 != null
                  *
                  *  Postconditions:
                  *    init'ed(new ArrayList(Category#1) num objects)
                  *    init'ed(new ArrayList(Category#2) num objects)
                  *    init'ed(new ArrayList(Category#3) num objects)
                  *    init'ed(new Category(getCategory#2) num objects)
                  *    possibly_updated(new Category(getCategory#2).blog)
                  *    init'ed(new Category(getCategory#2).blogEntries)
                  *    possibly_updated(new Category(getCategory#2).id)
                  *    init'ed(new Category(getCategory#2).name)
                  *    possibly_updated(new Category(getCategory#2).parent)
                  *    init'ed(new Category(getCategory#2).subCategories)
                  *    ...
                  */
        67      BlogEntry blogEntry = event.getBlogEntry();
        68      blogEntry.getBlog().getCategoryIndex().index(blogEntry);
        69    }
        70
        71    /**
        72     * Called when a blog entry has been unpublished.
        73     *
        74     * @param event a BlogEntryEvent instance
        75     */
        76    public void blogEntryUnpublished(BlogEntryEvent event) {
                 /*
        P/P       *  Method: void blogEntryUnpublished(BlogEntryEvent)
                  *
                  *  Preconditions:
                  *    event != null
                  *
                  *  Presumptions:
                  *    blogEntry.blog@77 != null
                  *    net.sourceforge.pebble.api.event.blogentry.BlogEntryEvent:getSource(...)@91 != null
                  *    getBlog(...).categoryIndex@77 != null
                  *    getCategoryIndex(...).blog@77 != null
                  *
                  *  Postconditions:
                  *    init'ed(new ArrayList(Category#1) num objects)
                  *    init'ed(new ArrayList(Category#2) num objects)
                  *    init'ed(new ArrayList(Category#3) num objects)
                  *    init'ed(new Category(getCategory#2) num objects)
                  *    possibly_updated(new Category(getCategory#2).blog)
                  *    init'ed(new Category(getCategory#2).blogEntries)
                  *    possibly_updated(new Category(getCategory#2).id)
                  *    init'ed(new Category(getCategory#2).name)
                  *    possibly_updated(new Category(getCategory#2).parent)
                  *    possibly_updated(new Category(getCategory#2).subCategories)
                  *    ...
                  */
        77      BlogEntry blogEntry = event.getBlogEntry();
        78      blogEntry.getBlog().getCategoryIndex().unindex(blogEntry);
        79    }
        80
        81  }

SofCheck Inspector Build Version : 2.22510

categoryindexlistener.java | 2010-Jun-25 19:40:32
categoryindexlistener.class | 2010-Jul-19 20:23:38