diff options
Diffstat (limited to 'src/jcckit/util')
-rw-r--r-- | src/jcckit/util/AppletBasedConfigData.java | 53 | ||||
-rw-r--r-- | src/jcckit/util/ConfigData.java | 55 | ||||
-rw-r--r-- | src/jcckit/util/ConfigParameters.java | 321 | ||||
-rw-r--r-- | src/jcckit/util/ConfigParametersBasedConfigData.java | 74 | ||||
-rw-r--r-- | src/jcckit/util/Factory.java | 120 | ||||
-rw-r--r-- | src/jcckit/util/FactoryException.java | 79 | ||||
-rw-r--r-- | src/jcckit/util/FlatConfigData.java | 187 | ||||
-rw-r--r-- | src/jcckit/util/Format.java | 208 | ||||
-rw-r--r-- | src/jcckit/util/FormatElement.java | 242 | ||||
-rw-r--r-- | src/jcckit/util/Point.java | 65 | ||||
-rw-r--r-- | src/jcckit/util/PropertiesBasedConfigData.java | 81 | ||||
-rw-r--r-- | src/jcckit/util/TicLabelFormat.java | 33 | ||||
-rw-r--r-- | src/jcckit/util/Util.java | 47 |
13 files changed, 0 insertions, 1565 deletions
diff --git a/src/jcckit/util/AppletBasedConfigData.java b/src/jcckit/util/AppletBasedConfigData.java deleted file mode 100644 index e46b720..0000000 --- a/src/jcckit/util/AppletBasedConfigData.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2003-2004, Franz-Josef Elmer, All rights reserved - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details - * (http://www.gnu.org/copyleft/lesser.html). - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -package jcckit.util; - -import java.applet.Applet; - -/** - * Implementation of {@link FlatConfigData} based on - * <tt>java.applet.Applet</tt>. - * - * @author Franz-Josef Elmer - */ -public class AppletBasedConfigData extends FlatConfigData { - private final Applet _applet; - - /** - * Creates an instance based on the specified applet. - * The path is undefined. - */ - public AppletBasedConfigData(Applet applet) { - this(applet, null); - } - - /** Creates an instance based on the specified properties and path. */ - private AppletBasedConfigData(Applet applet, String path) { - super(path); - _applet = applet; - } - - protected String getValue(String fullKey) { - return _applet.getParameter(fullKey); - } - - protected ConfigData createConfigData(String path) { - return new AppletBasedConfigData(_applet, path); - } -} diff --git a/src/jcckit/util/ConfigData.java b/src/jcckit/util/ConfigData.java deleted file mode 100644 index 7a48bb3..0000000 --- a/src/jcckit/util/ConfigData.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2003-2004, Franz-Josef Elmer, All rights reserved - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details - * (http://www.gnu.org/copyleft/lesser.html). - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -package jcckit.util; - -/** - * Interface for hierarchically managed key-value pairs. The key is - * always a string which contains any kind of printable character except - * '/', '=', ':', and whitespace characters like ' ' and '\t'. - * The value is either a string or a <tt>ConfigData</tt> object. - * <p> - * This interface will be used by {@link ConfigParameters} in accordance - * with the Strategy design pattern. - * - * @author Franz-Josef Elmer - */ -public interface ConfigData { - /** - * Returns the full key. - * @param key A (relative) key. <tt>null</tt> is not allowed. - * @return the full key including path. - */ - public String getFullKey(String key); - - /** - * Returns the value associated with this key. - * @param key The relative key. <tt>null</tt> is not allowed. - * @return the associated value. Will be <tt>null</tt> if no value exists - * for <tt>key</tt>. - */ - public String get(String key); - - /** - * Returns the <tt>ConfigData</tt> object associated with this key. - * @param key The relative key. <tt>null</tt> is not allowed. - * @return the associated value. Will never return <tt>null</tt>. - * Instead an empty <tt>ConfigData</tt> is returned. - */ - public ConfigData getNode(String key); -} diff --git a/src/jcckit/util/ConfigParameters.java b/src/jcckit/util/ConfigParameters.java deleted file mode 100644 index 2594a25..0000000 --- a/src/jcckit/util/ConfigParameters.java +++ /dev/null @@ -1,321 +0,0 @@ -/* - * Copyright 2003-2004, Franz-Josef Elmer, All rights reserved - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details - * (http://www.gnu.org/copyleft/lesser.html). - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -package jcckit.util; - -import java.awt.Color; -import java.util.StringTokenizer; - -import net.sourceforge.plantuml.graphic.HtmlColorSet; -import net.sourceforge.plantuml.graphic.HtmlColorSetSimple; -import net.sourceforge.plantuml.graphic.IHtmlColorSet; -import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity; - -/** - * Read-only class for hierarchically organized key-value pairs. - * The key is always a string. The following value types are - * supported: - * <ul><li><tt>String</tt> - * <li><tt>boolean</tt> - * <li><tt>int</tt> - * <li><tt>double</tt> - * <li><tt>double[]</tt> - * <li><tt>Color</tt> - * <li><tt>ConfigParameters</tt> - * </ul> - * <p> - * In accordance with the Strategy design pattern the retrieval of - * a key-value pair is delegated to an instance of - * {@link ConfigData}. - * - * @author Franz-Josef Elmer - */ -public class ConfigParameters { - private final ConfigData _configData; - - /** Creates an instance from the specified <tt>ConfigData</tt> object. */ - public ConfigParameters(ConfigData configData) { - _configData = configData; - } - - /** - * Returns the full key. - * @return the path concatenated with <tt>key</tt>. - * @see ConfigData#getFullKey - */ - public String getFullKey(String key) { - return _configData.getFullKey(key); - } - - /** - * Returns the string value associated with the specified key. - * @param key The (relative) key. <tt>null</tt> is not allowed. - * @return the corresponding value. Will always be not <tt>null</tt>. - * @throws IllegalArgumentException if no value exists for <tt>key</tt>. - * The exception message is the full key. - */ - public String get(String key) { - String result = _configData.get(key); - if (result == null) { - throw new IllegalArgumentException(getFullKey(key)); - } - return result; - } - - /** - * Returns the string value associated with the specified key or - * <tt>defaultValue</tt> if undefined. - * @param key The (relative) key. <tt>null</tt> is not allowed. - * @param defaultValue The default value. Can be <tt>null</tt>. - * @return the corresponding value or <tt>defaultValue</tt>. - */ - public String get(String key, String defaultValue) { - String result = _configData.get(key); - if (result == null) { - result = defaultValue; - } - return result; - } - - /** - * Returns the boolean associated with the specified key. - * @param key The (relative) key. <tt>null</tt> is not allowed. - * @return <tt>true</tt> if the value is "true" otherwise <tt>false</tt>. - * @throws IllegalArgumentException if no value exists for <tt>key</tt>. - * The exception message is the full key. - * @throws NumberFormatException if the value is neither "true" nor "false". - */ - public boolean getBoolean(String key) { - return parseBoolean(get(key), key); - } - - /** - * Returns the boolean associated with the specified key. - * @param key The (relative) key. <tt>null</tt> is not allowed. - * @param defaultValue The default value. Can be <tt>null</tt>. - * @return <tt>true</tt> if the value is "true" otherwise <tt>false</tt>. - * @throws NumberFormatException if the value is neither "true" nor "false". - */ - public boolean getBoolean(String key, boolean defaultValue) { - String value = _configData.get(key); - return value == null ? defaultValue : parseBoolean(value, key); - } - - private boolean parseBoolean(String value, String key) { - if (value.equals("true")) { - return true; - } else if (value.equals("false")) { - return false; - } else { - throw createNumberFormatException("boolean", value, key); - } - } - - private NumberFormatException createNumberFormatException(String text, - String value, - String key) { - return new NumberFormatException("Not a " + text + ": " + getFullKey(key) - + " = " + value); - } - - /** - * Returns the integer associated with the specified key. - * The value can be either - * <ul><li>a decimal number (starting with a non-zero digit), - * <li>a hexadecimal number (starting with <tt>0x</tt>), or - * <li>an octal number (starting with zero). - * </ul> - * @param key The (relative) key. <tt>null</tt> is not allowed. - * @return the integer value. - * @throws IllegalArgumentException if no value exists for <tt>key</tt>. - * The exception message is the full key. - * @throws NumberFormatException if the value is not a number. - * The exception message contains the full key and the invalid value. - */ - public int getInt(String key) { - return parseInt(get(key), key); - } - - /** - * Returns the integer associated with the specified key or - * <tt>defaultValue</tt> if no key-value pair exists for the specified key. - * The value can be either - * <ul><li>a decimal number (starting with a non-zero digit), - * <li>a hexadecimal number (starting with <tt>0x</tt>), or - * <li>an octal number (starting with zero). - * </ul> - * @param key The (relative) key. <tt>null</tt> is not allowed. - * @param defaultValue The default value. Can be <tt>null</tt>. - * @return the integer value. - * @throws NumberFormatException if the value exists but is not a number. - * The exception message contains the full key and the invalid value. - */ - public int getInt(String key, int defaultValue) { - String value = _configData.get(key); - return value == null ? defaultValue : parseInt(value, key); - } - - private int parseInt(String value, String key) { - try { - return Integer.decode(value).intValue(); - } catch (NumberFormatException e) { - throw createNumberFormatException("number", value, key); - } - } - - /** - * Returns the double associated with the specified key. - * @param key The (relative) key. <tt>null</tt> is not allowed. - * @return the double value. - * @throws IllegalArgumentException if no value exists for <tt>key</tt>. - * The exception message is the full key. - * @throws NumberFormatException if the value is not a valid number. - * The exception message contains the full key and the invalid value. - */ - public double getDouble(String key) { - return parseDouble(get(key), key); - } - - /** - * Returns the double associated with the specified key or - * <tt>defaultValue</tt> if no key-value pair exists for the specified key. - * @param key The (relative) key. <tt>null</tt> is not allowed. - * @param defaultValue The default value. Can be <tt>null</tt>. - * @return the double value. - * @throws NumberFormatException if the value exists but is not a valid - * number. - * The exception message contains the full key and the invalid value. - */ - public double getDouble(String key, double defaultValue) { - String value = _configData.get(key); - return value == null ? defaultValue : parseDouble(value, key); - } - - private double parseDouble(String value, String key) { - try { - return new Double(value).doubleValue(); - } catch (NumberFormatException e) { - throw createNumberFormatException("number", value, key); - } - } - - /** - * Returns the array of doubles associated with the specified key. - * The numbers are separated by whitespaces. - * @param key The (relative) key. <tt>null</tt> is not allowed. - * @return the array of double values. - * @throws IllegalArgumentException if no value exists for <tt>key</tt>. - * The exception message is the full key. - * @throws NumberFormatException if the value exists but is not a - * sequence of number. The exception message contains - * the full key and the invalid value. - */ - public double[] getDoubleArray(String key) { - return parseDoubleArray(get(key), key); - } - - /** - * Returns the array of doubles associated with the specified key - * or <tt>defaultValue</tt> if no key-value pair exists for - * the specified key. The numbers are separated by whitespaces. - * @param key The (relative) key. <tt>null</tt> is not allowed. - * @param defaultValue The default value. Can be <tt>null</tt>. - * @return the array of double values. - * @throws NumberFormatException if the value exists but is not a - * sequence of number. The exception message contains - * the full key and the invalid value. - */ - public double[] getDoubleArray(String key, double[] defaultValue) { - String value = _configData.get(key); - return value == null ? defaultValue : parseDoubleArray(value, key); - } - - private double[] parseDoubleArray(String value, String key) { - try { - StringTokenizer tokenizer = new StringTokenizer(value); - double[] result = new double[tokenizer.countTokens()]; - for (int i = 0; i < result.length; i++) { - result[i] = new Double(tokenizer.nextToken()).doubleValue(); - } - return result; - } catch (NumberFormatException e) { - throw createNumberFormatException("sequence of numbers", value, key); - } - } - - /** - * Returns the color associated with the specified key. - * The color is coded as - * <ul><li>a decimal number (starting with a non-zero digit), - * <li>a hexadecimal number (starting with <tt>0x</tt>), or - * <li>an octal number (starting with zero). - * </ul> - * @param key The (relative) key. <tt>null</tt> is not allowed. - * @return the color. - * @throws NumberFormatException if the value exists but is not a number. - * The exception message contains the full key and the invalid value. - */ - public Color getColor(String key) { - return parseColor(get(key), key); - } - - /** - * Returns the color associated with the specified key or the specified - * default value if no key-value pair exists for the specified key. - * The color is coded as - * <ul><li>a decimal number (starting with a non-zero digit), - * <li>a hexadecimal number (starting with <tt>0x</tt>), or - * <li>an octal number (starting with zero). - * </ul> - * @param key The (relative) key. <tt>null</tt> is not allowed. - * @param defaultValue The default value. Can be <tt>null</tt>. - * @return the color or <tt>null</tt> if the value is an empty string. - * @throws NumberFormatException if the value exists but is not a number. - * The exception message contains the full key and the invalid value. - */ - public Color getColor(String key, Color defaultValue) { - String value = _configData.get(key); - return value == null ? defaultValue : parseColor(value, key); - } - - private Color parseColor(String value, String key) { - try { - return value.length() == 0 ? null : decodeInternal(value); - } catch (NumberFormatException e) { - throw createNumberFormatException("number", value, key); - } - } - -static private IHtmlColorSet colors = new HtmlColorSetSimple(); -private Color decodeInternal(String value) { - if (colors.getColorIfValid(value)!=null) { - return new ColorMapperIdentity().getMappedColor(colors.getColorIfValid(value)); - } - return Color.decode(value); -} - - /** - * Returns the child node associated with the specified key. - * This method returns in any case a non-<tt>null</tt> result. - * @param key The (relative) key. <tt>null</tt> is not allowed. - * @return the corresponding child node which may be empty. - */ - public ConfigParameters getNode(String key) { - return new ConfigParameters(_configData.getNode(key)); - } -} diff --git a/src/jcckit/util/ConfigParametersBasedConfigData.java b/src/jcckit/util/ConfigParametersBasedConfigData.java deleted file mode 100644 index 77138a7..0000000 --- a/src/jcckit/util/ConfigParametersBasedConfigData.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2003-2004, Franz-Josef Elmer, All rights reserved - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details - * (http://www.gnu.org/copyleft/lesser.html). - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -package jcckit.util; - -/** - * An implementation of {@link ConfigData} based on two instances of - * {@link ConfigParameters}. The second one serves as a set of - * default parameters. It will be used if the first one has not the requested - * key-value pair. - * - * @author Franz-Josef Elmer - */ -public class ConfigParametersBasedConfigData implements ConfigData { - private ConfigParameters _config; - private ConfigParameters _defaultConfig; - - /** - * Creates an instance. - * @param config A set of key-value pairs. - * @param defaultConfig The default set of key-value pairs. - */ - public ConfigParametersBasedConfigData(ConfigParameters config, - ConfigParameters defaultConfig) { - _config = config; - _defaultConfig = defaultConfig; - } - - /** - * Returns the full key. - * @param key A (relative) key. <tt>null</tt> is not allowed. - * @return the full key including path. - */ - public String getFullKey(String key) { - return _config.getFullKey(key); - } - - /** - * Returns the value associated with this key. - * @param key The relative key. <tt>null</tt> is not allowed. - * @return the associated value. Will be <tt>null</tt> if no value exists - * for <tt>key</tt>. - */ - public String get(String key) { - String value = _config.get(key, null); - return value == null ? _defaultConfig.get(key, null) : value; - } - - /** - * Returns the <tt>ConfigData</tt> object associated with this key. - * @param key The relative key. <tt>null</tt> is not allowed. - * @return the associated value. Will never return <tt>null</tt>. - * Instead an empty <tt>ConfigData</tt> is returned. - */ - public ConfigData getNode(String key) { - return new ConfigParametersBasedConfigData(_config.getNode(key), - _defaultConfig.getNode(key)); - } -} diff --git a/src/jcckit/util/Factory.java b/src/jcckit/util/Factory.java deleted file mode 100644 index 240f8be..0000000 --- a/src/jcckit/util/Factory.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright 2003-2004, Franz-Josef Elmer, All rights reserved - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details - * (http://www.gnu.org/copyleft/lesser.html). - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -package jcckit.util; - -import java.lang.reflect.Constructor; - -/** - * General purpose factory method based on {@link ConfigParameters} - * and Java's Reflection API. - * - * @author Franz-Josef Elmer - */ -public class Factory { - /** The constant defining the key <tt>className</tt>. */ - public static final String CLASS_NAME_KEY = "className"; - - /** No public constructor necessary. */ - private Factory() {} - - /** - * Creates an instance of the specified class. - * @param className Fully-qualified name of a class with a default - * constructor. - * @return a new instance. - * @throws IllegalArgumentException if the instance could be created. - */ - public static Object create(String className) { - try { - return Class.forName(className).newInstance(); - } catch (Throwable t) { - throw new IllegalArgumentException("Could not create an instance of " - + className + " because of " + t); - } - } - - /** - * Creates an object based on the specified configuration - * parameters. The class of the object is determined by the - * parameter with the key {@link #CLASS_NAME_KEY}. - * The constructor with a single argument of the type - * <tt>ConfigParameter</tt> is invoked with the argument - * <tt>configParameters</tt>. If such a constructor - * does not exists the default constructor is invoked. If - * neither of these constructors exist a {@link FactoryException} - * is thrown. - * @param configParameters Configuration parameters. - * @return the newly created object. - * @throws IllegalArgumentException if key <tt>className</tt> is missing. - * @throws FactoryException wrapping any kind of exception or error occured. - */ - public static Object create(ConfigParameters configParameters) { - String className = configParameters.get(CLASS_NAME_KEY); - return createObject(configParameters, className); - } - - /** - * Creates an object based on the specified configuration - * parameters and default class name. If the - * parameter with the key {@link #CLASS_NAME_KEY} is missed in - * <tt>configParameters</tt> <tt>defaultClassName</tt> is used. - * Otherwise it works as {@link #create(jcckit.util.ConfigParameters)}. - * @param configParameters Configuration parameters. - * @param defaultClassName Default class name. - * @return the newly created object. - * @throws FactoryException wrapping any kind of exception or error occured. - */ - public static Object create(ConfigParameters configParameters, - String defaultClassName) { - String className = configParameters.get(CLASS_NAME_KEY, defaultClassName); - return createObject(configParameters, className); - } - - /** - * Creates an object based on the specified configuration - * parameters or returns the default object. This method behaves - * as {@link #create(jcckit.util.ConfigParameters)}, except that is does - * not throw an <tt>IllegalArgumentException</tt> if key <tt>className</tt> - * is missing. Instead <tt>defaultObject</tt> is returned. - */ - public static Object createOrGet(ConfigParameters configParameters, - Object defaultObject) { - String className = configParameters.get(CLASS_NAME_KEY, null); - return className == null ? defaultObject - : createObject(configParameters, className); - } - - private static Object createObject(ConfigParameters configParameters, - String className) { - try { - Class c = Class.forName(className); - Object result = null; - Constructor constructor = null; - try { - constructor = c.getConstructor(new Class[] {ConfigParameters.class}); - result = constructor.newInstance(new Object[] {configParameters}); - } catch (NoSuchMethodException e) { - result = c.newInstance(); - } - return result; - } catch (Throwable t) { - throw new FactoryException(configParameters, CLASS_NAME_KEY, t); - } - } -} diff --git a/src/jcckit/util/FactoryException.java b/src/jcckit/util/FactoryException.java deleted file mode 100644 index 28d0f39..0000000 --- a/src/jcckit/util/FactoryException.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2003-2004, Franz-Josef Elmer, All rights reserved - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details - * (http://www.gnu.org/copyleft/lesser.html). - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -package jcckit.util; - -import java.lang.reflect.InvocationTargetException; - -/** - * Exception thrown in the case of an error during creation of a new - * object by {@link Factory#create}. - * - * @author Franz-Josef Elmer - */ -public class FactoryException extends RuntimeException { - private final String _fullKey; - private final String _className; - private final Object _reason; - - /** - * Creates a new instance based on the specified configuration parameters - * and reason object. - * <p> - * If <tt>reason</tt> is an instance of <tt>InvocationTargetException</tt> - * it will be replaced by the wrapped <tt>Throwable</tt>. - * @param configParameters Configuration parameters from which the - * <tt>className</tt> will be extracted (if it exists, otherwise - * <tt>null</tt> will be taken). - * @param reason The reason causing this exception. Most often an - * an exception. - */ - public FactoryException(ConfigParameters configParameters, String key, - Object reason) { - _fullKey = configParameters.getFullKey(key); - _className = configParameters.get(key, null); - if (reason instanceof InvocationTargetException) { - reason = ((InvocationTargetException) reason).getTargetException(); - } - _reason = reason; - } - - /** Returns the full class name key. */ - public String getFullKey() { - return _fullKey; - } - - /** Returns the fully qualified class name. */ - public String getClassName() { - return _className; - } - - /** Returns the reason object causing this exception. */ - public Object getReason() { - return _reason; - } - - /** - * Renders this instance as follows: <tt>jcckit.util.FactoryException: - * <i>full key</i> = <i>class name</i>: <i>reason</i></tt>. - */ - public String toString() { - return getClass().getName() + ": " + _fullKey + " = " + _className - + ": " + _reason; - } -} diff --git a/src/jcckit/util/FlatConfigData.java b/src/jcckit/util/FlatConfigData.java deleted file mode 100644 index 1384e5c..0000000 --- a/src/jcckit/util/FlatConfigData.java +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright 2003-2004, Franz-Josef Elmer, All rights reserved - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details - * (http://www.gnu.org/copyleft/lesser.html). - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -package jcckit.util; - -/** - * An implementation of <tt>ConfigData</tt> based on a flat - * representation of the hierachically organized key-value pairs. - * Concrete subclasses must implement the methods - * {@link #getValue} and {@link #createConfigData} in accordance - * with the Template Method pattern and Factory Method pattern, - * respectively. - * <p> - * In a flat representation of hierachically organized key-value - * pairs all key-value pairs are stored in a single <tt>Hashtable</tt>. - * Its key is the <em>full key</em> of the configuration data (i.e. the key - * including its path). - * <p> - * Example (using the notation for a <tt>.properties</tt> file): - * <pre> - * title = example - * symbolAttributes/className = jcckit.graphic.BasicDrawingAttributes - * symbolAttributes/fillColor = 0xcaffee - * symbolAttributes/lineColor = 0xff0000 - * </pre> - * The following table shows the result of some method calls at a - * <tt>FlatConfigData</tt> instance prepared with - * this example: - * <p> - * <center> - * <table border=1 cellspacing=1 cellpadding=5> - * <tr><th>Method call</th><th>Result</th></tr> - * <tr><td>get("title")</td><td>example</td></tr> - * <tr><td>getNode("symbolAttributes").get("fillColor") - * </td><td>0xcaffee</td></tr> - * </table> - * </center> - * <p> - * In addition <tt>FlatConfigData</tt> implements <b>inheritance</b> - * of key-value pairs. - * Basically a node in the tree of key-value pairs - * may extend another node in the tree. - * The extended node inherit all key-value pairs from the extending - * one including the key-value pairs of all descendants. - * The value of a inherited key-value pair may be overridden. - * Also new key-value pairs may be placed in the inherited node or - * anywhere in the subtree. - * Note, that the extending node has to be a node which is not a - * descendant of the extended node (otherwise a circulary chain - * of references occurs). As a consequence not more than 20 inheritance - * levels are allowed. - * <p> - * The implementation of this kind of inheritance in a flat hashtable - * is done by an additional key-value pair of the form - * <pre> - * <i>extending-node</i><b>/</b> = <i>extended-node</i><b>/</b> - * </pre> - * Example: - * <pre> - * A/a/priority = high - * A/a/alpha/hello = universe - * A/a/alpha/answer = 42 - * <b>A/b/1/ = A/a/</b> - * A/b/1/alpha/hello = world - * A/b/1/alpha/question = 6 * 7 - * </pre> - * The following table shows the result of various method calls - * applied at the node <tt>A/b/1/</tt> of a <tt>FlatConfigData</tt> - * instance prepared with this example: - * <p> - * <center> - * <table border=1 cellspacing=1 cellpadding=5> - * <tr><th>Method call</th><th>Result</th><th>Comment</th></tr> - * <tr><td>get("priority")</td><td>high</td><td>inherited</td></tr> - * <tr><td>getNode("alpha").get("hello") - * </td><td>world</td><td>overridden</td></tr> - * <tr><td>getNode("alpha").get("question") - * </td><td>6 * 7</td><td>added</td></tr> - * <tr><td>getNode("alpha").get("answer") - * </td><td>42</td><td>inherited</td></tr> - * </table> - * </center> - * - * @author Franz-Josef Elmer - */ -public abstract class FlatConfigData implements ConfigData { - private final String _path; - - /** Creates a new instance for the specified path. */ - public FlatConfigData(String path) { - _path = path; - } - - /** - * Returns the full key. - * @param key A (relative) key. <tt>null</tt> is not allowed. - * @return the path concatenated with <tt>key</tt> or <tt>key</tt> - * if the path is undefined. - */ - public String getFullKey(String key) { - return _path == null ? key : _path + key; - } - - /** - * Returns the value associated with this key. - * @param key The relative key. <tt>null</tt> is not allowed. - * @return the associated value. Will be <tt>null</tt> if no value exists - * for <tt>key</tt>. - */ - public String get(String key) { - return get(_path, key, 0); - } - - /** - * Obtains a value in accordance with hierarchy (<tt>path</tt>) and - * inheritance (recursive calls of this routine). - */ - private String get(String path, String key, int numberOfLevels) { - String result = null; - if (numberOfLevels < 20) { - String fullKey = path == null ? key : path + key; - result = getValue(fullKey); - if (result == null) { - // posAfterDelim is the index in path just after '/' - int posAfterDelim = path == null ? -1 : path.length(); - String replacement; - while (posAfterDelim > 0) { - // look for a sub-tree - replacement = getValue(path.substring(0, posAfterDelim)); - if (replacement != null) { - // sub-tree found, add last part of the original path - result = get(replacement + path.substring(posAfterDelim), key, - numberOfLevels + 1); - // break whether result is null or not. - break; - } - // remove last element from the path - posAfterDelim = path.lastIndexOf('/', posAfterDelim - 2) + 1; - } - } - } - return result; - } - - /** - * Returns the <tt>ConfigData</tt> object associated with this key. - * @param key The relative key. - * @return the associated value. Will never return <tt>null</tt>. - * Instead an empty <tt>ConfigData</tt> is returned. - */ - public ConfigData getNode(String key) { - String path = (_path == null ? key : _path + key) + '/'; - return createConfigData(path); - } - - /** - * Returns the value for the specified full key from the flat - * representation of the hierarchically organized key-value pairs. - * @param fullKey The full key including path. <tt>null</tt> is not allowed. - * @return the value or <tt>null</tt> if not found. - */ - protected abstract String getValue(String fullKey); - - /** - * Returns the <tt>FlatConfigData</tt> object for the specified full path. - * In general <tt>path</tt> will be used in the constructor with - * path argument. - * @param path The full path. - * @return a new instance in any case. - */ - protected abstract ConfigData createConfigData(String path); -} diff --git a/src/jcckit/util/Format.java b/src/jcckit/util/Format.java deleted file mode 100644 index c4e04e2..0000000 --- a/src/jcckit/util/Format.java +++ /dev/null @@ -1,208 +0,0 @@ -/* - * Copyright 2003-2004, Franz-Josef Elmer, All rights reserved - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details - * (http://www.gnu.org/copyleft/lesser.html). - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -package jcckit.util; - -import java.util.Vector; - -/** - * A helper class for formatting numbers according to - * a <tt>printf</tt>-like format string. Each instance of - * this class is initialized by a format string for a - * single number. - * - * @author Franz-Josef Elmer - */ -public class Format implements TicLabelFormat { - /** - * Creates a new instance based of specified key-value pair of the - * specified configuration parameters. - * @param config Config parameters. - * @param key The key of the key-value pair in <tt>config</tt> containing - * the format string. - * @return <tt>null</tt> if undefined key-value pair or format string - * is an empty string. - * @throws FactoryException if the format string is invalid. - */ - public static Format create(ConfigParameters config, String key) { - Format result = null; - String format = config.get(key, null); - if (format != null && format.length() > 0) { - try { - result = new Format(format); - } catch (Exception e) { - throw new FactoryException(config, key, e); - } - } - return result; - } - - private final FormatElement[] _formatElements; - private final Vector _staticParts; - - /** - * Creates an instance for the specified format string. - * The format string is an alternation of some static texts and - * format elements. - * A format element has to start with '%' and it must end with - * one of the following format descriptors: - * <table border=0 cellpadding=5> - * <tr><td><tt>d</tt></td> - * <td>decimal integer</td></tr> - * <tr><td><tt>o</tt></td> - * <td>octal integer</td></tr> - * <tr><td><tt>x</tt></td> - * <td>hex integer</td></tr> - * <tr><td><tt>f</tt></td> - * <td>floating point number with a fixed decimal point</td></tr> - * <tr><td><tt>e, E</tt></td> - * <td>floating point number in logarithmic format</td></tr> - * <tr><td><tt>g, G</tt></td> - * <td>floating point number rendered either in fixed-decimal - * format of logarithmic format depending on the size of - * the mantissa.</td></tr> - * </table> - * The characters between '%' and the decriptor are optional. - * They can be grouped into - * <ul><li>modifier<br> - * it is - * <ul><li>'-' if the formated result should be flushed left - * <li>'+' if the sign should be always appear - * <li>'0' if the leading space should be filled with zeros - * </ul> - * <li>width<br> - * a decimal number given the minimum number of characters - * of the result - * <li>precision - * </ul> - * A plain '%' is coded as '%%'. - * @param formatString The format string. - * @exception IllegalArgumentException if invalid format string. - */ - public Format(String formatString) { - _staticParts = new Vector(); - Vector formatElements = new Vector(); - StringBuffer part = new StringBuffer(); - boolean insideFormatElement = false; - boolean atPercentSymbol = false; - for (int i = 0, n = formatString.length(); i < n; i++) { - char c = formatString.charAt(i); - if (insideFormatElement) { - part.append(c); - if (FormatElement.DESCRIPTORS.indexOf(c) >= 0) { - formatElements.addElement(new String(part)); - part.setLength(0); - insideFormatElement = false; - } - } else if (atPercentSymbol) { - atPercentSymbol = false; - if (c != '%') { - _staticParts.addElement(new String(part)); - part.setLength(0); - insideFormatElement = true; - } - part.append(c); - if (FormatElement.DESCRIPTORS.indexOf(c) >= 0) { - formatElements.addElement(new String(part)); - part.setLength(0); - insideFormatElement = false; - } - } else { - if (c == '%') { - atPercentSymbol = true; - } else { - part.append(c); - } - } - } - if (insideFormatElement) { - formatElements.addElement(new String(part)); - } else { - _staticParts.addElement(new String(part)); - } - - _formatElements = new FormatElement[formatElements.size()]; - for (int i = 0; i < _formatElements.length; i++) { - _formatElements[i] - = new FormatElement((String) formatElements.elementAt(i)); - } - } - - /** - * Format a number. - * If there are no format elements the numbers will be ignored. - * If there are more than one format elements the - * additional format elements will be ignored and only the static parts - * are taken. - * @param number Number to be formated. - * @return Formated number. - */ - public String form(long number) { - StringBuffer result = new StringBuffer(); - result.append(_staticParts.elementAt(0)); - if (_formatElements.length > 0) { - _formatElements[0].form(result, number); - } - return appendRest(result); - } - - /** - * Format a number. - * If there are no format elements the numbers will be ignored. - * If there are more than one format elements the - * additional format elements will be ignored and only the static parts - * are taken. - * @param number Number to be formated. - * @return Formated number. - */ - public String form(double number) { - StringBuffer result = new StringBuffer(); - result.append(_staticParts.elementAt(0)); - if (_formatElements.length > 0) { - _formatElements[0].form(result, number); - } - return appendRest(result); - } - - private String appendRest(StringBuffer buffer) { - for (int i = 1, n = _staticParts.size(); i < n; i++) { - buffer.append(_staticParts.elementAt(i)); - } - return new String(buffer); - } - - /** - * Format an array of double numbers. - * If there are less format elements than numbers the additional numbers - * will be ignored. If there are less numbers than format elements the - * additional format elements will be ignored and only the static parts - * are taken. - * @param numbers Numbers to be formated. - * @return Formated numbers. - */ - public String form(double[] numbers) { - StringBuffer result = new StringBuffer(); - for (int i = 0, n = _staticParts.size(); i < n; i++) { - result.append(_staticParts.elementAt(i)); - if (i < _formatElements.length && i < numbers.length) { - _formatElements[i].form(result, numbers[i]); - } - } - return new String(result); - } -} diff --git a/src/jcckit/util/FormatElement.java b/src/jcckit/util/FormatElement.java deleted file mode 100644 index 84f629a..0000000 --- a/src/jcckit/util/FormatElement.java +++ /dev/null @@ -1,242 +0,0 @@ -/* - * Copyright 2003-2004, Franz-Josef Elmer, All rights reserved - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details - * (http://www.gnu.org/copyleft/lesser.html). - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -package jcckit.util; - -/** - * - * - * @author Franz-Josef Elmer - */ -class FormatElement { - /** All descriptor characters. */ - static final String DESCRIPTORS = "doxfeEgG"; - private static final String INT_DESCRIPTORS = "dox"; - private static final int INT_DESCRIPTOR = 0; - private static final int FLOAT_DESCRIPTOR = 1; - /** - * Calculate the integer power of a floating point number. - * @param n Exponent. - * @param x Number. - * @return <tt>x^n</tt>. - */ - private static final double power(double x, int n) { - return n < 0 ? 1.0 / power2(x, -n) : power2(x, n); - } - - /** Calculate <tt>x^n</tt> recursively assuming <tt>n > 0</tt>. */ - private static final double power2(double x, int n) { - switch (n) { - case 0: return 1; - case 1: return x; - default: - double p = power2(x, n / 2); - return p * p * power2(x, n % 2); - } - } - - private final char _descriptor; - private final int _descriptorType; - private final double _tenToPrecision; - private boolean _decimalPoint; - private boolean _flushLeft; - private boolean _leadingZeros; - private boolean _alwaysSign; - private int _width; - private int _precision; - - /** Creates an instance for the specified format string. */ - FormatElement(String formatString) { - int len = formatString.length() - 1; - _descriptor = formatString.charAt(len); - if (DESCRIPTORS.indexOf(_descriptor) < 0) { - throw new IllegalArgumentException("Format element '" + formatString - + "' does not ends with one of the following characters: " - + DESCRIPTORS); - } - _descriptorType = INT_DESCRIPTORS.indexOf(_descriptor) >= 0 - ? INT_DESCRIPTOR : FLOAT_DESCRIPTOR; - if (formatString.length() > 1) { - switch (formatString.charAt(0)) { - case '-': - _flushLeft = true; - formatString = formatString.substring(1); - break; - case '0': - _leadingZeros = true; - formatString = formatString.substring(1); - break; - case '+': - _alwaysSign = true; - formatString = formatString.substring(1); - break; - } - len = formatString.length() - 1; - int index = formatString.indexOf('.'); - _decimalPoint = index >= 0; - int last = _decimalPoint ? index : len; - if (last > 0) { - _width = Integer.parseInt(formatString.substring(0, last)); - } - if (_decimalPoint) { - index++; - if (index < len) { - _precision = Integer.parseInt(formatString.substring(index, len)); - } - } - } - _tenToPrecision = power(10, _precision); - } - - /** - * Format a number in accordance of the format string - * given at the initialisation of this instance. - * @param buffer Buffer to which the formated output will be appended. - * @param number Number to be formated. - */ - public void form(StringBuffer buffer, long number) { - if (_descriptorType == FLOAT_DESCRIPTOR) { - form(buffer, (double) number); - } else { - // Format absolut value in the right base - buffer.append(form(number < 0, - Long.toString(Math.abs(number), - _descriptor == 'o' ? 8 - : (_descriptor == 'x' ? 16 : 10)), - "")); - } - } - - /** - * Format a number in accordance of the format string - * given at the initialisation of this instance. - * @param buffer Buffer to which the formated output will be appended. - * @param number Number to be formated. - */ - public void form(StringBuffer buffer, double number) { - if (_descriptorType == INT_DESCRIPTOR) { - form(buffer, (long) Math.floor(number + 0.5)); - } else if (_descriptor == 'f') { - buffer.append(formF(number)); - } else if (_descriptor == 'e' || _descriptor == 'E') { - buffer.append(formE(number)); - } else if (_descriptor == 'g' || _descriptor == 'G') { - String formF = formF(number); - String formE = formE(number); - buffer.append(formF.length() > formE.length() ? formE : formF); - } - } - - private String form(boolean negativeValue, String intPart, String fracPart) { - int len = intPart.length() + fracPart.length(); - - // Buffer holding the result - StringBuffer result = new StringBuffer(); - int count = 0; - - // add sign if necessary - if (_alwaysSign || negativeValue) { - result.append(negativeValue ? '-' : '+'); - count++; - } - - // add zeros if necessary - if (_leadingZeros) { - for (int i = count + len; i < _width; i++) { - result.append('0'); - count++; - } - } - - // add number - result.append(intPart).append(fracPart); - count += len; - - // add spaces if necessary - if (_flushLeft) { - for (; count < _width; count++) { - result.append(' '); - } - } else { - for (; count < _width; count++) { - result.insert(0, ' '); - } - } - - return new String(result); - } - - /** Format floating point number with exponent. */ - private String formE(double number) { - // format absolute mantisse - int exponent = 0; - String zeros = "00000000000000000000000".substring(0, _precision + 1); - if (number != 0) { - exponent = (int) Math.floor(Math.log(Math.abs(number)) / Math.log(10)); - double mantisse = Math.floor(Math.abs(number * power(10.0, - _precision - exponent)) + 0.5); - if (mantisse >= 10 * _tenToPrecision) { - exponent++; - mantisse = Math.floor(Math.abs(number * power(10.0, - _precision - exponent)) + 0.5); - } - zeros = Long.toString((long) mantisse); - } - - // make fractional part - StringBuffer fracPart = new StringBuffer(); - if (_decimalPoint) { - fracPart.append('.').append(zeros.substring(1)); - } - - // make exponent - fracPart.append(Character.isLowerCase(_descriptor) ? 'e': 'E') - .append(exponent < 0 ? '-' : '+'); - exponent = Math.abs(exponent); - for (int i = 0, n = fracPart.length(); i < 3; i++) { - fracPart.insert(n, Character.forDigit(exponent % 10, 10)); - exponent /= 10; - } - - return form(number < 0, zeros.substring(0, 1), new String(fracPart)); - } - - /** Format floating point number. */ - private String formF(double number) { - // Format absolut value - double multiplier = number < 0 ? - _tenToPrecision : _tenToPrecision; - String digits - = Long.toString((long) Math.floor(number * multiplier + 0.5)); - String intPart = digits; - StringBuffer fracPart = new StringBuffer(); - if (_decimalPoint) { - int len = digits.length() - _precision; - fracPart.append('.').append(digits.substring(Math.max(0, len))); - if (len > 0) { - intPart = digits.substring(0, len); - } else { - intPart = "0"; - for (; len < 0; len++) { - fracPart.insert(1, '0'); - } - } - } - - return form(number < 0, intPart, new String(fracPart)); - } -} diff --git a/src/jcckit/util/Point.java b/src/jcckit/util/Point.java deleted file mode 100644 index 623c78f..0000000 --- a/src/jcckit/util/Point.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2003-2004, Franz-Josef Elmer, All rights reserved - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details - * (http://www.gnu.org/copyleft/lesser.html). - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -package jcckit.util; - -/** - * Immutable class of a two-dimensional point with floating point - * coordinates. - * - * @author Franz-Josef Elmer - */ -public class Point { - private final double _x; - private final double _y; - - /** - * Creates an instance for the specified vector. The value of the - * first/second element of <tt>vector</tt> denotes the x/y value. - * If <tt>vector</tt> is <tt>null</tt> or not long enough 0 will be used - * as default values. - */ - public Point(double[] vector) { - double x = 0; - double y = 0; - if (vector != null && vector.length > 0) { - x = vector[0]; - if (vector.length > 1) { - y = vector[1]; - } - } - _x = x; - _y = y; - } - - /** Creates an instance for the specified coordinates. */ - public Point(double x, double y) { - _x = x; - _y = y; - } - - /** Returns the x-coordinate of the point. */ - public double getX() { - return _x; - } - - /** Returns the y-coordinate of the point. */ - public double getY() { - return _y; - } -} diff --git a/src/jcckit/util/PropertiesBasedConfigData.java b/src/jcckit/util/PropertiesBasedConfigData.java deleted file mode 100644 index 1d5bcc4..0000000 --- a/src/jcckit/util/PropertiesBasedConfigData.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2003-2004, Franz-Josef Elmer, All rights reserved - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details - * (http://www.gnu.org/copyleft/lesser.html). - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -package jcckit.util; - -import java.io.FileInputStream; -import java.io.IOException; -import java.util.Properties; - -/** - * Implementation of {@link FlatConfigData} based on - * <tt>java.util.Properties</tt>. - * - * @author Franz-Josef Elmer - */ -public class PropertiesBasedConfigData extends FlatConfigData { - private final Properties _properties; - - /** - * Creates an instance from the specified <tt>.properties</tt> file. - * @param fileName File name of the <tt>.properties</tt> file relative - * to the working directory or absolute. - * @throws IOException if the <tt>.properties</tt> does not exist or could - * not be read. - */ - public PropertiesBasedConfigData(String fileName) throws IOException { - super(null); - _properties = new Properties(); - _properties.load(new FileInputStream(fileName)); - } - - /** - * Creates an instance based on the specified properties. - * The path is undefined. - */ - public PropertiesBasedConfigData(Properties properties) { - this(properties, null); - } - - /** Creates an instance based on the specified properties and path. */ - private PropertiesBasedConfigData(Properties properties, String path) { - super(path); - _properties = properties; - } - - /** - * Returns the value for the specified full key. The call will be delegated - * to the wrapped <tt>java.util.properties</tt> object. - * @param fullKey The full key including path. <tt>null</tt> is not allowed. - * @return the value or <tt>null</tt> if not found. - */ - protected String getValue(String fullKey) { - return _properties.getProperty(fullKey); - } - - /** - * Returns a new instance of <tt>PropertiesBasedConfigData</tt> - * for the specified full path. The wrapped <tt>java.util.Properties</tt> - * will be the same as of this instance. - * @param path The full path. - * @return a new instance. - */ - protected ConfigData createConfigData(String path) { - return new PropertiesBasedConfigData(_properties, path); - } -} diff --git a/src/jcckit/util/TicLabelFormat.java b/src/jcckit/util/TicLabelFormat.java deleted file mode 100644 index 61d924c..0000000 --- a/src/jcckit/util/TicLabelFormat.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2003-2004, Franz-Josef Elmer, All rights reserved - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details - * (http://www.gnu.org/copyleft/lesser.html). - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -package jcckit.util; - -/** - * Format interface for tic labels. Maps a numerical tic value onto a string. - * - * @author Franz-Josef Elmer - */ -public interface TicLabelFormat -{ - /** - * Forms the specified tic value to a string. Note, the numerical - * <tt>ticValue</tt> may be mapped onto a non-numerical one. - */ - public String form(double ticValue); -} diff --git a/src/jcckit/util/Util.java b/src/jcckit/util/Util.java deleted file mode 100644 index 5715d5a..0000000 --- a/src/jcckit/util/Util.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2003-2004, Franz-Josef Elmer, All rights reserved - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details - * (http://www.gnu.org/copyleft/lesser.html). - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -package jcckit.util; - -/** - * Collection of static utility methods. - * - * @author Franz-Josef Elmer - */ -public class Util { - /** Private constructor to prevent instanciation of this class. */ - private Util() {} - - /** - * Returns the natural logarithm of the specified number if - * <tt>logScale</tt> is true. - * @return <tt>x</tt> if <tt>logScale == false</tt>. - */ - public static double log(double x, boolean logScale) { - return logScale ? Math.log(x) : x; - } - - /** - * Returns the exponential function of the specified number if - * <tt>logScale</tt> is true. - * @return <tt>x</tt> if <tt>logScale == false</tt>. - */ - public static double exp(double x, boolean logScale) { - return logScale ? Math.exp(x) : x; - } -} |