Source Code Cross Referenced for CatalogBase.java in  » Library » Apache-commons-chain-1.1-src » org » apache » commons » chain » impl » 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 » Library » Apache commons chain 1.1 src » org.apache.commons.chain.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 1999-2004 The Apache Software Foundation
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:         */
016:        package org.apache.commons.chain.impl;
017:
018:        import java.util.HashMap;
019:        import java.util.Collections;
020:        import java.util.Iterator;
021:        import java.util.Map;
022:        import org.apache.commons.chain.Catalog;
023:        import org.apache.commons.chain.Command;
024:
025:        /**
026:         * <p>Simple in-memory implementation of {@link Catalog}.  This class can
027:         * also be used as the basis for more advanced implementations.</p>
028:         *
029:         * <p>This implementation is thread-safe.</p>
030:         *
031:         * @author Craig R. McClanahan
032:         * @author Matthew J. Sgarlata
033:         * @version $Revision: 411876 $ $Date: 2006-06-05 19:02:19 +0100 (Mon, 05 Jun 2006) $
034:         */
035:
036:        public class CatalogBase implements  Catalog {
037:
038:            // ----------------------------------------------------- Instance Variables
039:
040:            /**
041:             * <p>The map of named {@link Command}s, keyed by name.
042:             */
043:            protected Map commands = Collections.synchronizedMap(new HashMap());
044:
045:            // --------------------------------------------------------- Constructors
046:
047:            /**
048:             * Create an empty catalog.
049:             */
050:            public CatalogBase() {
051:            }
052:
053:            /**
054:             * <p>Create a catalog whose commands are those specified in the given <code>Map</code>.
055:             * All Map keys should be <code>String</code> and all values should be <code>Command</code>.</p>
056:             *
057:             * @param commands Map of Commands.
058:             *
059:             * @since Chain 1.1
060:             */
061:            public CatalogBase(Map commands) {
062:                this .commands = Collections.synchronizedMap(commands);
063:            }
064:
065:            // --------------------------------------------------------- Public Methods
066:
067:            /**
068:             * <p>Add a new name and associated {@link Command}
069:             * to the set of named commands known to this {@link Catalog},
070:             * replacing any previous command for that name.
071:             *
072:             * @param name Name of the new command
073:             * @param command {@link Command} to be returned
074:             *  for later lookups on this name
075:             */
076:            public void addCommand(String name, Command command) {
077:
078:                commands.put(name, command);
079:
080:            }
081:
082:            /**
083:             * <p>Return the {@link Command} associated with the
084:             * specified name, if any; otherwise, return <code>null</code>.</p>
085:             *
086:             * @param name Name for which a {@link Command}
087:             *  should be retrieved
088:             * @return The Command associated with the specified name.
089:             */
090:            public Command getCommand(String name) {
091:
092:                return ((Command) commands.get(name));
093:
094:            }
095:
096:            /**
097:             * <p>Return an <code>Iterator</code> over the set of named commands
098:             * known to this {@link Catalog}.  If there are no known commands,
099:             * an empty Iterator is returned.</p>
100:             * @return An iterator of the names in this Catalog.
101:             */
102:            public Iterator getNames() {
103:
104:                return (commands.keySet().iterator());
105:
106:            }
107:
108:            /**
109:             * Converts this Catalog to a String.  Useful for debugging purposes.
110:             * @return a representation of this catalog as a String
111:             */
112:            public String toString() {
113:
114:                Iterator names = getNames();
115:                StringBuffer str = new StringBuffer("["
116:                        + this .getClass().getName() + ": ");
117:
118:                while (names.hasNext()) {
119:                    str.append(names.next());
120:                    if (names.hasNext()) {
121:                        str.append(", ");
122:                    }
123:                }
124:                str.append("]");
125:
126:                return str.toString();
127:
128:            }
129:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.