KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > java > plugin > tools > mocks > MockParameterDefinition


1 /*****************************************************************************
2  * Java Plug-in Framework (JPF)
3  * Copyright (C) 2006 Dmitry Olshansky
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *****************************************************************************/

19 package org.java.plugin.tools.mocks;
20
21 import java.util.Collection JavaDoc;
22 import java.util.Collections JavaDoc;
23 import java.util.Iterator JavaDoc;
24 import java.util.LinkedList JavaDoc;
25
26 import org.java.plugin.registry.ExtensionPoint;
27 import org.java.plugin.registry.ExtensionPoint.ParameterDefinition;
28
29 /**
30  * @version $Id: MockParameterDefinition.java,v 1.3 2006/09/14 18:15:45 ddimon Exp $
31  */

32 public class MockParameterDefinition extends MockPluginElement implements
33         ParameterDefinition {
34     private String JavaDoc customData;
35     private ExtensionPoint declaringExtensionPoint;
36     private String JavaDoc defaultValue;
37     private String JavaDoc multiplicity;
38     private String JavaDoc type;
39     private ParameterDefinition superDefinition;
40     private LinkedList JavaDoc subDefinitions = new LinkedList JavaDoc();
41
42     /**
43      * @see org.java.plugin.registry.ExtensionPoint.ParameterDefinition#getCustomData()
44      */

45     public String JavaDoc getCustomData() {
46         return customData;
47     }
48     
49     /**
50      * @param value the custom data to set
51      * @return this instance
52      */

53     public MockParameterDefinition setCustomData(final String JavaDoc value) {
54         customData = value;
55         return this;
56     }
57
58     /**
59      * @see org.java.plugin.registry.ExtensionPoint.ParameterDefinition#getDeclaringExtensionPoint()
60      */

61     public ExtensionPoint getDeclaringExtensionPoint() {
62         return declaringExtensionPoint;
63     }
64     
65     /**
66      * @param value the declaring extension point to set
67      * @return this instance
68      */

69     public MockParameterDefinition setDeclaringExtensionPoint(
70             final ExtensionPoint value) {
71         declaringExtensionPoint = value;
72         return this;
73     }
74
75     /**
76      * @see org.java.plugin.registry.ExtensionPoint.ParameterDefinition#getDefaultValue()
77      */

78     public String JavaDoc getDefaultValue() {
79         return defaultValue;
80     }
81     
82     /**
83      * @param value the default value to set
84      * @return this instance
85      */

86     public MockParameterDefinition setDefaultValue(final String JavaDoc value) {
87         defaultValue = value;
88         return this;
89     }
90
91     /**
92      * @see org.java.plugin.registry.ExtensionPoint.ParameterDefinition#getMultiplicity()
93      */

94     public String JavaDoc getMultiplicity() {
95         return multiplicity;
96     }
97     
98     /**
99      * @param value the multiplicity to set
100      * @return this instance
101      */

102     public MockParameterDefinition setMultiplicity(final String JavaDoc value) {
103         multiplicity = value;
104         return this;
105     }
106
107     /**
108      * @see org.java.plugin.registry.ExtensionPoint.ParameterDefinition#getSubDefinition(java.lang.String)
109      */

110     public ParameterDefinition getSubDefinition(String JavaDoc id) {
111         for (Iterator JavaDoc it = subDefinitions.iterator(); it.hasNext();) {
112             ParameterDefinition paramDef = (ParameterDefinition) it.next();
113             if (paramDef.getId().equals(id)) {
114                 return paramDef;
115             }
116         }
117         throw new IllegalArgumentException JavaDoc(
118                 "unknown parameter definition ID " + id); //$NON-NLS-1$
119
}
120
121     /**
122      * @see org.java.plugin.registry.ExtensionPoint.ParameterDefinition#getSubDefinitions()
123      */

124     public Collection JavaDoc getSubDefinitions() {
125         return Collections.unmodifiableCollection(subDefinitions);
126     }
127     
128     /**
129      * @param parameterDefinition sub-parameter definition to add
130      * @return this instance
131      */

132     public MockParameterDefinition addSubDefinition(
133             final ParameterDefinition parameterDefinition) {
134         subDefinitions.add(parameterDefinition);
135         return this;
136     }
137
138     /**
139      * @see org.java.plugin.registry.ExtensionPoint.ParameterDefinition#getSuperDefinition()
140      */

141     public ParameterDefinition getSuperDefinition() {
142         return superDefinition;
143     }
144     
145     /**
146      * @param value the super definition to set
147      * @return this instance
148      */

149     public MockParameterDefinition setSuperDefinition(
150             final ParameterDefinition value) {
151         superDefinition = value;
152         return this;
153     }
154
155     /**
156      * @see org.java.plugin.registry.ExtensionPoint.ParameterDefinition#getType()
157      */

158     public String JavaDoc getType() {
159         return type;
160     }
161     
162     /**
163      * @param value the type to set
164      * @return this instance
165      */

166     public MockParameterDefinition setType(final String JavaDoc value) {
167         type = value;
168         return this;
169     }
170 }
171
Popular Tags