1 25 package org.snipsnap.render.macro; 26 27 import org.radeox.macro.BaseMacro; 28 import org.radeox.macro.parameter.MacroParameter; 29 import org.radeox.util.i18n.ResourceManager; 30 import org.radeox.util.logging.Logger; 31 import org.snipsnap.date.Month; 32 33 import java.io.IOException ; 34 import java.io.Writer ; 35 36 42 43 public class CalendarMacro extends BaseMacro { 44 public String getName() { 45 return "calendar"; 46 } 47 48 public String getDescription() { 49 return ResourceManager.getString("i18n.messages", "macro.calendar.description"); 50 } 51 52 public void execute(Writer writer, MacroParameter params) 53 throws IllegalArgumentException , IOException { 54 int year = -1; 55 int month = -1; 56 int paramCount = params.getLength(); 57 58 if (paramCount==2) { 59 try { 60 year = Integer.parseInt(params.get("0")); 61 } catch (NumberFormatException e) { 62 } 64 try { 65 month = Integer.parseInt(params.get("1")); 66 } catch (NumberFormatException e) { 67 } 69 } else if (params.getLength() > 0) { 70 Logger.warn("CalendarMacro: illegal number of arguments: " + params.getLength()); 71 } 72 73 Month m = new Month(); 74 if (-1 == year || -1 == month) { 75 writer.write(m.getView(paramCount==2)); 76 } else { 77 writer.write(m.getView(month, year, paramCount==2)); 79 } 80 } 81 } 82 | Popular Tags |