KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > celtix > configuration > Configuration


1 package org.objectweb.celtix.configuration;
2
3 import java.util.List JavaDoc;
4
5 public interface Configuration {
6    
7     /**
8      * Returns the identifier for this configuration instance (unique within all instances
9      * configuration instances for the same metadata model).
10      *
11      * @return the name for this configuration.
12      */

13     Object JavaDoc getId();
14     
15     /**
16      * Returns the <code>Configurator</code> associated with this <code>Configuration</code>.
17      *
18      * @return the configuration's configurator object.
19      */

20     // Configurator getConfigurator();
21

22     /**
23      * Returns the configuration metadata model for this <code>Configuration</code>.
24      *
25      * @return the configuration metadata model.
26      */

27     ConfigurationMetadata getModel();
28     
29     /**
30      * Sets the list of configuration providers for this configuration - these will be
31      * consulted in orde when looking up the value for a particular configuration item.
32      *
33      * @param providers the configuration providers to use for this configuration.
34      */

35     void setProviders(List JavaDoc<ConfigurationProvider> providers);
36     
37     /**
38      * Returns the list of configuration providers for this configuration.
39      *
40      * @return the list of configuration providers for this configuration.
41      */

42     List JavaDoc<ConfigurationProvider> getProviders();
43     
44     /**
45      * Returns the parent configuration of this configuration, or null if there is no
46      * parent.
47      *
48      * @return the parent configuration.
49      */

50     Configuration getParent();
51     
52     /**
53      * Returns the child configuration of the type specified in the namespaceURI and with the
54      * specified identifier if there is one, otherwise null.
55      *
56      * @param id the identifier of the child configuration.
57      *
58      * @return the configuration metadata model.
59      *
60      */

61     Configuration getChild(String JavaDoc namespaceURI, Object JavaDoc id);
62     
63     /**
64      * Returns the object holding the value for the configuration item with the specified name.
65      * The runtime class of this object is determined by the jaxb mapping of the configuration
66      * item's type, e.g. for a boolean item it is an instance of java.lang.Boolean.
67      *
68      * @throws ConfigurationException if no such item is defined in this configuration's
69      * metadata model, or if no value for this item can be found in either this configuration
70      * or any of its parent configuration's and if no default value is specified for the
71      * item in the metadata model.
72      *
73      * @param name the name of the configuration item.
74      * @return the object holding the configuration item's value.
75      */

76     Object JavaDoc getObject(String JavaDoc name);
77     
78     /**
79      * Changes the value of the configuration item identified by the name to the given value.
80      * @throws ConfigurationException if no such item is defined in this configuration's
81      * metadata model, or if the value is illegal. Returns true if the change was accepted.
82      *
83      * @param name the name of the configuration item.
84      * @param value the new value for the configuration item.
85      * @return true if the change was accepted.
86      */

87     boolean setObject(String JavaDoc name, Object JavaDoc value);
88     
89     /**
90      * Returns the object holding the value for the configuration item with the specified name.
91      * The runtime class of this object is determined by the jaxb mapping of the configuration
92      * item's type, e.g. for a boolean item it is an instance of java.lang.Boolean.
93      *
94      * @throws ConfigurationException if no such item is defined in this configuration's
95      * metadata model, or if no value for this item can be found in either this configuration
96      * or any of its parent configuration's and if no default value is specified for the
97      * item in the metadata model.
98      *
99      * @param name the name of the configuration item.
100      * @param cls the class of the configuration item.
101      * @return the object holding the configuration item's value.
102      */

103     <T> T getObject(Class JavaDoc<T> cls, String JavaDoc name);
104     
105     /** Convenience method to extract the value of a boolean type configuration item from
106      * its holder object.
107      *
108      *
109      * @param name the name of the configuration item.
110      * @return the value of the configuration item.
111      */

112     boolean getBoolean(String JavaDoc name);
113     
114     /** Convenience method to set the value of a boolean type configuration item to
115      * its holder object.
116      *
117      *
118      * @param name the name of the configuration item.
119      * @param value the value of the configuration item.
120      * @return true if the change was accepted.
121      */

122     boolean setBoolean(String JavaDoc name, boolean value);
123
124     /** Convenience method to extract the value of a short type configuration item from
125      * its holder object.
126      *
127      * @param name the name of the configuration item.
128      * @return the value of the configuration item.
129      */

130     short getShort(String JavaDoc name);
131     
132     /** Convenience method to set the value of a short type configuration item to
133      * its holder object.
134      *
135      *
136      * @param name the name of the configuration item.
137      * @param value the value of the configuration item.
138      * @return true if the change was accepted.
139      */

140     boolean setShort(String JavaDoc name, short value);
141
142     /** Convenience method to extract the value of an int type configuration item from
143      * its holder object.
144      *
145      * @param name the name of the configuration item.
146      * @return the value of the configuration item.
147      */

148     int getInt(String JavaDoc name);
149   
150     /** Convenience method to set the value of a int type configuration item to
151      * its holder object.
152      *
153      *
154      * @param name the name of the configuration item.
155      * @param value the value of the configuration item.
156      * @return true if the change was accepted.
157      */

158     boolean setInt(String JavaDoc name, int value);
159     
160     /** Convenience method to extract the value of a long type configuration item from
161      * its holder object.
162      *
163      * @param name the name of the configuration item.
164      * @return the value of the configuration item.
165      */

166     long getLong(String JavaDoc name);
167     
168     /** Convenience method to set the value of a long type configuration item to
169      * its holder object.
170      *
171      *
172      * @param name the name of the configuration item.
173      * @param value the value of the configuration item.
174      * @return true if the change was accepted.
175      */

176     boolean setLong(String JavaDoc name, long value);
177
178     /** Convenience method to extract the value of a float type configuration item from
179      * its holder object.
180      *
181      * @param name the name of the configuration item.
182      * @return the value of the configuration item.
183      */

184     float getFloat(String JavaDoc name);
185     
186     /** Convenience method to set the value of a float type configuration item to
187      * its holder object.
188      *
189      *
190      * @param name the name of the configuration item.
191      * @param value the value of the configuration item.
192      * @return true if the change was accepted.
193      */

194     boolean setFloat(String JavaDoc name, float value);
195     
196     /** Convenience method to extract the value of a double type configuration item from
197      * its holder object.
198      *
199      * @param name the name of the configuration item.
200      * @return the value of the configuration item.
201      */

202     double getDouble(String JavaDoc name);
203     
204     /** Convenience method to set the value of a double type configuration item to
205      * its holder object.
206      *
207      *
208      * @param name the name of the configuration item.
209      * @param value the value of the configuration item.
210      * @return true if the change was accepted.
211      */

212     boolean setDouble(String JavaDoc name, double value);
213
214     /** Convenience method to extract the value of a string type configuration item from
215      * its holder object.
216      *
217      * @param name the name of the configuration item.
218      * @return the value of the configuration item.
219      */

220     String JavaDoc getString(String JavaDoc name);
221     
222     /** Convenience method to set the value of a String type configuration item to
223      * its holder object.
224      *
225      *
226      * @param name the name of the configuration item.
227      * @param value the value of the configuration item.
228      * @return true if the change was accepted.
229      */

230     boolean setString(String JavaDoc name, String JavaDoc value);
231
232     /** Convenience method to extract the value of a string list type configuration item from
233      * its holder object.
234      *
235      * @param name the name of the configuration item.
236      * @return the value of the configuration item.
237      */

238     List JavaDoc<String JavaDoc> getStringList(String JavaDoc name);
239
240     /**
241      * Save the changes
242      *
243      * @return true if the save was successful.
244      */

245     boolean save();
246
247 }
248
Popular Tags