1 package org.apache.ojb.broker.util.configuration; 2 3 /* Copyright 2002-2005 The Apache Software Foundation 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 import org.apache.ojb.broker.util.logging.Logger; 19 20 /** 21 * The <code>Configuration</code> interface defines lookup-methods to lookup 22 * typed configuration-values. 23 * For example <code>boolean getBoolean(String key, boolean defaultValue)</code> 24 * looks up a boolean value associated with <code>key</code>. 25 * If no value is found for <code>key</code> the boolean <code>defaultValue</code> 26 * is returned. 27 * @author Thomas Mahler 28 * @version $Id: Configuration.java,v 1.1 2007-08-24 22:17:30 ewestfal Exp $ 29 */ 30 public interface Configuration 31 { 32 33 /** 34 * this method allows to set a logger that tracks configuration events. 35 * @param loggerInstance the logger to set 36 */ 37 public void setLogger(Logger loggerInstance); 38 39 /** 40 * Returns the boolean value for the specified key. If no value for this key 41 * is found in the configuration or the value is not an legal boolean 42 * <code>defaultValue</code> is returned. 43 * 44 * @param key the key 45 * @param defaultValue the default Value 46 * @return the value for the key, or <code>defaultValue</code> 47 */ 48 public boolean getBoolean(String key, boolean defaultValue); 49 50 /** 51 * Returns the class specified by the value for the specified key. If no 52 * value for this key is found in the configuration, no class of this name 53 * can be found or the specified class is not assignable 54 * <code>assignable</code> <code>defaultValue</code> is returned. 55 * 56 * @param key the key 57 * @param defaultValue the default Value 58 * @param assignable a classe and/or interface the specified class must 59 * extend/implement. 60 * @return the value for the key, or <code>defaultValue</code> 61 */ 62 public Class getClass(String key, Class defaultValue, Class assignable); 63 64 /** 65 * Returns the class specified by the value for the specified key. If no 66 * value for this key is found in the configuration, no class of this name 67 * can be found or the specified class is not assignable to each 68 * class/interface in <code>assignables</code> <code>defaultValue</code> is 69 * returned. 70 * 71 * @param key the key 72 * @param defaultValue the default Value 73 * @param assignables classes and/or interfaces the specified class must 74 * extend/implement. 75 * @return the value for the key, or <code>defaultValue</code> 76 */ 77 public Class getClass(String key, Class defaultValue, Class[] assignables); 78 79 /** 80 * Returns the class specified by the value for the specified key. If no 81 * value for this key is found in the configuration or no class of this name 82 * can be found <code>defaultValue</code> is returned. 83 * 84 * @param key the key 85 * @param defaultValue the default Value 86 * @return the value for the key, or <code>defaultValue</code> 87 */ 88 public Class getClass(String key, Class defaultValue); 89 90 /** 91 * Returns the integer value for the specified key. If no value for this key 92 * is found in the configuration or the value is not an legal integer 93 * <code>defaultValue</code> is returned. 94 * 95 * @param key the key 96 * @param defaultValue the default Value 97 * @return the value for the key, or <code>defaultValue</code> 98 */ 99 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 }