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 36 43 44 public class UserSnipCountMacro extends ListOutputMacro { 45 public String getName() { 46 return "snip-count-by-user"; 47 } 48 49 public String getDescription() { 50 return ResourceManager.getString("i18n.messages", "macro.usersnips.description"); 51 52 } 53 54 public String [] getParamDescription() { 55 return ResourceManager.getString("i18n.messages", "macro.usersnips.params").split(";"); 56 } 57 58 public void execute(Writer writer, SnipMacroParameter params) 59 throws IllegalArgumentException , IOException { 60 61 if (params.getLength() == 1) { 62 Collection c = SnipSpaceFactory.getInstance().getByUser(params.get("0")); 63 writer.write(""+c.size()); 64 } else { 65 throw new IllegalArgumentException ("Number of arguments does not match"); 66 } 67 } 68 } 69 | Popular Tags |