KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > java2html > plugin > ParameterUtilities


1 package de.java2html.plugin;
2
3 import java.util.Map JavaDoc;
4
5 import com.ecyrd.jspwiki.plugin.PluginException;
6
7 /**
8  * @author Markus Gebhard
9  */

10 public class ParameterUtilities {
11   private ParameterUtilities() {
12     //nothing to do
13
}
14
15   public static String JavaDoc getParameter(Map JavaDoc params, IParameter parameter) {
16     String JavaDoc stringValue = null;
17     Object JavaDoc value = params.get(parameter.getName());
18     if (value != null && value instanceof String JavaDoc) {
19       stringValue = (String JavaDoc) value;
20     }
21     return stringValue;
22   }
23
24   public static int getInt(String JavaDoc intString) throws PluginException {
25     try {
26       return Integer.parseInt(intString);
27     }
28     catch (NumberFormatException JavaDoc e) {
29       throw new PluginException("Illegal value for integer '" + intString + "'");
30     }
31   }
32
33   public static boolean getBoolean(String JavaDoc 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