001: package org.objectweb.celtix.configuration;
002:
003: import java.util.List;
004:
005: public interface Configuration {
006:
007: /**
008: * Returns the identifier for this configuration instance (unique within all instances
009: * configuration instances for the same metadata model).
010: *
011: * @return the name for this configuration.
012: */
013: Object getId();
014:
015: /**
016: * Returns the <code>Configurator</code> associated with this <code>Configuration</code>.
017: *
018: * @return the configuration's configurator object.
019: */
020: // Configurator getConfigurator();
021: /**
022: * Returns the configuration metadata model for this <code>Configuration</code>.
023: *
024: * @return the configuration metadata model.
025: */
026: ConfigurationMetadata getModel();
027:
028: /**
029: * Sets the list of configuration providers for this configuration - these will be
030: * consulted in orde when looking up the value for a particular configuration item.
031: *
032: * @param providers the configuration providers to use for this configuration.
033: */
034: void setProviders(List<ConfigurationProvider> providers);
035:
036: /**
037: * Returns the list of configuration providers for this configuration.
038: *
039: * @return the list of configuration providers for this configuration.
040: */
041: List<ConfigurationProvider> getProviders();
042:
043: /**
044: * Returns the parent configuration of this configuration, or null if there is no
045: * parent.
046: *
047: * @return the parent configuration.
048: */
049: Configuration getParent();
050:
051: /**
052: * Returns the child configuration of the type specified in the namespaceURI and with the
053: * specified identifier if there is one, otherwise null.
054: *
055: * @param id the identifier of the child configuration.
056: *
057: * @return the configuration metadata model.
058: *
059: */
060: Configuration getChild(String namespaceURI, Object id);
061:
062: /**
063: * Returns the object holding the value for the configuration item with the specified name.
064: * The runtime class of this object is determined by the jaxb mapping of the configuration
065: * item's type, e.g. for a boolean item it is an instance of java.lang.Boolean.
066: *
067: * @throws ConfigurationException if no such item is defined in this configuration's
068: * metadata model, or if no value for this item can be found in either this configuration
069: * or any of its parent configuration's and if no default value is specified for the
070: * item in the metadata model.
071: *
072: * @param name the name of the configuration item.
073: * @return the object holding the configuration item's value.
074: */
075: Object getObject(String name);
076:
077: /**
078: * Changes the value of the configuration item identified by the name to the given value.
079: * @throws ConfigurationException if no such item is defined in this configuration's
080: * metadata model, or if the value is illegal. Returns true if the change was accepted.
081: *
082: * @param name the name of the configuration item.
083: * @param value the new value for the configuration item.
084: * @return true if the change was accepted.
085: */
086: boolean setObject(String name, Object value);
087:
088: /**
089: * Returns the object holding the value for the configuration item with the specified name.
090: * The runtime class of this object is determined by the jaxb mapping of the configuration
091: * item's type, e.g. for a boolean item it is an instance of java.lang.Boolean.
092: *
093: * @throws ConfigurationException if no such item is defined in this configuration's
094: * metadata model, or if no value for this item can be found in either this configuration
095: * or any of its parent configuration's and if no default value is specified for the
096: * item in the metadata model.
097: *
098: * @param name the name of the configuration item.
099: * @param cls the class of the configuration item.
100: * @return the object holding the configuration item's value.
101: */
102: <T> T getObject(Class<T> cls, String name);
103:
104: /** Convenience method to extract the value of a boolean type configuration item from
105: * its holder object.
106: *
107: *
108: * @param name the name of the configuration item.
109: * @return the value of the configuration item.
110: */
111: boolean getBoolean(String name);
112:
113: /** Convenience method to set the value of a boolean type configuration item to
114: * its holder object.
115: *
116: *
117: * @param name the name of the configuration item.
118: * @param value the value of the configuration item.
119: * @return true if the change was accepted.
120: */
121: boolean setBoolean(String name, boolean value);
122:
123: /** Convenience method to extract the value of a short type configuration item from
124: * its holder object.
125: *
126: * @param name the name of the configuration item.
127: * @return the value of the configuration item.
128: */
129: short getShort(String name);
130:
131: /** Convenience method to set the value of a short type configuration item to
132: * its holder object.
133: *
134: *
135: * @param name the name of the configuration item.
136: * @param value the value of the configuration item.
137: * @return true if the change was accepted.
138: */
139: boolean setShort(String name, short value);
140:
141: /** Convenience method to extract the value of an int type configuration item from
142: * its holder object.
143: *
144: * @param name the name of the configuration item.
145: * @return the value of the configuration item.
146: */
147: int getInt(String name);
148:
149: /** Convenience method to set the value of a int type configuration item to
150: * its holder object.
151: *
152: *
153: * @param name the name of the configuration item.
154: * @param value the value of the configuration item.
155: * @return true if the change was accepted.
156: */
157: boolean setInt(String name, int value);
158:
159: /** Convenience method to extract the value of a long type configuration item from
160: * its holder object.
161: *
162: * @param name the name of the configuration item.
163: * @return the value of the configuration item.
164: */
165: long getLong(String name);
166:
167: /** Convenience method to set the value of a long type configuration item to
168: * its holder object.
169: *
170: *
171: * @param name the name of the configuration item.
172: * @param value the value of the configuration item.
173: * @return true if the change was accepted.
174: */
175: boolean setLong(String name, long value);
176:
177: /** Convenience method to extract the value of a float type configuration item from
178: * its holder object.
179: *
180: * @param name the name of the configuration item.
181: * @return the value of the configuration item.
182: */
183: float getFloat(String name);
184:
185: /** Convenience method to set the value of a float type configuration item to
186: * its holder object.
187: *
188: *
189: * @param name the name of the configuration item.
190: * @param value the value of the configuration item.
191: * @return true if the change was accepted.
192: */
193: boolean setFloat(String name, float value);
194:
195: /** Convenience method to extract the value of a double type configuration item from
196: * its holder object.
197: *
198: * @param name the name of the configuration item.
199: * @return the value of the configuration item.
200: */
201: double getDouble(String name);
202:
203: /** Convenience method to set the value of a double type configuration item to
204: * its holder object.
205: *
206: *
207: * @param name the name of the configuration item.
208: * @param value the value of the configuration item.
209: * @return true if the change was accepted.
210: */
211: boolean setDouble(String name, double value);
212:
213: /** Convenience method to extract the value of a string type configuration item from
214: * its holder object.
215: *
216: * @param name the name of the configuration item.
217: * @return the value of the configuration item.
218: */
219: String getString(String name);
220:
221: /** Convenience method to set the value of a String type configuration item to
222: * its holder object.
223: *
224: *
225: * @param name the name of the configuration item.
226: * @param value the value of the configuration item.
227: * @return true if the change was accepted.
228: */
229: boolean setString(String name, String value);
230:
231: /** Convenience method to extract the value of a string list type configuration item from
232: * its holder object.
233: *
234: * @param name the name of the configuration item.
235: * @return the value of the configuration item.
236: */
237: List<String> getStringList(String name);
238:
239: /**
240: * Save the changes
241: *
242: * @return true if the save was successful.
243: */
244: boolean save();
245:
246: }
|