Coverage Report - net.sourceforge.pebble.plugins.AvailablePlugins
 
Classes in this File Line Coverage Branch Coverage Complexity
AvailablePlugins
0%
0/24
0%
0/4
1.188
 
 1  
 /*
 2  
  * Copyright (c) 2003-2011, 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  
   public static final String PAGE_DECORATOR = "page-decorator";
 51  
   public static final String OPEN_ID_COMMENT_AUTHOR_PROVIDER = "open-id-comment-author-provider";
 52  
   public static final String FEED_DECORATOR = "feed-decorator";
 53  
 
 54  
   private final Map<String, List<Plugin>> plugins;
 55  
 
 56  
   public Map<String, List<Plugin>> copyMap()
 57  
   {
 58  0
     Map<String, List<Plugin>> map = new HashMap<String, List<Plugin>>();
 59  0
     for (Map.Entry<String, List<Plugin>> entry : plugins.entrySet())
 60  
     {
 61  0
       map.put(entry.getKey(), new ArrayList<Plugin>(entry.getValue()));
 62  
     }
 63  0
     return map;
 64  
   }
 65  
 
 66  0
   public AvailablePlugins(Map<String, List<Plugin>> plugins) {
 67  0
     this.plugins = plugins;
 68  0
   }
 69  
 
 70  
   public Collection<Plugin> getPermalinkProviders() {
 71  0
     return getEmptyIfNull(PERMALINK_PROVIDER);
 72  
   }
 73  
 
 74  
   public Collection<Plugin> getContentDecorators() {
 75  0
     return getEmptyIfNull(CONTENT_DECORATOR);
 76  
   }
 77  
 
 78  
   public Collection<Plugin> getBlogListeners() {
 79  0
     return getEmptyIfNull(BLOG_LISTENER);
 80  
   }
 81  
 
 82  
   public Collection<Plugin> getBlogEntryListeners() {
 83  0
     return getEmptyIfNull(BLOG_ENTRY_LISTENER);
 84  
   }
 85  
 
 86  
   public Collection<Plugin> getCommentListeners() {
 87  0
     return getEmptyIfNull(COMMENT_LISTENER);
 88  
   }
 89  
 
 90  
   public Collection<Plugin> getCommentConfirmationStrategies() {
 91  0
     return getEmptyIfNull(COMMENT_CONFIRMATION_STRATEGY);
 92  
   }
 93  
 
 94  
   public Collection<Plugin> getTrackbackListeners() {
 95  0
     return getEmptyIfNull(TRACKBACK_LISTENER);
 96  
   }
 97  
 
 98  
   public Collection<Plugin> getTrackbackConfirmationStrategies() {
 99  0
     return getEmptyIfNull(TRACKBACK_CONFIRMATION_STRATEGY);
 100  
   }
 101  
 
 102  
   public Collection<Plugin> getLuceneAnalyzers() {
 103  0
     return getEmptyIfNull(LUCENCE_ANALYZER);
 104  
   }
 105  
 
 106  
   public Collection<Plugin> getLoggers() {
 107  0
     return getEmptyIfNull(LOGGER);
 108  
   }
 109  
 
 110  
   public Collection<Plugin> getPageDecorators() {
 111  0
     return getEmptyIfNull(PAGE_DECORATOR);
 112  
   }
 113  
   
 114  
   public Collection<Plugin> getOpenIdCommentAuthorProviders() {
 115  0
     return getEmptyIfNull(OPEN_ID_COMMENT_AUTHOR_PROVIDER);
 116  
   }
 117  
 
 118  
   public Collection<Plugin> getFeedDecorators() {
 119  0
     return getEmptyIfNull(FEED_DECORATOR);
 120  
   }
 121  
 
 122  
   private Collection<Plugin> getEmptyIfNull(String key) {
 123  0
     Collection<Plugin> list = plugins.get(key);
 124  0
     if (list == null) {
 125  0
       return Collections.emptyList();
 126  
     }
 127  
     else {
 128  0
       return Collections.unmodifiableCollection(list);
 129  
     }
 130  
   }
 131  
 
 132  
 }