| 1 31 package org.blojsom.plugin.common; 32 33 import org.blojsom.blog.Blog; 34 import org.blojsom.blog.Entry; 35 import org.blojsom.plugin.Plugin; 36 import org.blojsom.plugin.PluginException; 37 38 import javax.servlet.http.HttpServletRequest ; 39 import javax.servlet.http.HttpServletResponse ; 40 import java.util.Collections ; 41 import java.util.List ; 42 import java.util.Map ; 43 44 51 public class CollectionUtilitiesPlugin implements Plugin { 52 53 private static final String BLOJSOM_PLUGIN_COLLECTION_UTILITIES = "BLOJSOM_PLUGIN_COLLECTION_UTILITIES"; 54 55 58 public CollectionUtilitiesPlugin() { 59 } 60 61 67 public void init() throws PluginException { 68 } 69 70 81 public Entry[] process(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Blog blog, Map context, Entry[] entries) throws PluginException { 82 context.put(BLOJSOM_PLUGIN_COLLECTION_UTILITIES, new CollectionUtilities()); 83 84 return entries; 85 } 86 87 93 public void cleanup() throws PluginException { 94 } 95 96 102 public void destroy() throws PluginException { 103 } 104 105 108 public class CollectionUtilities { 109 110 113 public CollectionUtilities() { 114 } 115 116 122 public List reverse(List input) { 123 if (input == null || input.size() == 0) { 124 return input; 125 } 126 127 Collections.reverse(input); 128 129 return input; 130 } 131 } 132 } 133 | Popular Tags |