Source Code Cross Referenced for Parameters.java in  » Portal » jboss-portal-2.6.4 » org » jboss » portlet » util » 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 » Portal » jboss portal 2.6.4 » org.jboss.portlet.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /******************************************************************************
002:         * JBoss, a division of Red Hat                                               *
003:         * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
004:         * contributors as indicated by the @authors tag. See the                     *
005:         * copyright.txt in the distribution for a full listing of                    *
006:         * individual contributors.                                                   *
007:         *                                                                            *
008:         * This is free software; you can redistribute it and/or modify it            *
009:         * under the terms of the GNU Lesser General Public License as                *
010:         * published by the Free Software Foundation; either version 2.1 of           *
011:         * the License, or (at your option) any later version.                        *
012:         *                                                                            *
013:         * This software is distributed in the hope that it will be useful,           *
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
016:         * Lesser General Public License for more details.                            *
017:         *                                                                            *
018:         * You should have received a copy of the GNU Lesser General Public           *
019:         * License along with this software; if not, write to the Free                *
020:         * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
021:         * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
022:         ******************************************************************************/package org.jboss.portlet.util;
023:
024:        import java.util.Map;
025:
026:        /** @author <a href="theute@jboss.org">Thomas Heute </a> $Revision: 8786 $ */
027:        public class Parameters {
028:
029:            private Map parameters;
030:
031:            /** @param parameterMap  */
032:            public Parameters(Map parameterMap) {
033:                this .parameters = parameterMap;
034:            }
035:
036:            public String getParameter(String name) {
037:                if (name == null) {
038:                    return null;
039:                }
040:                String[] value = (String[]) parameters.get(name);
041:                return value == null ? null : value[0];
042:            }
043:
044:            public String get(String key, String def) {
045:                String value = getParameter(key);
046:                if (value != null) {
047:                    return value;
048:                } else {
049:                    return def;
050:                }
051:            }
052:
053:            /**
054:             * Returns the value as a boolean
055:             *
056:             * @param key Key of the parameter
057:             * @param def Default value if value is different from true or false
058:             * @return boolean value for the string "true" or "false" (not sensitive to uppercase/lowercase, and leading/trailing
059:             *         spaces).
060:             */
061:            public boolean getBoolean(String key, boolean def) {
062:
063:                String value = getParameter(key);
064:                if (value != null) {
065:                    if ("true".equalsIgnoreCase(value.trim())) {
066:                        return true;
067:                    } else if ("false".equalsIgnoreCase(value.trim())) {
068:                        return false;
069:                    } else {
070:                        return def;
071:                    }
072:                } else {
073:                    return def;
074:                }
075:            }
076:
077:            public Boolean getBooleanObject(String key, boolean def) {
078:                Boolean bool = getBooleanObject(key);
079:                return (bool != null) ? bool : new Boolean(def);
080:            }
081:
082:            public Boolean getBooleanObject(String key) {
083:
084:                String value = getParameter(key);
085:                if (value != null) {
086:                    if ("true".equalsIgnoreCase(value.trim())) {
087:                        return Boolean.TRUE;
088:                    } else if ("false".equalsIgnoreCase(value.trim())) {
089:                        return Boolean.FALSE;
090:                    } else {
091:                        return null;
092:                    }
093:                } else {
094:                    return null;
095:                }
096:            }
097:
098:            public byte[] getByteArray(String key, byte[] def) {
099:                String value = getParameter(key);
100:                byte[] returnValue = def;
101:                if (value != null) {
102:                    returnValue = value.getBytes();
103:                    if (returnValue == null) {
104:                        returnValue = def;
105:                    }
106:                    return returnValue;
107:                } else {
108:                    return def;
109:                }
110:            }
111:
112:            public double getDouble(String key, double def) {
113:                String value = getParameter(key);
114:                double returnValue = def;
115:                if (value != null) {
116:                    try {
117:                        returnValue = Double.parseDouble(value);
118:                        return returnValue;
119:                    } catch (NumberFormatException e) {
120:                        return def;
121:                    }
122:                } else {
123:                    return def;
124:                }
125:            }
126:
127:            public Double getDoubleObject(String key, double defaultValue) {
128:                Double value = getDoubleObject(key);
129:                return value != null ? value : new Double(defaultValue);
130:            }
131:
132:            public Double getDoubleObject(String key) {
133:                try {
134:                    String value = getParameter(key);
135:                    return (value != null) ? new Double(value) : null;
136:                } catch (NumberFormatException e) {
137:                    return null;
138:                }
139:            }
140:
141:            public float getFloat(String key, float def) {
142:                String value = getParameter(key);
143:                float returnValue = def;
144:                if (value != null) {
145:                    try {
146:                        returnValue = Float.parseFloat(value);
147:                        return returnValue;
148:                    } catch (NumberFormatException e) {
149:                        return def;
150:                    }
151:                } else {
152:                    return def;
153:                }
154:            }
155:
156:            public Float getFloatObject(String key, float defaultValue) {
157:                Float value = getFloatObject(key);
158:                return value != null ? value : new Float(defaultValue);
159:            }
160:
161:            public Float getFloatObject(String key) {
162:                try {
163:                    String value = getParameter(key);
164:                    return (value != null) ? new Float(value) : null;
165:                } catch (NumberFormatException e) {
166:                    return null;
167:                }
168:            }
169:
170:            public short getShort(String key, short def) {
171:                String value = getParameter(key);
172:                short returnValue = def;
173:                if (value != null) {
174:                    try {
175:                        returnValue = Short.parseShort(value);
176:                        return returnValue;
177:                    } catch (NumberFormatException e) {
178:                        return def;
179:                    }
180:                } else {
181:                    return def;
182:                }
183:            }
184:
185:            public Short getShortObject(String key, short defaultValue) {
186:                Short value = getShortObject(key);
187:                return value != null ? value : new Short(defaultValue);
188:            }
189:
190:            public Short getShortObject(String key) {
191:                try {
192:                    String value = getParameter(key);
193:                    return (value != null) ? new Short(value) : null;
194:                } catch (NumberFormatException e) {
195:                    return null;
196:                }
197:            }
198:
199:            public int getInt(String key, int def) {
200:                String value = getParameter(key);
201:                int returnValue = def;
202:                if (value != null) {
203:                    try {
204:                        returnValue = Integer.parseInt(value);
205:                        return returnValue;
206:                    } catch (NumberFormatException e) {
207:                        return def;
208:                    }
209:                } else {
210:                    return def;
211:                }
212:            }
213:
214:            public Integer getIntObject(String key, int defaultValue) {
215:                Integer value = getIntObject(key);
216:                return value != null ? value : new Integer(defaultValue);
217:            }
218:
219:            public Integer getIntObject(String key) {
220:                try {
221:                    String value = getParameter(key);
222:                    return (value != null) ? new Integer(value) : null;
223:                } catch (NumberFormatException e) {
224:                    return null;
225:                }
226:            }
227:
228:            public long getLong(String key, long def) {
229:                String value = getParameter(key);
230:                long returnValue = def;
231:                if (value != null) {
232:                    try {
233:                        returnValue = Long.parseLong(value);
234:                        return returnValue;
235:                    } catch (NumberFormatException e) {
236:                        return def;
237:                    }
238:                } else {
239:                    return def;
240:
241:                }
242:            }
243:
244:            public Long getLongObject(String key, long defaultValue) {
245:                Long value = getLongObject(key);
246:                return value != null ? value : new Long(defaultValue);
247:            }
248:
249:            public Long getLongObject(String key) {
250:                try {
251:                    String value = getParameter(key);
252:                    return (value != null) ? new Long(value) : null;
253:                } catch (NumberFormatException e) {
254:                    return null;
255:                }
256:            }
257:
258:            public boolean getParameterExists(String param) {
259:                String result = getParameter(param);
260:                if ((result != null) && (result.length() != 0)) {
261:                    return true;
262:                } else {
263:                    return false;
264:                }
265:            }
266:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.