availableplugins.java

### File Source: availableplugins.java

             /*
        P/P   *  Method: net.sourceforge.pebble.plugins.AvailablePlugins__static_init
              */
         1  /*
         2   * Copyright (c) 2003-2005, 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.plugins;
        33
        34  import java.util.*;
        35
        36  /**
        37   * @author James Roper
        38   */
        39  public class AvailablePlugins {
        40    public static final String PERMALINK_PROVIDER = "permalink-provider";
        41    public static final String CONTENT_DECORATOR = "content-decorator";
        42    public static final String BLOG_LISTENER = "blog-listener";
        43    public static final String BLOG_ENTRY_LISTENER = "blog-entry-listener";
        44    public static final String COMMENT_LISTENER = "comment-listener";
        45    public static final String COMMENT_CONFIRMATION_STRATEGY = "comment-confirmation-strategy";
        46    public static final String TRACKBACK_LISTENER = "trackback-listener";
        47    public static final String TRACKBACK_CONFIRMATION_STRATEGY = "trackback-confirmation-strategy";
        48    public static final String LUCENCE_ANALYZER = "lucene-analyzer";
        49    public static final String LOGGER = "logger";
        50
        51    private final Map<String, List<Plugin>> plugins;
        52
        53    public Map<String, List<Plugin>> copyMap()
        54    {
                 /*
        P/P       *  Method: Map copyMap()
                  *
                  *  Preconditions:
                  *    this.plugins != null
                  *
                  *  Presumptions:
                  *    java.util.Iterator:next(...)@56 != null
                  *    java.util.Map:entrySet(...)@56 != null
                  *
                  *  Postconditions:
                  *    return_value == &new HashMap(copyMap#1)
                  *    new HashMap(copyMap#1) num objects == 1
                  *
                  *  Test Vectors:
                  *    java.util.Iterator:hasNext(...)@56: {1}, {0}
                  */
        55      Map<String, List<Plugin>> map = new HashMap<String, List<Plugin>>();
        56      for (Map.Entry<String, List<Plugin>> entry : plugins.entrySet())
        57      {
        58        map.put(entry.getKey(), new ArrayList<Plugin>(entry.getValue()));
        59      }
        60      return map;
        61    }
        62
               /*
        P/P     *  Method: void net.sourceforge.pebble.plugins.AvailablePlugins(Map)
                *
                *  Postconditions:
                *    this.plugins == plugins
                *    init'ed(this.plugins)
                */
        63    public AvailablePlugins(Map<String, List<Plugin>> plugins) {
        64      this.plugins = plugins;
        65    }
        66
        67    public Collection<Plugin> getPermalinkProviders() {
                 /*
        P/P       *  Method: Collection getPermalinkProviders()
                  *
                  *  Preconditions:
                  *    this.plugins != null
                  *
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
        68      return getEmptyIfNull(PERMALINK_PROVIDER);
        69    }
        70
        71    public Collection<Plugin> getContentDecorators() {
                 /*
        P/P       *  Method: Collection getContentDecorators()
                  *
                  *  Preconditions:
                  *    this.plugins != null
                  *
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
        72      return getEmptyIfNull(CONTENT_DECORATOR);
        73    }
        74
        75    public Collection<Plugin> getBlogListeners() {
                 /*
        P/P       *  Method: Collection getBlogListeners()
                  *
                  *  Preconditions:
                  *    this.plugins != null
                  *
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
        76      return getEmptyIfNull(BLOG_LISTENER);
        77    }
        78
        79    public Collection<Plugin> getBlogEntryListeners() {
                 /*
        P/P       *  Method: Collection getBlogEntryListeners()
                  *
                  *  Preconditions:
                  *    this.plugins != null
                  *
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
        80      return getEmptyIfNull(BLOG_ENTRY_LISTENER);
        81    }
        82
        83    public Collection<Plugin> getCommentListeners() {
                 /*
        P/P       *  Method: Collection getCommentListeners()
                  *
                  *  Preconditions:
                  *    this.plugins != null
                  *
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
        84      return getEmptyIfNull(COMMENT_LISTENER);
        85    }
        86
        87    public Collection<Plugin> getCommentConfirmationStrategies() {
                 /*
        P/P       *  Method: Collection getCommentConfirmationStrategies()
                  *
                  *  Preconditions:
                  *    this.plugins != null
                  *
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
        88      return getEmptyIfNull(COMMENT_CONFIRMATION_STRATEGY);
        89    }
        90
        91    public Collection<Plugin> getTrackbackListeners() {
                 /*
        P/P       *  Method: Collection getTrackbackListeners()
                  *
                  *  Preconditions:
                  *    this.plugins != null
                  *
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
        92      return getEmptyIfNull(TRACKBACK_LISTENER);
        93    }
        94
        95    public Collection<Plugin> getTrackbackConfirmationStrategies() {
                 /*
        P/P       *  Method: Collection getTrackbackConfirmationStrategies()
                  *
                  *  Preconditions:
                  *    this.plugins != null
                  *
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
        96      return getEmptyIfNull(TRACKBACK_CONFIRMATION_STRATEGY);
        97    }
        98
        99    public Collection<Plugin> getLuceneAnalyzers() {
                 /*
        P/P       *  Method: Collection getLuceneAnalyzers()
                  *
                  *  Preconditions:
                  *    this.plugins != null
                  *
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
       100      return getEmptyIfNull(LUCENCE_ANALYZER);
       101    }
       102
       103    public Collection<Plugin> getLoggers() {
                 /*
        P/P       *  Method: Collection getLoggers()
                  *
                  *  Preconditions:
                  *    this.plugins != null
                  *
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
       104      return getEmptyIfNull(LOGGER);
       105    }
       106
       107    private Collection<Plugin> getEmptyIfNull(String key) {
                 /*
        P/P       *  Method: Collection getEmptyIfNull(String)
                  *
                  *  Preconditions:
                  *    this.plugins != null
                  *
                  *  Postconditions:
                  *    init'ed(return_value)
                  *
                  *  Test Vectors:
                  *    java.util.Map:get(...)@108: Inverse{null}, Addr_Set{null}
                  */
       108      Collection<Plugin> list = plugins.get(key);
       109      if (list == null) {
       110        return Collections.emptyList();
       111      }
       112      else {
       113        return Collections.unmodifiableCollection(list);
       114      }
       115    }
       116
       117  }

SofCheck Inspector Build Version : 2.22510

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