001: package org.apache.ojb.broker.util.configuration;
002:
003: /* Copyright 2002-2005 The Apache Software Foundation
004: *
005: * Licensed under the Apache License, Version 2.0 (the "License");
006: * you may not use this file except in compliance with the License.
007: * You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: import org.apache.ojb.broker.util.logging.Logger;
019:
020: /**
021: * The <code>Configuration</code> interface defines lookup-methods to lookup
022: * typed configuration-values.
023: * For example <code>boolean getBoolean(String key, boolean defaultValue)</code>
024: * looks up a boolean value associated with <code>key</code>.
025: * If no value is found for <code>key</code> the boolean <code>defaultValue</code>
026: * is returned.
027: * @author Thomas Mahler
028: * @version $Id: Configuration.java,v 1.5.2.1 2005/12/21 22:28:15 tomdz Exp $
029: */
030: public interface Configuration {
031:
032: /**
033: * this method allows to set a logger that tracks configuration events.
034: * @param loggerInstance the logger to set
035: */
036: public void setLogger(Logger loggerInstance);
037:
038: /**
039: * Returns the boolean value for the specified key. If no value for this key
040: * is found in the configuration or the value is not an legal boolean
041: * <code>defaultValue</code> is returned.
042: *
043: * @param key the key
044: * @param defaultValue the default Value
045: * @return the value for the key, or <code>defaultValue</code>
046: */
047: public boolean getBoolean(String key, boolean defaultValue);
048:
049: /**
050: * Returns the class specified by the value for the specified key. If no
051: * value for this key is found in the configuration, no class of this name
052: * can be found or the specified class is not assignable
053: * <code>assignable</code> <code>defaultValue</code> is returned.
054: *
055: * @param key the key
056: * @param defaultValue the default Value
057: * @param assignable a classe and/or interface the specified class must
058: * extend/implement.
059: * @return the value for the key, or <code>defaultValue</code>
060: */
061: public Class getClass(String key, Class defaultValue,
062: Class assignable);
063:
064: /**
065: * Returns the class specified by the value for the specified key. If no
066: * value for this key is found in the configuration, no class of this name
067: * can be found or the specified class is not assignable to each
068: * class/interface in <code>assignables</code> <code>defaultValue</code> is
069: * returned.
070: *
071: * @param key the key
072: * @param defaultValue the default Value
073: * @param assignables classes and/or interfaces the specified class must
074: * extend/implement.
075: * @return the value for the key, or <code>defaultValue</code>
076: */
077: public Class getClass(String key, Class defaultValue,
078: Class[] assignables);
079:
080: /**
081: * Returns the class specified by the value for the specified key. If no
082: * value for this key is found in the configuration or no class of this name
083: * can be found <code>defaultValue</code> is returned.
084: *
085: * @param key the key
086: * @param defaultValue the default Value
087: * @return the value for the key, or <code>defaultValue</code>
088: */
089: public Class getClass(String key, Class defaultValue);
090:
091: /**
092: * Returns the integer value for the specified key. If no value for this key
093: * is found in the configuration or the value is not an legal integer
094: * <code>defaultValue</code> is returned.
095: *
096: * @param key the key
097: * @param defaultValue the default Value
098: * @return the value for the key, or <code>defaultValue</code>
099: */
100: public int getInteger(String key, int defaultValue);
101:
102: /**
103: * Returns the string value for the specified key. If no value for this key
104: * is found in the configuration <code>defaultValue</code> is returned.
105: *
106: * @param key the key
107: * @param defaultValue the default value
108: * @return the value for the key, or <code>defaultValue</code>
109: */
110: public String getString(String key, String defaultValue);
111:
112: /**
113: * Gets an array of Strings from the value of the specified key, seperated
114: * by any key from <code>seperators</code>. If no value for this key
115: * is found the array contained in <code>defaultValue</code> is returned.
116: *
117: * @param key the key
118: * @param defaultValue the default Value
119: * @param seperators the seprators to be used
120: * @return the strings for the key, or the strings contained in
121: * <code>defaultValue</code>
122: */
123: public String[] getStrings(String key, String defaultValue,
124: String seperators);
125:
126: /**
127: * Gets an array of Strings from the value of the specified key, seperated
128: * by ";". If no value for this key
129: * is found the array contained in <code>defaultValue</code> is returned.
130: *
131: * @param key the key
132: * @param defaultValue the default Value
133: * @return the strings for the key, or the strings contained in
134: * <code>defaultValue</code>
135: */
136: public String[] getStrings(String key, String defaultValue);
137: }
|