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


001:        package org.apache.turbine.services.pull.tools;
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 org.apache.commons.configuration.Configuration;
023:
024:        import org.apache.turbine.Turbine;
025:        import org.apache.turbine.services.pull.ApplicationTool;
026:        import org.apache.turbine.util.RunData;
027:        import org.apache.turbine.util.uri.DataURI;
028:
029:        /**
030:         * Terribly simple tool to translate URIs into Turbine Links.
031:         * Equivalent to URIUtils.getAbsoluteLink() in a pull tool.
032:         *
033:         * <p>
034:         * If you're missing any routines from the 'old' $content tool concerning
035:         * path_info or query data, you did use the wrong tool then. You should've used
036:         * the TemplateLink tool which should be available as "$link" in your context.
037:         * <p>
038:         *
039:         * This is an application pull tool for the template system. You should <b>not</b>
040:         * use it in a normal application!
041:         *
042:         * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
043:         * @version $Id: ContentTool.java 534527 2007-05-02 16:10:59Z tv $
044:         */
045:
046:        public class ContentTool implements  ApplicationTool {
047:            /** Prefix for Parameters for this tool */
048:            public static final String CONTENT_TOOL_PREFIX = "tool.content";
049:
050:            /**
051:             * Should this tool add Container Encoding to the URIs returned?
052:             * True might cause trouble e.g. if you run with Apache HTTP Daemon / Tomcat Combo.
053:             *
054:             * Default is false (like Turbine 2.2)
055:             */
056:            public static final String CONTENT_TOOL_ENCODING_KEY = "want.encoding";
057:
058:            /** Default Value for CONTENT_TOOL_ENCODING_KEY */
059:            public static final boolean CONTENT_TOOL_ENCODING_DEFAULT = false;
060:
061:            /** Should this tool return relative URIs or absolute? Default: Absolute. */
062:            public static final String CONTENT_TOOL_RELATIVE_KEY = "want.relative";
063:
064:            /** Default Value for CONTENT_TOOL_RELATIVE_KEY */
065:            public static final boolean CONTENT_TOOL_RELATIVE_DEFAULT = false;
066:
067:            /** Do we want the container to encode the response? */
068:            boolean wantEncoding = false;
069:
070:            /** Do we want a relative link? */
071:            boolean wantRelative = false;
072:
073:            /** Caches a DataURI object which provides the translation routines */
074:            private DataURI dataURI = null;
075:
076:            /**
077:             * C'tor
078:             */
079:            public ContentTool() {
080:            }
081:
082:            /*
083:             * ========================================================================
084:             *
085:             * Application Tool Interface
086:             *
087:             * ========================================================================
088:             *
089:             */
090:
091:            /**
092:             * This will initialise a ContentTool object that was
093:             * constructed with the default constructor (ApplicationTool
094:             * method).
095:             *
096:             * @param data assumed to be a RunData object
097:             */
098:            public void init(Object data) {
099:                // we just blithely cast to RunData as if another object
100:                // or null is passed in we'll throw an appropriate runtime
101:                // exception.
102:                dataURI = new DataURI((RunData) data);
103:
104:                Configuration conf = Turbine.getConfiguration().subset(
105:                        CONTENT_TOOL_PREFIX);
106:
107:                if (conf != null) {
108:                    wantRelative = conf.getBoolean(CONTENT_TOOL_RELATIVE_KEY,
109:                            CONTENT_TOOL_RELATIVE_DEFAULT);
110:
111:                    wantEncoding = conf.getBoolean(CONTENT_TOOL_ENCODING_KEY,
112:                            CONTENT_TOOL_ENCODING_DEFAULT);
113:                }
114:
115:                if (!wantEncoding) {
116:                    dataURI.clearResponse();
117:                }
118:            }
119:
120:            /**
121:             * Refresh method - does nothing
122:             */
123:            public void refresh() {
124:                // empty
125:            }
126:
127:            /**
128:             * Returns the Turbine URI of a given Path
129:             *
130:             * @param path The path to translate
131:             *
132:             * @return Turbine translated absolute path
133:             */
134:            public String getURI(String path) {
135:                dataURI.setScriptName(path);
136:
137:                return wantRelative ? dataURI.getRelativeLink() : dataURI
138:                        .getAbsoluteLink();
139:            }
140:
141:            /**
142:             * Returns the Turbine URI of a given Path. The
143:             * result is always an absolute path starting with
144:             * the server scheme (http/https).
145:             *
146:             * @param path The path to translate
147:             *
148:             * @return Turbine translated absolute path
149:             */
150:            public String getAbsoluteURI(String path) {
151:                dataURI.setScriptName(path);
152:
153:                return dataURI.getAbsoluteLink();
154:            }
155:
156:            /**
157:             * Returns the Turbine URI of a given Path. The
158:             * result is always relative to the context of
159:             * the application.
160:             *
161:             * @param path The path to translate
162:             *
163:             * @return Turbine translated absolute path
164:             */
165:            public String getRelativeURI(String path) {
166:                dataURI.setScriptName(path);
167:
168:                return dataURI.getRelativeLink();
169:            }
170:
171:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.