1 25 package org.snipsnap.render.macro; 26 27 import org.radeox.util.logging.Logger; 28 import org.radeox.util.i18n.ResourceManager; 29 import org.snipsnap.render.macro.parameter.SnipMacroParameter; 30 import org.snipsnap.snip.SnipSpaceFactory; 31 32 import java.io.IOException ; 33 import java.io.Writer ; 34 import java.util.List ; 35 36 42 43 public class RecentChangesMacro extends ListOutputMacro { 44 public String getName() { 45 return "recent-changes"; 46 } 47 48 public String getDescription() { 49 return ResourceManager.getString("i18n.messages", "macro.recentchanges.description"); 50 } 51 52 public String [] getParamDescription() { 53 return ResourceManager.getString("i18n.messages", "macro.recentchanges.params").split(";"); 54 } 55 56 public void execute(Writer writer, SnipMacroParameter params) 57 throws IllegalArgumentException , IOException { 58 59 String type = "Vertical"; 60 boolean showSize = false; 61 int length = 10; 62 if (params.getLength() > 0) { 63 try { 64 length = Integer.parseInt(params.get("0")); 65 } catch (NumberFormatException e) { 66 Logger.warn("RecentChangesMacro: illegal parameter count='" + params.get("1") + "'"); 67 } 68 } 69 if (params.getLength() > 1) { 70 type = params.get("1"); 71 } 72 73 if (params.getLength() <= 3) { 74 List changed = SnipSpaceFactory.getInstance().getChanged(length); 75 output(writer, params.getSnipRenderContext().getSnip(), 76 ResourceManager.getString("i18n.messages", "macro.recentchanges.title"), 77 changed, 78 ResourceManager.getString("i18n.messages", "macro.recentchanges.nochanges"), 79 type, showSize); 80 } else { 81 throw new IllegalArgumentException ("Number of arguments does not match"); 82 } 83 } 84 } 85 | Popular Tags |