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.1 2007-08-24 22:17:30 ewestfal Exp $
029 */
030 public interface Configuration
031 {
032
033 /**
034 * this method allows to set a logger that tracks configuration events.
035 * @param loggerInstance the logger to set
036 */
037 public void setLogger(Logger loggerInstance);
038
039 /**
040 * Returns the boolean value for the specified key. If no value for this key
041 * is found in the configuration or the value is not an legal boolean
042 * <code>defaultValue</code> is returned.
043 *
044 * @param key the key
045 * @param defaultValue the default Value
046 * @return the value for the key, or <code>defaultValue</code>
047 */
048 public boolean getBoolean(String key, boolean defaultValue);
049
050 /**
051 * Returns the class specified by the value for the specified key. If no
052 * value for this key is found in the configuration, no class of this name
053 * can be found or the specified class is not assignable
054 * <code>assignable</code> <code>defaultValue</code> is returned.
055 *
056 * @param key the key
057 * @param defaultValue the default Value
058 * @param assignable a classe and/or interface the specified class must
059 * extend/implement.
060 * @return the value for the key, or <code>defaultValue</code>
061 */
062 public Class getClass(String key, Class defaultValue, 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, Class[] assignables);
078
079 /**
080 * Returns the class specified by the value for the specified key. If no
081 * value for this key is found in the configuration or no class of this name
082 * can be found <code>defaultValue</code> is returned.
083 *
084 * @param key the key
085 * @param defaultValue the default Value
086 * @return the value for the key, or <code>defaultValue</code>
087 */
088 public Class getClass(String key, Class defaultValue);
089
090 /**
091 * Returns the integer value for the specified key. If no value for this key
092 * is found in the configuration or the value is not an legal integer
093 * <code>defaultValue</code> is returned.
094 *
095 * @param key the key
096 * @param defaultValue the default Value
097 * @return the value for the key, or <code>defaultValue</code>
098 */
099 public int getInteger(String key, int defaultValue);
100
101 /**
102 * Returns the string value for the specified key. If no value for this key
103 * is found in the configuration <code>defaultValue</code> is returned.
104 *
105 * @param key the key
106 * @param defaultValue the default value
107 * @return the value for the key, or <code>defaultValue</code>
108 */
109 public String getString(String key, String defaultValue);
110
111 /**
112 * Gets an array of Strings from the value of the specified key, seperated
113 * by any key from <code>seperators</code>. If no value for this key
114 * is found the array contained in <code>defaultValue</code> is returned.
115 *
116 * @param key the key
117 * @param defaultValue the default Value
118 * @param seperators the seprators to be used
119 * @return the strings for the key, or the strings contained in
120 * <code>defaultValue</code>
121 */
122 public String[] getStrings(String key, String defaultValue, String seperators);
123
124 /**
125 * Gets an array of Strings from the value of the specified key, seperated
126 * by ";". If no value for this key
127 * is found the array contained in <code>defaultValue</code> is returned.
128 *
129 * @param key the key
130 * @param defaultValue the default Value
131 * @return the strings for the key, or the strings contained in
132 * <code>defaultValue</code>
133 */
134 public String[] getStrings(String key, String defaultValue);
135 }