1 package de.java2html.plugin; 2 3 import java.util.Map ; 4 5 import com.ecyrd.jspwiki.plugin.PluginException; 6 7 10 public class ParameterUtilities { 11 private ParameterUtilities() { 12 } 14 15 public static String getParameter(Map params, IParameter parameter) { 16 String stringValue = null; 17 Object value = params.get(parameter.getName()); 18 if (value != null && value instanceof String ) { 19 stringValue = (String ) value; 20 } 21 return stringValue; 22 } 23 24 public static int getInt(String intString) throws PluginException { 25 try { 26 return Integer.parseInt(intString); 27 } 28 catch (NumberFormatException e) { 29 throw new PluginException("Illegal value for integer '" + intString + "'"); 30 } 31 } 32 33 public static boolean getBoolean(String booleanString) throws PluginException { 34 if ("true".equals(booleanString) || "on".equals(booleanString)) { 35 return true; 36 } 37 if ("false".equals(booleanString) || "off".equals(booleanString)) { 38 return false; 39 } 40 throw new PluginException("Illegal value for boolean '" + booleanString + "'"); 41 } 42 } | Popular Tags |