KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > java > plugin > registry > Extension


1 /*****************************************************************************
2  * Java Plug-in Framework (JPF)
3  * Copyright (C) 2004-2005 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.registry;
20
21 import java.net.URL JavaDoc;
22 import java.util.Collection JavaDoc;
23 import java.util.Date JavaDoc;
24
25 import org.java.plugin.PathResolver;
26 import org.java.plugin.registry.ExtensionPoint.ParameterDefinition;
27
28 /**
29  * This interface abstracts an extension - particular functionality,
30  * the plug-in contribute to the system.
31  * <p>
32  * Extension UID is a combination of declaring plug-in ID and extension ID that
33  * is unique within whole set of registered plug-ins.
34  * </p>
35  *
36  * @version $Id: Extension.java,v 1.2 2005/12/10 13:15:28 ddimon Exp $
37  */

38 public interface Extension extends UniqueIdentity, PluginElement {
39     /**
40      * Returns collection of all top level parameters defined in this extension.
41      * @return collection of {@link Extension.Parameter} objects
42      */

43     Collection JavaDoc getParameters();
44     
45     /**
46      * Returns top level parameter with given ID or <code>null</code> if no top
47      * level parameters exist. If more than one top level parameters with given
48      * ID found, the method should throw an {@link IllegalArgumentException}.
49      * @param id ID of parameter to look for
50      * @return top level parameter with given ID
51      */

52     Parameter getParameter(String JavaDoc id);
53
54     /**
55      * @param id ID of parameter to look for
56      * @return collection of all top level parameters with given ID
57      */

58     Collection JavaDoc getParameters(String JavaDoc id);
59
60     /**
61      * @return ID of plug-in, extended point belongs to
62      */

63     String JavaDoc getExtendedPluginId();
64     
65     /**
66      * @return ID of extended point
67      */

68     String JavaDoc getExtendedPointId();
69     
70     /**
71      * @return <code>true</code> if extension is considered to be valid
72      */

73     boolean isValid();
74     
75     /**
76      * This interface abstracts extension parameter according to extension
77      * declaration in manifest.
78      * @version $Id: Extension.java,v 1.2 2005/12/10 13:15:28 ddimon Exp $
79      */

80     interface Parameter extends PluginElement {
81         /**
82          * @return parameter value as it is specified in manifest, if no value
83          * provided there, this method should return empty string
84          */

85         String JavaDoc rawValue();
86
87         /**
88          * Returns collection of all sub-parameters defined in this parameter.
89          * @return collection of {@link Extension.Parameter} objects
90          */

91         Collection JavaDoc getSubParameters();
92
93         /**
94          * Returns sub-parameter with given ID or <code>null</code> if no
95          * sub-parameters exist. If more than one sub-parameters with given ID
96          * found, the method should throw an {@link IllegalArgumentException}.
97          * @param id ID of sub-parameter to look for
98          * @return sub-parameter with given ID
99          */

100         Parameter getSubParameter(String JavaDoc id);
101
102         /**
103          * @param id ID of sub-parameter to look for
104          * @return collection of all sub-parameters with given ID
105          */

106         Collection JavaDoc getSubParameters(String JavaDoc id);
107
108         /**
109          * @return extension this parameter belongs to
110          */

111         Extension getDeclaringExtension();
112         
113         /**
114          * Returns definition for this extension parameter.
115          * May return <code>null</code> for "invalid" parameters.
116          * @return parameter definition or <code>null</code>, if this parameter
117          * is "invalid"
118          */

119         ParameterDefinition getDefinition();
120         
121         /**
122          * @return parameter, of which this one is child or <code>null</code> if
123          * this is top level parameter
124          */

125         Parameter getSuperParameter();
126         
127         /**
128          * Returns "typed" value of parameter. If this parameter is invalid or
129          * is not of type
130          * {@link ExtensionPoint.ParameterDefinition#TYPE_STRING}, this method
131          * should throw an {@link UnsupportedOperationException}.
132          * @return value as String object
133          */

134         String JavaDoc valueAsString();
135         
136         /**
137          * Returns "typed" value of parameter. If this parameter is invalid or
138          * is not of type
139          * {@link ExtensionPoint.ParameterDefinition#TYPE_BOOLEAN}, this method
140          * should throw an {@link UnsupportedOperationException}.
141          * @return value as Boolean object
142          */

143         Boolean JavaDoc valueAsBoolean();
144         
145         /**
146          * Returns "typed" value of parameter. If this parameter is invalid or
147          * is not of type
148          * {@link ExtensionPoint.ParameterDefinition#TYPE_NUMBER}, this method
149          * should throw an {@link UnsupportedOperationException}.
150          * @return value as Number object
151          */

152         Number JavaDoc valueAsNumber();
153         
154         /**
155          * Returns "typed" value of parameter. If this parameter is invalid or
156          * is not of type {@link ExtensionPoint.ParameterDefinition#TYPE_DATE},
157          * {@link ExtensionPoint.ParameterDefinition#TYPE_TIME}
158          * or {@link ExtensionPoint.ParameterDefinition#TYPE_DATETIME},
159          * this method should throw an {@link UnsupportedOperationException}.
160          * @return value as Date object
161          */

162         Date JavaDoc valueAsDate();
163         
164         /**
165          * Returns "typed" value of parameter. If this parameter is invalid or
166          * is not of type
167          * {@link ExtensionPoint.ParameterDefinition#TYPE_PLUGIN_ID}, this
168          * method should throw an {@link UnsupportedOperationException}.
169          * @return value as PluginDescriptor object
170          */

171         PluginDescriptor valueAsPluginDescriptor();
172         
173         /**
174          * Returns "typed" value of parameter. If this parameter is invalid or
175          * is not of type
176          * {@link ExtensionPoint.ParameterDefinition#TYPE_EXTENSION_POINT_ID},
177          * this method should throw an {@link UnsupportedOperationException}.
178          * @return value as ExtensionPoint object
179          */

180         ExtensionPoint valueAsExtensionPoint();
181         
182         /**
183          * Returns "typed" value of parameter. If this parameter is invalid or
184          * is not of type
185          * {@link ExtensionPoint.ParameterDefinition#TYPE_EXTENSION_ID}, this
186          * method should throw an {@link UnsupportedOperationException}.
187          * @return value as Extension object
188          */

189         Extension valueAsExtension();
190         
191         /**
192          * Returns "typed" value of parameter. If this parameter is invalid or
193          * is not of type
194          * {@link ExtensionPoint.ParameterDefinition#TYPE_RESOURCE}, this
195          * method should throw an {@link UnsupportedOperationException}.
196          * @return value as absolute or relative URL as specified in manifest
197          */

198         URL JavaDoc valueAsUrl();
199         
200         /**
201          * Returns "typed" value of parameter. If this parameter is invalid or
202          * is not of type
203          * {@link ExtensionPoint.ParameterDefinition#TYPE_RESOURCE}, this
204          * method should throw an {@link UnsupportedOperationException}.
205          * @param pathResolver path resolver to make URL absolute
206          * @return value as absolute URL
207          */

208         URL JavaDoc valueAsUrl(PathResolver pathResolver);
209     }
210 }
Popular Tags