1 25 26 package org.snipsnap.render.macro; 27 28 import org.snipsnap.render.macro.parameter.SnipMacroParameter; 29 import org.snipsnap.snip.SnipSpaceFactory; 30 import org.radeox.util.i18n.ResourceManager; 31 32 import java.io.IOException ; 33 import java.io.Writer ; 34 import java.util.Collection ; 35 import java.text.MessageFormat ; 36 37 43 44 public class UserSnipMacro extends ListOutputMacro { 45 public String getName() { 46 return "snips-by-user"; 47 } 48 49 public String getDescription() { 50 return ResourceManager.getString("i18n.messages", "macro.snipsbyuser.description"); 51 } 52 53 public String [] getParamDescription() { 54 return ResourceManager.getString("i18n.messages", "macro.snipsbyuser.params").split(";"); 55 } 56 57 public void execute(Writer writer, SnipMacroParameter params) 58 throws IllegalArgumentException , IOException { 59 String type = null; 60 boolean showSize = true; 61 if (params.getLength() > 1) { 62 type = params.get("1"); 63 } 64 65 if (params.getLength() > 0) { 66 Collection c = SnipSpaceFactory.getInstance().getByUser(params.get("0")); 67 MessageFormat mf = new MessageFormat (ResourceManager.getString("i18n.messages", "macro.snipsbyuser.title"), 68 ResourceManager.getLocale("i18n.messages")); 69 output(writer, params.getSnipRenderContext().getSnip(), 70 mf.format(new Object [] { params.get("0") }), 71 c, ResourceManager.getString("i18n.messages", "macro.snipsbyuser.nosnips"), 72 type, showSize); 73 } else { 74 throw new IllegalArgumentException ("Number of arguments does not match"); 75 } 76 } 77 } 78 | Popular Tags |