Source Code Cross Referenced for Registry.java in  » GIS » openjump » com » vividsolutions » jump » workbench » registry » 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 » GIS » openjump » com.vividsolutions.jump.workbench.registry 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.vividsolutions.jump.workbench.registry;
002:
003:        import java.util.*;
004:
005:        import com.vividsolutions.jump.util.CollectionMap;
006:
007:        /**
008:         * While a Registry is similar to a Blackboard in that they are both flexible
009:         * repositories of information, there are some subtle differences:
010:         * <ul>
011:         * <li>The Registry is a bit more structured (values are Lists as opposed to
012:         * general Objects).
013:         * <li>There is only one Registry, whereas there are Blackboards on several
014:         * different levels (the Workbench Blackboard, the Task Blackboard, the Layer
015:         * Blackboard, the LayerViewPanel Blackboard), thus representing varying degrees
016:         * of scope.
017:         * <li>Registry keys are in general "well known" to a greater degree than
018:         * Blackboard keys, which plugins tend to create as needed. Thus the Registry
019:         * can be thought of as being more static, and the Blackboard more fluid.
020:         * <li>Registry entries are intended to be much more static than Blackboard
021:         * entries. You might well think about persisting a Registry, but probably never
022:         * a Blackboard
023:         * <li>In the bigger world, Registries have all kinds of security,
024:         * classification and lifecyle features that probably would not appear on a
025:         * Blackboard.
026:         * </ul>
027:         * 
028:         * @author jaquino
029:         * @author dzwiers
030:         */
031:        public class Registry {
032:
033:            private CollectionMap classificationToEntriesMap = new CollectionMap();
034:
035:            /**
036:             * @param classification
037:             * @param entry
038:             * @return The current Registry
039:             * 
040:             * @throws ClassCastException When the entry does not match a registered Classification Type
041:             * @see Registry#createClassification(Object, Class)
042:             */
043:            public Registry createEntry(Object classification, Object entry)
044:                    throws ClassCastException {
045:                Class c = (Class) typeMap.get(classification);
046:                if (c != null) {
047:                    // check class type
048:                    if (!c.isInstance(entry)) {
049:                        throw new ClassCastException("Cannot Cast '" + entry
050:                                + "' into " + c.getName()
051:                                + " for classification '" + classification
052:                                + "'");
053:                    }
054:                }
055:                classificationToEntriesMap.addItem(classification, entry);
056:                return this ;
057:            }
058:
059:            /**
060:             * @param classification
061:             * @param entries
062:             * @return The current Registry
063:             * 
064:             * @throws ClassCastException When the entries do not match a registered Classification Type
065:             * @see Registry#createClassification(Object, Class)
066:             */
067:            public Registry createEntries(Object classification,
068:                    Collection entries) throws ClassCastException {
069:                for (Iterator i = entries.iterator(); i.hasNext();) {
070:                    createEntry(classification, i.next());
071:                }
072:                return this ;
073:            }
074:
075:            public List getEntries(Object classification) {
076:                return (List) new ArrayList(classificationToEntriesMap
077:                        .getItems(classification));
078:            }
079:
080:            // new api
081:            private Map typeMap = new HashMap(); // HashMap<Object,Class> --- use this for templating in jvm1.5
082:
083:            /**
084:             * Sets up the registry to be type-safe for a particular classification. 
085:             * Should the user not specify a type mappingthrough this method, no 
086:             * checks will be performed.
087:             * 
088:             * @param classification
089:             * @param type
090:             * @return The current Registry
091:             * 
092:             * @throws ClassCastException When the existing entries do not match Classification Type being registered.
093:             */
094:            public Registry createClassification(Object classification,
095:                    Class type) throws ClassCastException {
096:                if (classificationToEntriesMap.containsKey(classification)) {
097:                    // need to check here
098:                    Collection c = classificationToEntriesMap
099:                            .getItems(classification);
100:                    if (c != null) {
101:                        for (Iterator i = c.iterator(); i.hasNext();) {
102:                            Object entry = i.next();
103:                            if (!type.isInstance(entry)) {
104:                                throw new ClassCastException("Cannot Cast '"
105:                                        + entry + "' into " + type.getName()
106:                                        + " for classification '"
107:                                        + classification + "'");
108:                            }
109:                        }
110:                    }
111:                }
112:                typeMap.put(classification, type);
113:                return this;
114:            }
115:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.