| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
|
| 20 | |
|
| 21 | |
|
| 22 | |
|
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
package net.sourceforge.pebble.plugins; |
| 33 | |
|
| 34 | |
import java.util.*; |
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 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 | |
} |