KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > slide > util > conf > Configuration


1 /*
2  * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/util/conf/Configuration.java,v 1.5 2004/07/28 09:34:25 ib Exp $
3  * $Revision: 1.5 $
4  * $Date: 2004/07/28 09:34:25 $
5  *
6  * ====================================================================
7  *
8  * Copyright 1999-2002 The Apache Software Foundation
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */

23
24 package org.apache.slide.util.conf;
25
26 import java.util.*;
27
28 /**
29  * <code>Configuration</code> is a interface encapsulating a configuration node
30  * used to retrieve configuration values. This is a "read only" interface
31  * preventing applications from modifying their own configurations.
32  * <br />
33  *
34  * The contract surrounding the <code>Configuration</code> is that once
35  * it is created, information never changes. The <code>Configuration</code>
36  * is built by the <code>SAXConfigurationBuilder</code> and the
37  * <code>ConfigurationImpl</code> helper classes.
38  *
39  * @version 1.1.0, 22/05/1999.
40  */

41 public interface Configuration {
42     
43     /**
44      * Return the name of the node.
45      *
46      * @return name of the <code>Configuration</code> node.
47      */

48     public String JavaDoc getName();
49     
50     /**
51      * Return a new <code>Configuration</code> instance encapsulating the
52      * specified child node.
53      *
54      * @param child The name of the child node.
55      * @return Configuration
56      * @exception ConfigurationException If no child with that name exists.
57      */

58     public Configuration getConfiguration(String JavaDoc child)
59         throws ConfigurationException;
60     
61     /**
62      * Return an <code>Enumeration</code> of <code>Configuration<code>
63      * elements containing all node children with the specified name.
64      *
65      * @param name The name of the children to get.
66      * @return Enumeration. The <code>Enumeration</code> will be
67      * empty if there are no nodes by the specified name.
68      */

69     public Enumeration getConfigurations(String JavaDoc name);
70
71     /**
72      * Return the value of specified attribute.
73      *
74      * @param paramName The name of the parameter you ask the value of.
75      * @return String value of attribute.
76      * @exception ConfigurationException If no attribute with that name exists.
77      */

78     public String JavaDoc getAttribute(String JavaDoc paramName)
79         throws ConfigurationException;
80     
81     /**
82      * Return the <code>int</code> value of the specified attribute contained
83      * in this node.
84      *
85      * @param paramName The name of the parameter you ask the value of.
86      * @return int value of attribute
87      * @exception ConfigurationException If no parameter with that name exists.
88      * or if conversion to <code>int</code>
89      * fails.
90      */

91     public int getAttributeAsInt(String JavaDoc paramName)
92         throws ConfigurationException;
93     
94     /**
95      * Returns the value of the attribute specified by its name as a
96      * <code>long</code>.
97      *
98      * @param paramName The name of the parameter you ask the value of.
99      * @return long value of attribute
100      * @exception ConfigurationException If no parameter with that name exists.
101      * or if conversion to <code>long</code>
102      * fails.
103      */

104     public long getAttributeAsLong(String JavaDoc paramName)
105         throws ConfigurationException;
106     
107     /**
108      * Return the <code>float</code> value of the specified parameter contained
109      * in this node.
110      *
111      * @param paramName The name of the parameter you ask the value of.
112      * @return float value of attribute
113      * @exception ConfigurationException If no parameter with that name exists.
114      * or if conversion to <code>float</code>
115      * fails.
116      */

117     public float getAttributeAsFloat(String JavaDoc paramName)
118         throws ConfigurationException;
119     
120     /**
121      * Return the <code>boolean</code> value of the specified parameter contained
122      * in this node.<br>
123      *
124      * @param paramName The name of the parameter you ask the value of.
125      * @return boolean value of attribute
126      * @exception ConfigurationException If no parameter with that name exists.
127      * or if conversion to
128      * <code>boolean</code> fails.
129      */

130     public boolean getAttributeAsBoolean(String JavaDoc paramName)
131         throws ConfigurationException;
132     
133     /**
134      * Return the <code>String</code> value of the node.
135      *
136      * @return the value of the node.
137      */

138     public String JavaDoc getValue();
139     
140     /**
141      * Return the <code>int</code> value of the node.
142      *
143      * @return the value of the node.
144      * @exception ConfigurationException If conversion to <code>int</code>
145      * fails
146      */

147     public int getValueAsInt()
148         throws ConfigurationException;
149     
150     /**
151      * Return the <code>float</code> value of the node.
152      *
153      * @return the value of the node.
154      * @exception ConfigurationException If conversion to <code>float</code>
155      * fails.
156      */

157     public float getValueAsFloat()
158         throws ConfigurationException;
159     
160     /**
161      * Return the <code>boolean</code> value of the node.
162      *
163      * @return the value of the node.
164      * @exception ConfigurationException If conversion to <code>boolean</code>
165      * fails.
166      */

167     public boolean getValueAsBoolean()
168         throws ConfigurationException;
169     
170     /**
171      * Return the <code>long</code> value of the node.<br>
172      *
173      * @return the value of the node.
174      * @exception ConfigurationException If conversion to <code>long</code>
175      * fails.
176      */

177     public long getValueAsLong()
178         throws ConfigurationException;
179     
180     /**
181      * Returns the value of the configuration element as a <code>String</code>.
182      * If the configuration value is not set, the default value will be
183      * used.
184      *
185      * @param defaultValue The default value desired.
186      * @return String value of the <code>Configuration</code>, or default
187      * if none specified.
188      */

189     public String JavaDoc getValue(String JavaDoc defaultValue);
190     
191     /**
192      * Returns the value of the configuration element as an <code>int</code>.
193      * If the configuration value is not set, the default value will be
194      * used.
195      *
196      * @param defaultValue The default value desired.
197      * @return int value of the <code>Configuration</code>, or default
198      * if none specified.
199      */

200     public int getValueAsInt(int defaultValue);
201     
202     /**
203      * Returns the value of the configuration element as a <code>long</code>.
204      * If the configuration value is not set, the default value will be
205      * used.
206      *
207      * @param defaultValue The default value desired.
208      * @return long value of the <code>Configuration</code>, or default
209      * if none specified.
210      */

211     public long getValueAsLong(long defaultValue);
212     
213     /**
214      * Returns the value of the configuration element as a <code>float</code>.
215      * If the configuration value is not set, the default value will be
216      * used.
217      *
218      * @param defaultValue The default value desired.
219      * @return float value of the <code>Configuration</code>, or default
220      * if none specified.
221      */

222     public float getValueAsFloat(float defaultValue);
223     
224     /**
225      * Returns the value of the configuration element as a <code>boolean</code>.
226      * If the configuration value is not set, the default value will be
227      * used.
228      *
229      * @param defaultValue The default value desired.
230      * @return boolean value of the <code>Configuration</code>, or default
231      * if none specified.
232      */

233     public boolean getValueAsBoolean(boolean defaultValue);
234     
235     /**
236      * Returns the value of the attribute specified by its name as a
237      * <code>String</code>, or the default value if no attribute by
238      * that name exists or is empty.
239      *
240      * @param name The name of the attribute you ask the value of.
241      * @param defaultValue The default value desired.
242      * @return String value of attribute. It will return the default
243      * value if the named attribute does not exist, or if
244      * the value is not set.
245      */

246     public String JavaDoc getAttribute(String JavaDoc name, String JavaDoc defaultValue);
247     
248     /**
249      * Returns the value of the attribute specified by its name as a
250      * <code>int</code>, or the default value if no attribute by
251      * that name exists or is empty.
252      *
253      * @param name The name of the attribute you ask the value of.
254      * @param defaultValue The default value desired.
255      * @return int value of attribute. It will return the default
256      * value if the named attribute does not exist, or if
257      * the value is not set.
258      */

259     public int getAttributeAsInt(String JavaDoc name, int defaultValue);
260     
261     /**
262      * Returns the value of the attribute specified by its name as a
263      * <code>long</code>, or the default value if no attribute by
264      * that name exists or is empty.
265      *
266      * @param name The name of the attribute you ask the value of.
267      * @param defaultValue The default value desired.
268      * @return long value of attribute. It will return the default
269      * value if the named attribute does not exist, or if
270      * the value is not set.
271      */

272     public long getAttributeAsLong(String JavaDoc name, long defaultValue);
273     
274     /**
275      * Returns the value of the attribute specified by its name as a
276      * <code>float</code>, or the default value if no attribute by
277      * that name exists or is empty.
278      *
279      * @param name The name of the attribute you ask the value of.
280      * @param defaultValue The default value desired.
281      * @return float value of attribute. It will return the default
282      * value if the named attribute does not exist, or if
283      * the value is not set.
284      */

285     public float getAttributeAsFloat(String JavaDoc name, float defaultValue);
286     
287     /**
288      * Returns the value of the attribute specified by its name as a
289      * <code>boolean</code>, or the default value if no attribute by
290      * that name exists or is empty.
291      *
292      * @param name The name of the attribute you ask the value of.
293      * @param defaultValue The default value desired.
294      * @return boolean value of attribute. It will return the default
295      * value if the named attribute does not exist, or if
296      * the value is not set.
297      */

298     public boolean getAttributeAsBoolean(String JavaDoc name, boolean defaultValue);
299     
300     /**
301      * Return a <code>String</code> indicating the position of this
302      * configuration element in a source file or URI.
303      *
304      * @return String if a source file or URI is specified. Otherwise
305      * it returns <code>null</code>
306      */

307     public String JavaDoc getLocation();
308     
309 }
310
Popular Tags