Source Code Cross Referenced for MockExtensionPoint.java in  » Development » Java-Plugin-Framework » org » java » plugin » tools » mocks » 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 » Development » Java Plugin Framework » org.java.plugin.tools.mocks 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*****************************************************************************
002:         * Java Plug-in Framework (JPF)
003:         * Copyright (C) 2006-2007 Dmitry Olshansky
004:         * 
005:         * This library is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU Lesser General Public
007:         * License as published by the Free Software Foundation; either
008:         * version 2.1 of the License, or (at your option) any later version.
009:         * 
010:         * This library is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013:         * Lesser General Public License for more details.
014:         * 
015:         * You should have received a copy of the GNU Lesser General Public
016:         * License along with this library; if not, write to the Free Software
017:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018:         *****************************************************************************/package org.java.plugin.tools.mocks;
019:
020:        import java.util.Collection;
021:        import java.util.Collections;
022:        import java.util.HashSet;
023:        import java.util.LinkedList;
024:        import org.java.plugin.registry.Extension;
025:        import org.java.plugin.registry.ExtensionMultiplicity;
026:        import org.java.plugin.registry.ExtensionPoint;
027:
028:        /**
029:         * @version $Id$
030:         */
031:        public class MockExtensionPoint extends
032:                MockPluginElement<ExtensionPoint> implements  ExtensionPoint {
033:            private ExtensionMultiplicity multiplicity;
034:            private String parentExtensionPointId;
035:            private String parentPluginId;
036:            private boolean isValid = true;
037:            private LinkedList<Extension> availableExtensions = new LinkedList<Extension>();
038:            private LinkedList<Extension> connectedExtensions = new LinkedList<Extension>();
039:            private LinkedList<ExtensionPoint> descendants = new LinkedList<ExtensionPoint>();
040:            private LinkedList<ParameterDefinition> parameterDefinitions = new LinkedList<ParameterDefinition>();
041:            private HashSet<String> predecessors = new HashSet<String>();
042:
043:            /**
044:             * @see org.java.plugin.registry.ExtensionPoint#getAvailableExtension(
045:             *      java.lang.String)
046:             */
047:            public Extension getAvailableExtension(final String uniqueId) {
048:                for (Extension ext : availableExtensions) {
049:                    if (ext.getUniqueId().equals(uniqueId)) {
050:                        return ext;
051:                    }
052:                }
053:                throw new IllegalArgumentException("extension UID " //$NON-NLS-1$
054:                        + uniqueId + " not available"); //$NON-NLS-1$
055:            }
056:
057:            /**
058:             * @see org.java.plugin.registry.ExtensionPoint#getAvailableExtensions()
059:             */
060:            public Collection<Extension> getAvailableExtensions() {
061:                return Collections.unmodifiableCollection(availableExtensions);
062:            }
063:
064:            /**
065:             * @see org.java.plugin.registry.ExtensionPoint#getConnectedExtension(
066:             *      java.lang.String)
067:             */
068:            public Extension getConnectedExtension(final String uniqueId) {
069:                for (Extension ext : connectedExtensions) {
070:                    if (ext.getUniqueId().equals(uniqueId)) {
071:                        return ext;
072:                    }
073:                }
074:                throw new IllegalArgumentException("extension UID " //$NON-NLS-1$
075:                        + uniqueId + " not connected"); //$NON-NLS-1$
076:            }
077:
078:            /**
079:             * @see org.java.plugin.registry.ExtensionPoint#getConnectedExtensions()
080:             */
081:            public Collection<Extension> getConnectedExtensions() {
082:                return Collections.unmodifiableCollection(connectedExtensions);
083:            }
084:
085:            /**
086:             * @param extension extension to add
087:             * @param isConnected if <code>true</code> extension will be marked as
088:             *                    "connected" also
089:             * @return this instance
090:             */
091:            public MockExtensionPoint addExtension(final Extension extension,
092:                    final boolean isConnected) {
093:                availableExtensions.add(extension);
094:                if (isConnected) {
095:                    connectedExtensions.add(extension);
096:                }
097:                return this ;
098:            }
099:
100:            /**
101:             * @see org.java.plugin.registry.ExtensionPoint#getDescendants()
102:             */
103:            public Collection<ExtensionPoint> getDescendants() {
104:                return Collections.unmodifiableCollection(descendants);
105:            }
106:
107:            /**
108:             * @param extensionPoint descendant extension to add
109:             * @return this instance
110:             */
111:            public MockExtensionPoint addParameter(
112:                    final ExtensionPoint extensionPoint) {
113:                descendants.add(extensionPoint);
114:                return this ;
115:            }
116:
117:            /**
118:             * @see org.java.plugin.registry.ExtensionPoint#getMultiplicity()
119:             */
120:            public ExtensionMultiplicity getMultiplicity() {
121:                return multiplicity;
122:            }
123:
124:            /**
125:             * @param value the multiplicity to set
126:             * @return this instance
127:             */
128:            public MockExtensionPoint setMultiplicity(
129:                    final ExtensionMultiplicity value) {
130:                multiplicity = value;
131:                return this ;
132:            }
133:
134:            /**
135:             * @see org.java.plugin.registry.ExtensionPoint#getParameterDefinition(
136:             *      java.lang.String)
137:             */
138:            public ParameterDefinition getParameterDefinition(String id) {
139:                for (ParameterDefinition paramDef : parameterDefinitions) {
140:                    if (paramDef.getId().equals(id)) {
141:                        return paramDef;
142:                    }
143:                }
144:                throw new IllegalArgumentException(
145:                        "unknown parameter definition ID " + id); //$NON-NLS-1$
146:            }
147:
148:            /**
149:             * @see org.java.plugin.registry.ExtensionPoint#getParameterDefinitions()
150:             */
151:            public Collection<ParameterDefinition> getParameterDefinitions() {
152:                return Collections.unmodifiableCollection(parameterDefinitions);
153:            }
154:
155:            /**
156:             * @param parameterDefinition parameter definition to add
157:             * @return this instance
158:             */
159:            public MockExtensionPoint addParameterDefinition(
160:                    final ParameterDefinition parameterDefinition) {
161:                parameterDefinitions.add(parameterDefinition);
162:                return this ;
163:            }
164:
165:            /**
166:             * @see org.java.plugin.registry.ExtensionPoint#getParentExtensionPointId()
167:             */
168:            public String getParentExtensionPointId() {
169:                return parentExtensionPointId;
170:            }
171:
172:            /**
173:             * @param pluginId the parent plug-in id to set
174:             * @param extensionPointId the parent extension point id to set
175:             * @return this instance
176:             */
177:            public MockExtensionPoint setParentExtensionPoint(
178:                    final String pluginId, final String extensionPointId) {
179:                parentPluginId = pluginId;
180:                parentExtensionPointId = extensionPointId;
181:                predecessors.add(pluginId + '@' + extensionPointId);
182:                return this ;
183:            }
184:
185:            /**
186:             * @see org.java.plugin.registry.ExtensionPoint#getParentPluginId()
187:             */
188:            public String getParentPluginId() {
189:                return parentPluginId;
190:            }
191:
192:            /**
193:             * @see org.java.plugin.registry.ExtensionPoint#isExtensionAvailable(
194:             *      java.lang.String)
195:             */
196:            public boolean isExtensionAvailable(final String uniqueId) {
197:                for (Extension ext : availableExtensions) {
198:                    if (ext.getUniqueId().equals(uniqueId)) {
199:                        return true;
200:                    }
201:                }
202:                return false;
203:            }
204:
205:            /**
206:             * @see org.java.plugin.registry.ExtensionPoint#isExtensionConnected(
207:             *      java.lang.String)
208:             */
209:            public boolean isExtensionConnected(final String uniqueId) {
210:                for (Extension ext : connectedExtensions) {
211:                    if (ext.getUniqueId().equals(uniqueId)) {
212:                        return true;
213:                    }
214:                }
215:                return false;
216:            }
217:
218:            /**
219:             * @see org.java.plugin.registry.ExtensionPoint#isSuccessorOf(
220:             *      org.java.plugin.registry.ExtensionPoint)
221:             */
222:            public boolean isSuccessorOf(final ExtensionPoint extensionPoint) {
223:                return predecessors.contains(extensionPoint.getUniqueId());
224:            }
225:
226:            /**
227:             * @param pluginId predecessor plug-in ID to add
228:             * @param extensionPointId predecessor extension point ID to add
229:             * @return this instance
230:             */
231:            public MockExtensionPoint addPredecessors(final String pluginId,
232:                    final String extensionPointId) {
233:                predecessors.add(pluginId + '@' + extensionPointId);
234:                return this ;
235:            }
236:
237:            /**
238:             * @see org.java.plugin.registry.ExtensionPoint#isValid()
239:             */
240:            public boolean isValid() {
241:                return isValid;
242:            }
243:
244:            /**
245:             * @param value the valid flag to set
246:             * @return this instance
247:             */
248:            public MockExtensionPoint setValid(final boolean value) {
249:                isValid = value;
250:                return this ;
251:            }
252:
253:            /**
254:             * @see org.java.plugin.registry.UniqueIdentity#getUniqueId()
255:             */
256:            public String getUniqueId() {
257:                return getDeclaringPluginDescriptor().getId() + '@' + getId();
258:            }
259:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.