Source Code Cross Referenced for TemplateURI.java in  » Web-Framework » TURBINE » org » apache » turbine » util » uri » 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 » Web Framework » TURBINE » org.apache.turbine.util.uri 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.apache.turbine.util.uri;
002:
003:        /*
004:         * Licensed to the Apache Software Foundation (ASF) under one
005:         * or more contributor license agreements.  See the NOTICE file
006:         * distributed with this work for additional information
007:         * regarding copyright ownership.  The ASF licenses this file
008:         * to you under the Apache License, Version 2.0 (the
009:         * "License"); you may not use this file except in compliance
010:         * with the License.  You may obtain a copy of the License at
011:         *
012:         *   http://www.apache.org/licenses/LICENSE-2.0
013:         *
014:         * Unless required by applicable law or agreed to in writing,
015:         * software distributed under the License is distributed on an
016:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017:         * KIND, either express or implied.  See the License for the
018:         * specific language governing permissions and limitations
019:         * under the License.
020:         */
021:
022:        import java.util.Iterator;
023:
024:        import org.apache.commons.lang.StringUtils;
025:
026:        import org.apache.turbine.util.RunData;
027:        import org.apache.turbine.util.ServerData;
028:        import org.apache.turbine.util.parser.ParameterParser;
029:
030:        /**
031:         * This class allows you to keep all the information needed for a single
032:         * link at one place. It keeps your query data, path info, the server
033:         * scheme, name, port and the script path. It is tuned for usage with a
034:         * Template System e.g. Velocity.
035:         *
036:         * If you must generate a Turbine Link in a Template System, use this class.
037:         *
038:         * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
039:         * @version $Id: TemplateURI.java 534527 2007-05-02 16:10:59Z tv $
040:         */
041:
042:        public class TemplateURI extends TurbineURI {
043:            /**
044:             * Empty C'tor. Uses Turbine.getDefaultServerData().
045:             *
046:             */
047:            public TemplateURI() {
048:                super ();
049:            }
050:
051:            /**
052:             * Constructor with a RunData object
053:             *
054:             * @param runData A RunData object
055:             */
056:            public TemplateURI(RunData runData) {
057:                super (runData);
058:            }
059:
060:            /**
061:             * Constructor, set explicit redirection
062:             *
063:             * @param runData A RunData object
064:             * @param redirect True if redirection allowed.
065:             */
066:            public TemplateURI(RunData runData, boolean redirect) {
067:                super (runData, redirect);
068:            }
069:
070:            /**
071:             * Constructor, set Template
072:             *
073:             * @param runData A RunData object
074:             * @param template A Template Name
075:             */
076:            public TemplateURI(RunData runData, String template) {
077:                super (runData);
078:                setTemplate(template);
079:            }
080:
081:            /**
082:             * Constructor, set Template, set explicit redirection
083:             *
084:             * @param runData A RunData object
085:             * @param template A Template Name
086:             * @param redirect True if redirection allowed.
087:             */
088:            public TemplateURI(RunData runData, String template,
089:                    boolean redirect) {
090:                super (runData, redirect);
091:                setTemplate(template);
092:            }
093:
094:            /**
095:             * Constructor, set Template and Action
096:             *
097:             * @param runData A RunData object
098:             * @param template A Template Name
099:             * @param action An Action Name
100:             */
101:            public TemplateURI(RunData runData, String template, String action) {
102:                this (runData, template);
103:                setAction(action);
104:            }
105:
106:            /**
107:             * Constructor, set Template and Action, set explicit redirection
108:             *
109:             * @param runData A RunData object
110:             * @param template A Template Name
111:             * @param action An Action Name
112:             * @param redirect True if redirection allowed.
113:             */
114:            public TemplateURI(RunData runData, String template, String action,
115:                    boolean redirect) {
116:                this (runData, template, redirect);
117:                setAction(action);
118:            }
119:
120:            /**
121:             * Constructor with a ServerData object
122:             *
123:             * @param serverData A ServerData object
124:             */
125:            public TemplateURI(ServerData serverData) {
126:                super (serverData);
127:            }
128:
129:            /**
130:             * Constructor, set explicit redirection
131:             *
132:             * @param serverData A ServerData object
133:             * @param redirect True if redirection allowed.
134:             */
135:            public TemplateURI(ServerData serverData, boolean redirect) {
136:                super (serverData, redirect);
137:            }
138:
139:            /**
140:             * Constructor, set Template
141:             *
142:             * @param serverData A ServerData object
143:             * @param template A Template Name
144:             */
145:            public TemplateURI(ServerData serverData, String template) {
146:                super (serverData);
147:                setTemplate(template);
148:            }
149:
150:            /**
151:             * Constructor, set Template, set explicit redirection
152:             *
153:             * @param serverData A ServerData object
154:             * @param template A Template Name
155:             * @param redirect True if redirection allowed.
156:             */
157:            public TemplateURI(ServerData serverData, String template,
158:                    boolean redirect) {
159:                super (serverData, redirect);
160:                setTemplate(template);
161:            }
162:
163:            /**
164:             * Constructor, set Template and Action
165:             *
166:             * @param serverData A ServerData object
167:             * @param template A Template Name
168:             * @param action An Action Name
169:             */
170:            public TemplateURI(ServerData serverData, String template,
171:                    String action) {
172:                this (serverData, template);
173:                setAction(action);
174:            }
175:
176:            /**
177:             * Constructor, set Template and Action, set explicit redirection
178:             *
179:             * @param serverData A ServerData object
180:             * @param template A Template Name
181:             * @param action An Action Name
182:             * @param redirect True if redirection allowed.
183:             */
184:            public TemplateURI(ServerData serverData, String template,
185:                    String action, boolean redirect) {
186:                this (serverData, template, redirect);
187:                setAction(action);
188:            }
189:
190:            /**
191:             * Constructor, user Turbine.getDefaultServerData(), set Template and Action
192:             *
193:             * @param template A Template Name
194:             * @param action An Action Name
195:             */
196:            public TemplateURI(String template, String action) {
197:                this ();
198:                setTemplate(template);
199:                setAction(action);
200:            }
201:
202:            /**
203:             * Sets the template= value for this URL.
204:             *
205:             * By default it adds the information to the path_info instead
206:             * of the query data. An empty value (null or "") cleans out
207:             * an existing value.
208:             *
209:             * @param template A String with the template value.
210:             */
211:            public void setTemplate(String template) {
212:                if (StringUtils.isNotEmpty(template)) {
213:                    add(PATH_INFO, CGI_TEMPLATE_PARAM, template);
214:                } else {
215:                    clearTemplate();
216:                }
217:            }
218:
219:            /**
220:             * Clears the template= value for this URL.
221:             *
222:             */
223:            public void clearTemplate() {
224:                removePathInfo(CGI_TEMPLATE_PARAM);
225:            }
226:
227:            /*
228:             * ========================================================================
229:             *
230:             * Protected / Private Methods
231:             *
232:             * ========================================================================
233:             *
234:             */
235:
236:            /**
237:             * Method for a quick way to add all the parameters in a
238:             * ParameterParser.
239:             *
240:             * <p>If the type is P (0), then add name/value to the pathInfo
241:             * hashtable.
242:             *
243:             * <p>If the type is Q (1), then add name/value to the queryData
244:             * hashtable.
245:             *
246:             * @param type Type of insertion (@see #add(char type, String name, String value))
247:             * @param pp A ParameterParser.
248:             */
249:            protected void add(int type, ParameterParser pp) {
250:                for (Iterator it = pp.keySet().iterator(); it.hasNext();) {
251:                    String key = (String) it.next();
252:
253:                    if (!key.equalsIgnoreCase(CGI_ACTION_PARAM)
254:                            && !key.equalsIgnoreCase(CGI_SCREEN_PARAM)
255:                            && !key.equalsIgnoreCase(CGI_TEMPLATE_PARAM)) {
256:                        String[] values = pp.getStrings(key);
257:                        if (values != null) {
258:                            for (int i = 0; i < values.length; i++) {
259:                                add(type, key, values[i]);
260:                            }
261:                        } else {
262:                            add(type, key, "");
263:                        }
264:                    }
265:                }
266:            }
267:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.