Source Code Cross Referenced for SimplePageRequest.java in  » Search-Engine » regain » net » sf » regain » util » sharedtag » simple » 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 » Search Engine » regain » net.sf.regain.util.sharedtag.simple 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * regain - A file search engine providing plenty of formats
003:         * Copyright (C) 2004  Til Schneider
004:         *
005:         * This library is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU Lesser General Public
007:         * License as published by the Free Software Foundation; either
008:         * version 2.1 of the License, or (at your option) any later version.
009:         *
010:         * This library is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013:         * Lesser General Public License for more details.
014:         *
015:         * You should have received a copy of the GNU Lesser General Public
016:         * License along with this library; if not, write to the Free Software
017:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
018:         *
019:         * Contact: Til Schneider, info@murfman.de
020:         *
021:         * CVS information:
022:         *  $RCSfile$
023:         *   $Source$
024:         *     $Date: 2005-08-10 16:00:46 +0200 (Mi, 10 Aug 2005) $
025:         *   $Author: til132 $
026:         * $Revision: 155 $
027:         */
028:        package net.sf.regain.util.sharedtag.simple;
029:
030:        import java.io.File;
031:        import java.io.IOException;
032:        import java.net.URL;
033:        import java.util.Enumeration;
034:        import java.util.HashMap;
035:        import java.util.Locale;
036:
037:        import net.sf.regain.RegainException;
038:        import net.sf.regain.util.sharedtag.PageRequest;
039:        import simple.http.Request;
040:        import simple.util.net.Parameters;
041:
042:        /**
043:         * Adapter from a simpleweb Request to a SharedTag PageRequest.
044:         *
045:         * @author Til Schneider, www.murfman.de
046:         */
047:        public class SimplePageRequest extends PageRequest {
048:
049:            /** The init parameters. May be null. */
050:            private static HashMap mInitParameterHash;
051:
052:            /** The base URL where the JSP files and resources are located. */
053:            private static URL mResourceBaseUrl;
054:
055:            /** The working directory of the web server.*/
056:            private static File mWorkingDir;
057:
058:            /** The simpleweb Request to adapt. */
059:            private Request mRequest;
060:
061:            /** The page context. May be null. */
062:            private HashMap mPageContext;
063:
064:            /**
065:             * Creates a new instance of SimplePageRequest.
066:             * 
067:             * @param request The simpleweb Request to adapt.
068:             */
069:            public SimplePageRequest(Request request) {
070:                mRequest = request;
071:            }
072:
073:            /**
074:             * Gets a request parameter that was given to page via GET or POST.
075:             * 
076:             * @param name The name of the parameter.
077:             * @return The given parameter or <code>null</code> if no such parameter was
078:             *         given.
079:             * @throws RegainException If getting the parameter failed.
080:             */
081:            public String getParameter(String name) throws RegainException {
082:                try {
083:                    return mRequest.getParameter(name);
084:                } catch (IOException exc) {
085:                    throw new RegainException("Getting parameter " + name
086:                            + " failed", exc);
087:                }
088:            }
089:
090:            /**
091:             * Gets all request parameters with the given name that were given to the page
092:             * via GET or POST.
093:             * 
094:             * @param name The name of the parameter.
095:             * @return The parameters or <code>null</code> if no such parameter was
096:             *         given.
097:             * @throws RegainException If getting the parameter failed.
098:             */
099:            public String[] getParameters(String name) throws RegainException {
100:                try {
101:                    return mRequest.getParameters().getParameters(name);
102:                } catch (IOException exc) {
103:                    throw new RegainException("Getting parameter " + name
104:                            + " failed", exc);
105:                }
106:            }
107:
108:            /**
109:             * Gets the names of the given parameters.
110:             * 
111:             * @return The names of the given parameters.
112:             * @throws RegainException If getting the parameter names failed.
113:             */
114:            public Enumeration getParameterNames() throws RegainException {
115:                try {
116:                    Parameters params = mRequest.getParameters();
117:                    return params.getParameterNames();
118:                } catch (IOException exc) {
119:                    throw new RegainException("Getting parameter names failed",
120:                            exc);
121:                }
122:            }
123:
124:            /**
125:             * Gets the header with the given name.
126:             * 
127:             * @param name The name of the header.
128:             * @return The header or <code>null</code> if no such header exists.
129:             * @throws RegainException If getting the header failed.
130:             */
131:            public String getHeader(String name) throws RegainException {
132:                return mRequest.getValue(name);
133:            }
134:
135:            /**
136:             * Gets the header with the given name as date.
137:             * 
138:             * @param name The name of the header.
139:             * @return The date header or <code>-1</code> if no such header exists.
140:             * @throws RegainException If getting the header failed.
141:             */
142:            public long getHeaderAsDate(String name) throws RegainException {
143:                return mRequest.getDate(name);
144:            }
145:
146:            /**
147:             * Gets the locale of the client.
148:             * 
149:             * @return The locale.
150:             * @throws RegainException If getting the locale failed.
151:             */
152:            public Locale getLocale() throws RegainException {
153:                return mRequest.getLanguage();
154:            }
155:
156:            /**
157:             * Sets an attribute at the page context.
158:             * 
159:             * @param name The name of the attribute to set.
160:             * @param value The value of the attribute to set.
161:             */
162:            public void setContextAttribute(String name, Object value) {
163:                if (mPageContext == null) {
164:                    mPageContext = new HashMap();
165:                }
166:                mPageContext.put(name, value);
167:            }
168:
169:            /**
170:             * Gets an attribute from the page context.
171:             * 
172:             * @param name The name of the attribute to get.
173:             * @return The attribute's value or <code>null</code> if there is no such
174:             *         attribute.
175:             */
176:            public Object getContextAttribute(String name) {
177:                if (mPageContext == null) {
178:                    return null;
179:                }
180:
181:                return mPageContext.get(name);
182:            }
183:
184:            /**
185:             * Sets an attribute at the session.
186:             * 
187:             * @param name The name of the attribute to set.
188:             * @param value The value of the attribute to set.
189:             */
190:            public void setSessionAttribute(String name, Object value) {
191:                // TODO: implement
192:                throw new IllegalStateException("Not yet implemented");
193:            }
194:
195:            /**
196:             * Gets an attribute from the session.
197:             * 
198:             * @param name The name of the attribute to get.
199:             * @return The attribute's value or <code>null</code> if there is no such
200:             *         attribute.
201:             */
202:            public Object getSessionAttribute(String name) {
203:                // TODO: implement
204:                throw new IllegalStateException("Not yet implemented");
205:            }
206:
207:            /**
208:             * Gets an init parameter.
209:             * 
210:             * @param name The name of the init parameter.
211:             * @return The value of the init parameter.
212:             */
213:            public String getInitParameter(String name) {
214:                if (mInitParameterHash == null) {
215:                    return null;
216:                }
217:
218:                return (String) mInitParameterHash.get(name);
219:            }
220:
221:            /**
222:             * Sets an init parameter.
223:             * 
224:             * @param name The name of the init parameter.
225:             * @param value The value of the init parameter.
226:             */
227:            public static void setInitParameter(String name, String value) {
228:                if (mInitParameterHash == null) {
229:                    mInitParameterHash = new HashMap();
230:                }
231:                mInitParameterHash.put(name, value);
232:            }
233:
234:            /**
235:             * Gets the base URL where the JSP files and resources are located.
236:             * 
237:             * @return The base URL where the JSP files and resources are located.
238:             */
239:            public URL getResourceBaseUrl() {
240:                return mResourceBaseUrl;
241:            }
242:
243:            /**
244:             * Sets the base URL where the JSP files and resources are located.
245:             * 
246:             * @param baseurl The base URL where the JSP files and resources are located.
247:             */
248:            public static void setResourceBaseUrl(URL baseurl) {
249:                mResourceBaseUrl = baseurl;
250:            }
251:
252:            /**
253:             * Gets the working directory of the web server.
254:             * 
255:             * @return The working directory of the web server.
256:             */
257:            public File getWorkingDir() {
258:                return mWorkingDir;
259:            }
260:
261:            /**
262:             * Sets the working directory of the web server.
263:             * 
264:             * @param workingDir The working directory of the web server.
265:             */
266:            public static void setWorkingDir(File workingDir) {
267:                mWorkingDir = workingDir;
268:            }
269:
270:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.