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 import org.blojsom.util.BlojsomUtils; 38 39 import javax.servlet.http.HttpServletRequest ; 40 import javax.servlet.http.HttpServletResponse ; 41 import java.util.Map ; 42 43 50 public class ConvertLineBreaksPlugin implements Plugin { 51 52 55 public ConvertLineBreaksPlugin() { 56 } 57 58 64 public void init() throws PluginException { 65 } 66 67 78 public Entry[] process(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Blog blog, Map context, Entry[] entries) throws PluginException { 79 for (int i = 0; i < entries.length; i++) { 80 Entry entry = entries[i]; 81 String description = entry.getDescription(); 82 if (!BlojsomUtils.checkNullOrBlank(description)) { 83 description = BlojsomUtils.replace(description, "\n", "<br />"); 84 entry.setDescription(description); 85 } 86 } 87 88 return entries; 89 } 90 91 97 public void cleanup() throws PluginException { 98 } 99 100 106 public void destroy() throws PluginException { 107 } 108 } | Popular Tags |