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


001:        package org.apache.velocity;
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.HashMap;
023:        import java.util.Map;
024:
025:        import org.apache.velocity.context.AbstractContext;
026:        import org.apache.velocity.context.Context;
027:
028:        /**
029:         *  General purpose implemention of the application Context
030:         *  interface for general application use.  This class should
031:         *  be used in place of the original Context class.
032:         *
033:         *  This implementation uses a HashMap  (@see java.util.HashMap )
034:         *  for data storage.
035:         *
036:         *  This context implementation cannot be shared between threads
037:         *  without those threads synchronizing access between them, as
038:         *  the HashMap is not synchronized, nor are some of the fundamentals
039:         *  of AbstractContext.  If you need to share a Context between
040:         *  threads with simultaneous access for some reason, please create
041:         *  your own and extend the interface Context
042:         *
043:         *  @see org.apache.velocity.context.Context
044:         *
045:         *  @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
046:         *  @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
047:         *  @author <a href="mailto:fedor.karpelevitch@home.com">Fedor Karpelevitch</a>
048:         *  @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
049:         *  @version $Id: VelocityContext.java 463298 2006-10-12 16:10:32Z henning $
050:         */
051:        public class VelocityContext extends AbstractContext implements 
052:                Cloneable {
053:            /**
054:             * Version Id for serializable
055:             */
056:            private static final long serialVersionUID = 9033846851064645037L;
057:
058:            /**
059:             *  Storage for key/value pairs.
060:             */
061:            private Map context = null;
062:
063:            /**
064:             *  Creates a new instance (with no inner context).
065:             */
066:            public VelocityContext() {
067:                this (null, null);
068:            }
069:
070:            /**
071:             *  Creates a new instance with the provided storage (and no inner
072:             *  context).
073:             * @param context
074:             */
075:            public VelocityContext(Map context) {
076:                this (context, null);
077:            }
078:
079:            /**
080:             *  Chaining constructor, used when you want to
081:             *  wrap a context in another.  The inner context
082:             *  will be 'read only' - put() calls to the
083:             *  wrapping context will only effect the outermost
084:             *  context
085:             *
086:             *  @param innerContext The <code>Context</code> implementation to
087:             *  wrap.
088:             */
089:            public VelocityContext(Context innerContext) {
090:                this (null, innerContext);
091:            }
092:
093:            /**
094:             *  Initializes internal storage (never to <code>null</code>), and
095:             *  inner context.
096:             *
097:             *  @param context Internal storage, or <code>null</code> to
098:             *  create default storage.
099:             *  @param innerContext Inner context.
100:             */
101:            public VelocityContext(Map context, Context innerContext) {
102:                super (innerContext);
103:                this .context = (context == null ? new HashMap() : context);
104:            }
105:
106:            /**
107:             *  retrieves value for key from internal
108:             *  storage
109:             *
110:             *  @param key name of value to get
111:             *  @return value as object
112:             */
113:            public Object internalGet(String key) {
114:                return context.get(key);
115:            }
116:
117:            /**
118:             *  stores the value for key to internal
119:             *  storage
120:             *
121:             *  @param key name of value to store
122:             *  @param value value to store
123:             *  @return previous value of key as Object
124:             */
125:            public Object internalPut(String key, Object value) {
126:                return context.put(key, value);
127:            }
128:
129:            /**
130:             *  determines if there is a value for the
131:             *  given key
132:             *
133:             *  @param key name of value to check
134:             *  @return true if non-null value in store
135:             */
136:            public boolean internalContainsKey(Object key) {
137:                return context.containsKey(key);
138:            }
139:
140:            /**
141:             *  returns array of keys
142:             *
143:             *  @return keys as []
144:             */
145:            public Object[] internalGetKeys() {
146:                return context.keySet().toArray();
147:            }
148:
149:            /**
150:             *  remove a key/value pair from the
151:             *  internal storage
152:             *
153:             *  @param key name of value to remove
154:             *  @return value removed
155:             */
156:            public Object internalRemove(Object key) {
157:                return context.remove(key);
158:            }
159:
160:            /**
161:             * Clones this context object.
162:             *
163:             * @return A deep copy of this <code>Context</code>.
164:             */
165:            public Object clone() {
166:                VelocityContext clone = null;
167:                try {
168:                    clone = (VelocityContext) super .clone();
169:                    clone.context = new HashMap(context);
170:                } catch (CloneNotSupportedException ignored) {
171:                }
172:                return clone;
173:            }
174:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.