001: /**********************************************************************
002: Copyright (c) 2006 Erik Bengtson and others. All rights reserved.
003: Licensed under the Apache License, Version 2.0 (the "License");
004: you may not use this file except in compliance with the License.
005: You may obtain a copy of the License at
006:
007: http://www.apache.org/licenses/LICENSE-2.0
008:
009: Unless required by applicable law or agreed to in writing, software
010: distributed under the License is distributed on an "AS IS" BASIS,
011: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012: See the License for the specific language governing permissions and
013: limitations under the License.
014:
015:
016: Contributors:
017: ...
018: **********************************************************************/package org.jpox.plugin;
019:
020: /**
021: * Extension declared in a plug-in. Represents the XML element
022: * @version $Revision: 1.6 $
023: */
024: public class Extension {
025: /** reference to the extension point this extension implements * */
026: private ExtensionPoint point;
027:
028: /** declared plugin * */
029: final private Bundle plugin;
030:
031: /** point id **/
032: final private String pointId;
033:
034: /** Configuration elements * */
035: ConfigurationElement[] configurationElement;
036:
037: public Extension(ExtensionPoint point, Bundle plugin) {
038: this .point = point;
039: this .pointId = point.getUniqueId();
040: this .plugin = plugin;
041: this .configurationElement = new ConfigurationElement[0];
042: }
043:
044: public Extension(String pointId, Bundle plugin) {
045: this .pointId = pointId;
046: this .plugin = plugin;
047: this .configurationElement = new ConfigurationElement[0];
048: }
049:
050: /**
051: * Assign the ExtensionPoint to this Extension
052: * @param point
053: */
054: public void setExtensionPoint(ExtensionPoint point) {
055: this .point = point;
056: }
057:
058: /**
059: * Acessor to the extension point id
060: * @return extension point id
061: */
062: public String getExtensionPointId() {
063: return this .pointId;
064: }
065:
066: /**
067: * Accessor for the Plug-in that declared this Extension
068: * @return the Plug-in
069: */
070: public Bundle getPlugin() {
071: return plugin;
072: }
073:
074: /**
075: * Acessor for the ExtensionPoint that this Extension implements
076: * @return the ExtensionPoint
077: */
078: public ExtensionPoint getPoint() {
079: return point;
080: }
081:
082: /**
083: * Add a new child ConfigurationElement (declared nested in the extension XML element)
084: * @param element the ConfigurationElement
085: */
086: public void addConfigurationElement(ConfigurationElement element) {
087: ConfigurationElement[] elms = new ConfigurationElement[configurationElement.length + 1];
088: System.arraycopy(configurationElement, 0, elms, 0,
089: configurationElement.length);
090: elms[configurationElement.length] = element;
091: configurationElement = elms;
092: }
093:
094: /**
095: * Acessor for all ConfigurationElements declared in the Extension
096: * @return array of ConfigurationElement
097: */
098: public ConfigurationElement[] getConfigurationElements() {
099: return configurationElement;
100: }
101: }
|