Source Code Cross Referenced for ParamUtils.java in  » Forum » nemesis-forum » org » nemesis » forum » webapp » front » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Forum » nemesis forum » org.nemesis.forum.webapp.front 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * NEMESIS-FORUM.
003:         * Copyright (C) 2002  David Laurent(lithium2@free.fr). All rights reserved.
004:         * 
005:         * Copyright (c) 2000 The Apache Software Foundation. All rights reserved.
006:         * 
007:         * Copyright (C) 2001 Yasna.com. All rights reserved.
008:         * 
009:         * Copyright (C) 2000 CoolServlets.com. All rights reserved.
010:         * 
011:         * NEMESIS-FORUM. is free software; you can redistribute it and/or
012:         * modify it under the terms of the Apache Software License, Version 1.1,
013:         * or (at your option) any later version.
014:         * 
015:         * NEMESIS-FORUM core framework, NEMESIS-FORUM backoffice, NEMESIS-FORUM frontoffice
016:         * application are parts of NEMESIS-FORUM and are distributed under
017:         * same terms of licence.
018:         * 
019:         * 
020:         * NEMESIS-FORUM includes software developed by the Apache Software Foundation (http://www.apache.org/)
021:         * and software developed by CoolServlets.com (http://www.coolservlets.com).
022:         * and software developed by Yasna.com (http://www.yasna.com).
023:         * 
024:         */
025:
026:        package org.nemesis.forum.webapp.front;
027:
028:        import javax.servlet.http.*;
029:
030:        /**
031:         *  This class assists skin writers in getting parameters.
032:         */
033:        public class ParamUtils {
034:
035:            /**
036:             *  Gets a parameter as a string.
037:             *  @param request The HttpServletRequest object, known as "request" in a
038:             *  JSP page.
039:             *  @param paramName The name of the parameter you want to get
040:             *  @return The value of the parameter or null if the parameter was not
041:             *  found or if the parameter is a zero-length string.
042:             */
043:            public static String getParameter(HttpServletRequest request,
044:                    String paramName) {
045:                return getParameter(request, paramName, false);
046:            }
047:
048:            /**
049:             *  Gets a parameter as a string.
050:             *  @param request The HttpServletRequest object, known as "request" in a
051:             *  JSP page.
052:             *  @param paramName The name of the parameter you want to get
053:             *  @param emptyStringsOK Return the parameter values even if it is an empty string.
054:             *  @return The value of the parameter or null if the parameter was not
055:             *  found.
056:             */
057:            public static String getParameter(HttpServletRequest request,
058:                    String paramName, boolean emptyStringsOK) {
059:                String temp = request.getParameter(paramName);
060:                if (temp != null) {
061:                    if (temp.equals("") && !emptyStringsOK) {
062:                        return null;
063:                    } else {
064:                        return temp;
065:                    }
066:                } else {
067:                    return null;
068:                }
069:            }
070:
071:            /**
072:             *  Gets a parameter as a boolean.
073:             *  @param request The HttpServletRequest object, known as "request" in a
074:             *  JSP page.
075:             *  @param paramName The name of the parameter you want to get
076:             *  @return True if the value of the parameter was "true", false otherwise.
077:             */
078:            public static boolean getBooleanParameter(
079:                    HttpServletRequest request, String paramName) {
080:                String temp = request.getParameter(paramName);
081:                if (temp != null && temp.equals("true")) {
082:                    return true;
083:                } else {
084:                    return false;
085:                }
086:            }
087:
088:            /**
089:             *  Gets a parameter as a int.
090:             *  @param request The HttpServletRequest object, known as "request" in a
091:             *  JSP page.
092:             *  @param paramName The name of the parameter you want to get
093:             *  @return The int value of the parameter specified or the default value if
094:             *  the parameter is not found.
095:             */
096:            public static int getIntParameter(HttpServletRequest request,
097:                    String paramName, int defaultNum) {
098:                String temp = request.getParameter(paramName);
099:                if (temp != null && !temp.equals("")) {
100:                    int num = defaultNum;
101:                    try {
102:                        num = Integer.parseInt(temp);
103:                    } catch (Exception ignored) {
104:                    }
105:                    return num;
106:                } else {
107:                    return defaultNum;
108:                }
109:            }
110:
111:            /**
112:             *  Gets a checkbox parameter value as a boolean.
113:             *  @param request The HttpServletRequest object, known as "request" in a
114:             *  JSP page.
115:             *  @param paramName The name of the parameter you want to get
116:             *  @return True if the value of the checkbox is "on", false otherwise.
117:             */
118:            public static boolean getCheckboxParameter(
119:                    HttpServletRequest request, String paramName) {
120:                String temp = request.getParameter(paramName);
121:                if (temp != null && temp.equals("on")) {
122:                    return true;
123:                } else {
124:                    return false;
125:                }
126:            }
127:
128:            /**
129:             *  Gets a parameter as a string.
130:             *  @param request The HttpServletRequest object, known as "request" in a
131:             *  JSP page.
132:             *  @param attribName The name of the parameter you want to get
133:             *  @return The value of the parameter or null if the parameter was not
134:             *  found or if the parameter is a zero-length string.
135:             */
136:            public static String getAttribute(HttpServletRequest request,
137:                    String attribName) {
138:                return getAttribute(request, attribName, false);
139:            }
140:
141:            /**
142:             *  Gets a parameter as a string.
143:             *  @param request The HttpServletRequest object, known as "request" in a
144:             *  JSP page.
145:             *  @param attribName The name of the parameter you want to get
146:             *  @param emptyStringsOK Return the parameter values even if it is an empty string.
147:             *  @return The value of the parameter or null if the parameter was not
148:             *  found.
149:             */
150:            public static String getAttribute(HttpServletRequest request,
151:                    String attribName, boolean emptyStringsOK) {
152:                String temp = (String) request.getAttribute(attribName);
153:                if (temp != null) {
154:                    if (temp.equals("") && !emptyStringsOK) {
155:                        return null;
156:                    } else {
157:                        return temp;
158:                    }
159:                } else {
160:                    return null;
161:                }
162:            }
163:
164:            /**
165:             *  Gets an attribute as a boolean.
166:             *  @param request The HttpServletRequest object, known as "request" in a
167:             *  JSP page.
168:             *  @param attribName The name of the attribute you want to get
169:             *  @return True if the value of the attribute is "true", false otherwise.
170:             */
171:            public static boolean getBooleanAttribute(
172:                    HttpServletRequest request, String attribName) {
173:                String temp = (String) request.getAttribute(attribName);
174:                if (temp != null && temp.equals("true")) {
175:                    return true;
176:                } else {
177:                    return false;
178:                }
179:            }
180:
181:            /**
182:             *  Gets an attribute as a int.
183:             *  @param request The HttpServletRequest object, known as "request" in a
184:             *  JSP page.
185:             *  @param attribName The name of the attribute you want to get
186:             *  @return The int value of the attribute or the default value if the attribute is not
187:             *  found or is a zero length string.
188:             */
189:            public static int getIntAttribute(HttpServletRequest request,
190:                    String attribName, int defaultNum) {
191:                String temp = (String) request.getAttribute(attribName);
192:                if (temp != null && !temp.equals("")) {
193:                    int num = defaultNum;
194:                    try {
195:                        num = Integer.parseInt(temp);
196:                    } catch (Exception ignored) {
197:                    }
198:                    return num;
199:                } else {
200:                    return defaultNum;
201:                }
202:            }
203:
204:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.