Source Code Cross Referenced for StandardEnvironment.java in  » Web-Framework » aranea-mvc-1.1.1 » org » araneaframework » core » 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 » aranea mvc 1.1.1 » org.araneaframework.core 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Copyright 2006 Webmedia Group Ltd.
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *  http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         **/package org.araneaframework.core;
016:
017:        import java.util.HashMap;
018:        import java.util.Iterator;
019:        import java.util.Map;
020:        import org.apache.commons.lang.ObjectUtils;
021:        import org.apache.commons.lang.StringUtils;
022:        import org.araneaframework.Environment;
023:
024:        /**
025:         * A simple {@link org.araneaframework.Environment} implementation.
026:         * 
027:         * @author "Toomas Römer" <toomas@webmedia.ee>
028:         */
029:        public class StandardEnvironment extends BaseEnvironment {
030:            private Map entries;
031:            private Environment parentEnv;
032:
033:            /**
034:             * Constructs an object with the env parent Environment and with the entries data.
035:             * @param env the parent environment
036:             * @param entries a map of the entries in the Environment
037:             */
038:            public StandardEnvironment(Environment env, Map entries) {
039:                Assert.notNullParam(entries, "entries");
040:
041:                this .entries = entries;
042:                parentEnv = env;
043:            }
044:
045:            /**
046:             * Constructs an object with the env parent Environment and entries data containing &lt;key, value&gt;.
047:             * @param env the parent environment
048:             * @param key a key of the value in the map of the Environment entries.
049:             * @param value a value corresponding to given key in the map of the Environment entries.
050:             */
051:            public StandardEnvironment(Environment env, Object key, Object value) {
052:                Assert.notNullParam(key, "key");
053:
054:                entries = new HashMap(1);
055:                entries.put(key, value);
056:                parentEnv = env;
057:            }
058:
059:            /**
060:             * Returns the map with the entries in this Environment. An entry is a key value pair.
061:             * @return a map with the entries.
062:             */
063:            public Map getEntryMap() {
064:                return entries;
065:            }
066:
067:            /**
068:             * Returns the corresponding value of this Envrionment's entries. If none is
069:             * found from the entries then the entry is returned from the parent environment.
070:             * If a value to the key does not exist, AraneaNoSuchEnvironmentEntryException is thrown.
071:             * @param key the key of the entry
072:             * @return the Object under the key provided
073:             * @throws AraneaNoSuchEnvironmentEntryException 
074:             */
075:            public Object getEntry(Object key) {
076:                if (entries.containsKey(key)) {
077:                    return entries.get(key);
078:                }
079:
080:                if (parentEnv == null) {
081:                    return null;
082:                }
083:
084:                return parentEnv.getEntry(key);
085:            }
086:
087:            public String toString() {
088:                return toString(0);
089:            }
090:
091:            private static final String space = " ";
092:            private static final String lf = "\n";
093:
094:            private String toString(int pad) {
095:                String padding = StringUtils.leftPad("", pad, space);
096:                StringBuffer result = new StringBuffer();
097:
098:                if (entries != null) {
099:                    for (Iterator i = entries.entrySet().iterator(); i
100:                            .hasNext();) {
101:                        Map.Entry e = (Map.Entry) i.next();
102:                        result.append(padding + e.getKey() + "="
103:                                + ObjectUtils.identityToString(e.getValue())
104:                                + lf);
105:                    }
106:                }
107:
108:                if (parentEnv instanceof  StandardEnvironment) {
109:                    result.append(((StandardEnvironment) parentEnv)
110:                            .toString(pad + (space.length() * 2)));
111:                }
112:
113:                result.append("\n");
114:                return result.toString();
115:            }
116:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.