Source Code Cross Referenced for InternalContextAdapterImpl.java in  » Template-Engine » Velocity » org » apache » velocity » context » 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 » Template Engine » Velocity » org.apache.velocity.context 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.apache.velocity.context;
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.velocity.app.event.EventCartridge;
023:        import org.apache.velocity.runtime.resource.Resource;
024:        import org.apache.velocity.util.introspection.IntrospectionCacheData;
025:
026:        /**
027:         *  This adapter class is the container for all context types for internal
028:         *  use.  The AST now uses this class rather than the app-level Context
029:         *  interface to allow flexibility in the future.
030:         *
031:         *  Currently, we have two context interfaces which must be supported :
032:         *  <ul>
033:         *  <li> Context : used for application/template data access
034:         *  <li> InternalHousekeepingContext : used for internal housekeeping and caching
035:         *  <li> InternalWrapperContext : used for getting root cache context and other
036:         *       such.
037:         *  <li> InternalEventContext : for event handling.
038:         *  </ul>
039:         *
040:         *  This class implements the two interfaces to ensure that all methods are
041:         *  supported.  When adding to the interfaces, or adding more context
042:         *  functionality, the interface is the primary definition, so alter that first
043:         *  and then all classes as necessary.  As of this writing, this would be
044:         *  the only class affected by changes to InternalContext
045:         *
046:         *  This class ensures that an InternalContextBase is available for internal
047:         *  use.  If an application constructs their own Context-implementing
048:         *  object w/o subclassing AbstractContext, it may be that support for
049:         *  InternalContext is not available.  Therefore, InternalContextAdapter will
050:         *  create an InternalContextBase if necessary for this support.  Note that
051:         *  if this is necessary, internal information such as node-cache data will be
052:         *  lost from use to use of the context.  This may or may not be important,
053:         *  depending upon application.
054:         *
055:         *
056:         * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
057:         * @version $Id: InternalContextAdapterImpl.java 471908 2006-11-06 22:39:28Z henning $
058:         */
059:        public final class InternalContextAdapterImpl implements 
060:                InternalContextAdapter {
061:            /**
062:             *  the user data Context that we are wrapping
063:             */
064:            Context context = null;
065:
066:            /**
067:             *  the ICB we are wrapping.  We may need to make one
068:             *  if the user data context implementation doesn't
069:             *  support one.  The default AbstractContext-derived
070:             *  VelocityContext does, and it's recommended that
071:             *  people derive new contexts from AbstractContext
072:             *  rather than piecing things together
073:             */
074:            InternalHousekeepingContext icb = null;
075:
076:            /**
077:             *  The InternalEventContext that we are wrapping.  If
078:             *  the context passed to us doesn't support it, no
079:             *  biggie.  We don't make it for them - since its a
080:             *  user context thing, nothing gained by making one
081:             *  for them now
082:             */
083:            InternalEventContext iec = null;
084:
085:            /**
086:             *  CTOR takes a Context and wraps it, delegating all 'data' calls
087:             *  to it.
088:             *
089:             *  For support of internal contexts, it will create an InternalContextBase
090:             *  if need be.
091:             * @param c
092:             */
093:            public InternalContextAdapterImpl(Context c) {
094:                context = c;
095:
096:                if (!(c instanceof  InternalHousekeepingContext)) {
097:                    icb = new InternalContextBase();
098:                } else {
099:                    icb = (InternalHousekeepingContext) context;
100:                }
101:
102:                if (c instanceof  InternalEventContext) {
103:                    iec = (InternalEventContext) context;
104:                }
105:            }
106:
107:            /* --- InternalHousekeepingContext interface methods --- */
108:
109:            /**
110:             * @see org.apache.velocity.context.InternalHousekeepingContext#pushCurrentTemplateName(java.lang.String)
111:             */
112:            public void pushCurrentTemplateName(String s) {
113:                icb.pushCurrentTemplateName(s);
114:            }
115:
116:            /**
117:             * @see org.apache.velocity.context.InternalHousekeepingContext#popCurrentTemplateName()
118:             */
119:            public void popCurrentTemplateName() {
120:                icb.popCurrentTemplateName();
121:            }
122:
123:            /**
124:             * @see org.apache.velocity.context.InternalHousekeepingContext#getCurrentTemplateName()
125:             */
126:            public String getCurrentTemplateName() {
127:                return icb.getCurrentTemplateName();
128:            }
129:
130:            /**
131:             * @see org.apache.velocity.context.InternalHousekeepingContext#getTemplateNameStack()
132:             */
133:            public Object[] getTemplateNameStack() {
134:                return icb.getTemplateNameStack();
135:            }
136:
137:            /**
138:             * @see org.apache.velocity.context.InternalHousekeepingContext#icacheGet(java.lang.Object)
139:             */
140:            public IntrospectionCacheData icacheGet(Object key) {
141:                return icb.icacheGet(key);
142:            }
143:
144:            /**
145:             * @see org.apache.velocity.context.InternalHousekeepingContext#icachePut(java.lang.Object, org.apache.velocity.util.introspection.IntrospectionCacheData)
146:             */
147:            public void icachePut(Object key, IntrospectionCacheData o) {
148:                icb.icachePut(key, o);
149:            }
150:
151:            /**
152:             * @see org.apache.velocity.context.InternalHousekeepingContext#setCurrentResource(org.apache.velocity.runtime.resource.Resource)
153:             */
154:            public void setCurrentResource(Resource r) {
155:                icb.setCurrentResource(r);
156:            }
157:
158:            /**
159:             * @see org.apache.velocity.context.InternalHousekeepingContext#getCurrentResource()
160:             */
161:            public Resource getCurrentResource() {
162:                return icb.getCurrentResource();
163:            }
164:
165:            /**
166:             * @see org.apache.velocity.context.InternalHousekeepingContext#getAllowRendering()
167:             */
168:            public boolean getAllowRendering() {
169:                return icb.getAllowRendering();
170:            }
171:
172:            /**
173:             * @see org.apache.velocity.context.InternalHousekeepingContext#setAllowRendering(boolean)
174:             */
175:            public void setAllowRendering(boolean v) {
176:                icb.setAllowRendering(v);
177:            }
178:
179:            /* ---  Context interface methods --- */
180:
181:            /**
182:             * @see org.apache.velocity.context.Context#put(java.lang.String, java.lang.Object)
183:             */
184:            public Object put(String key, Object value) {
185:                return context.put(key, value);
186:            }
187:
188:            /**
189:             * @see InternalWrapperContext#localPut(String, Object)
190:             */
191:            public Object localPut(final String key, final Object value) {
192:                return put(key, value);
193:            }
194:
195:            /**
196:             * @see org.apache.velocity.context.Context#get(java.lang.String)
197:             */
198:            public Object get(String key) {
199:                return context.get(key);
200:            }
201:
202:            /**
203:             * @see org.apache.velocity.context.Context#containsKey(java.lang.Object)
204:             */
205:            public boolean containsKey(Object key) {
206:                return context.containsKey(key);
207:            }
208:
209:            /**
210:             * @see org.apache.velocity.context.Context#getKeys()
211:             */
212:            public Object[] getKeys() {
213:                return context.getKeys();
214:            }
215:
216:            /**
217:             * @see org.apache.velocity.context.Context#remove(java.lang.Object)
218:             */
219:            public Object remove(Object key) {
220:                return context.remove(key);
221:            }
222:
223:            /* ---- InternalWrapperContext --- */
224:
225:            /**
226:             *  returns the user data context that
227:             *  we are wrapping
228:             * @return The internal user data context.
229:             */
230:            public Context getInternalUserContext() {
231:                return context;
232:            }
233:
234:            /**
235:             *  Returns the base context that we are
236:             *  wrapping. Here, its this, but for other thing
237:             *  like VM related context contortions, it can
238:             *  be something else
239:             * @return The base context.
240:             */
241:            public InternalContextAdapter getBaseContext() {
242:                return this ;
243:            }
244:
245:            /* -----  InternalEventContext ---- */
246:
247:            /**
248:             * @see org.apache.velocity.context.InternalEventContext#attachEventCartridge(org.apache.velocity.app.event.EventCartridge)
249:             */
250:            public EventCartridge attachEventCartridge(EventCartridge ec) {
251:                if (iec != null) {
252:                    return iec.attachEventCartridge(ec);
253:                }
254:
255:                return null;
256:            }
257:
258:            /**
259:             * @see org.apache.velocity.context.InternalEventContext#getEventCartridge()
260:             */
261:            public EventCartridge getEventCartridge() {
262:                if (iec != null) {
263:                    return iec.getEventCartridge();
264:                }
265:
266:                return null;
267:            }
268:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.