KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > runtime > model > ConfigurationElementModel


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.core.runtime.model;
12
13 /**
14  * An object which represents the user-defined contents of an extension in a
15  * plug-in manifest.
16  * <p>
17  * This class may be instantiated, or further subclassed.
18  * </p>
19  * @deprecated In Eclipse 3.0 the runtime was refactored and all
20  * non-essential elements removed. This class provides facilities primarily intended
21  * for tooling. As such it has been removed and no directly substitutable API provided.
22  */

23 public class ConfigurationElementModel extends PluginModelObject {
24
25     // DTD properties (included in plug-in manifest)
26
private String JavaDoc value = null;
27     private ConfigurationPropertyModel[] properties = null;
28     private ConfigurationElementModel[] children = null;
29
30     // transient properties (not included in plug-in manifest)
31
private Object JavaDoc parent = null; // parent element or declaring extension
32

33     /**
34      * Creates a new configuration element model in which all fields are <code>null</code>.
35      */

36     public ConfigurationElementModel() {
37         super();
38     }
39
40     /**
41      * Returns the element which contains this element. If this element is an
42      * immediate child of an extension, the returned value can be downcast to
43      * <code>ExtensionModel</code>. Otherwise the returned value can be
44      * downcast to <code>ConfigurationElementModel</code>.
45      *
46      * @return the parent of this configuration element or <code>null</code>
47      */

48     public Object JavaDoc getParent() {
49         return parent;
50     }
51
52     /**
53      * Returns the extension in which this configuration element is declared.
54      * If this element is a top-level child of an extension, the returned value
55      * is equivalent to <code>getParent</code>.
56      *
57      * @return the extension in which this configuration element is declared or
58      * <code>null</code>
59      */

60     public ExtensionModel getParentExtension() {
61         Object JavaDoc p = getParent();
62         while (p != null && p instanceof ConfigurationElementModel)
63             p = ((ConfigurationElementModel) p).getParent();
64         return (ExtensionModel) p;
65     }
66
67     /**
68      * Returns the properties associated with this element.
69      *
70      * @return the properties associated with this element or <code>null</code>
71      */

72     public ConfigurationPropertyModel[] getProperties() {
73         return properties;
74     }
75
76     /**
77      * Returns this element's sub-elements.
78      *
79      * @return the sub-elements of this element or <code>null</code>
80      */

81     public ConfigurationElementModel[] getSubElements() {
82         return children;
83     }
84
85     /**
86      * Returns the value of this element.
87      *
88      * @return the value of this element or <code>null</code>
89      */

90     public String JavaDoc getValue() {
91         return value;
92     }
93
94     /**
95      * Returns the value of this element.
96      *
97      * @return the value of this element or <code>null</code>
98      * @since 2.0
99      */

100     public String JavaDoc getValueAsIs() {
101         return value;
102     }
103
104     /**
105      * Sets this model object and all of its descendents to be read-only.
106      * Subclasses may extend this implementation.
107      *
108      * @see #isReadOnly()
109      */

110     public void markReadOnly() {
111         super.markReadOnly();
112         if (children != null)
113             for (int i = 0; i < children.length; i++)
114                 children[i].markReadOnly();
115         if (properties != null)
116             for (int i = 0; i < properties.length; i++)
117                 properties[i].markReadOnly();
118     }
119
120     /**
121      * Optimization to replace a non-localized key with its localized value.
122      * Avoids having to access resource bundles for further lookups.
123      *
124      * @param value the localized value of this model object
125      */

126     public void setLocalizedValue(String JavaDoc value) {
127         this.value = value;
128     }
129
130     /**
131      * Sets the parent of this element. The supplied parent is either an <code>ExtensionModel</code>,
132      * if this element is to be a direct child of an extension, or another
133      * <code>ConfigurationElement</code>. This object must not be read-only.
134      *
135      * @param value
136      * the new parent of this element. May be <code>null</code>.
137      */

138     public void setParent(Object JavaDoc value) {
139         assertIsWriteable();
140         parent = value;
141     }
142
143     /**
144      * Sets the properties associated with this element. This object must not
145      * be read-only.
146      *
147      * @param value
148      * the properties to associate with this element. May be <code>null</code>.
149      */

150     public void setProperties(ConfigurationPropertyModel[] value) {
151         assertIsWriteable();
152         properties = value;
153     }
154
155     /**
156      * Sets configuration elements contained by this element This object must
157      * not be read-only.
158      *
159      * @param value
160      * the configuration elements to be associated with this
161      * element. May be <code>null</code>.
162      */

163     public void setSubElements(ConfigurationElementModel[] value) {
164         assertIsWriteable();
165         children = value;
166     }
167
168     /**
169      * Sets the value of this element. This object must not be read-only.
170      *
171      * @param value
172      * the new value of this element. May be <code>null</code>.
173      */

174     public void setValue(String JavaDoc value) {
175         assertIsWriteable();
176         this.value = value;
177     }
178 }
179
Popular Tags