[Jukebox-cvs] CVS update: J4/src/java/gnu/j4/config Configuration.java
Brought to you by:
vtt
From: CVS B. <vt...@fr...> - 2000-11-02 08:48:31
|
User: vt Date: 00/11/02 01:48:25 Modified: src/java/gnu/j4/config Configuration.java Log: Updated the test case and fixed the bug. Not completely, though: the commas cannot be used in the values for now, until I get time to fix it. Revision Changes Path 1.32 +52 -2 J4/src/java/gnu/j4/config/Configuration.java CVSWEB Options: ------------------- CVSWeb: Annotate this file: http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/J4/src/java/gnu/j4/config/Configuration.java?annotate=1.32&cvsroot=jukebox4 CVSWeb: View this file: http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/J4/src/java/gnu/j4/config/Configuration.java?rev=1.32&content-type=text/x-cvsweb-markup&cvsroot=jukebox4 CVSWeb: Diff to previous version: http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/J4/src/java/gnu/j4/config/Configuration.java.diff?r1=1.32&r2=1.31&cvsroot=jukebox4 ----------------------------------- Index: Configuration.java =================================================================== RCS file: /usr/local/cvs/J4/src/java/gnu/j4/config/Configuration.java,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- Configuration.java 2000/08/24 20:35:49 1.31 +++ Configuration.java 2000/11/02 08:48:25 1.32 @@ -25,7 +25,7 @@ * target=_top>Java-Apache Project</a> in general and code written by <a * href="mailto:st...@ap...">Stefano Mazzocchi</a> in particular. * - * @version $Id: Configuration.java,v 1.31 2000/08/24 20:35:49 vt Exp $ + * @version $Id: Configuration.java,v 1.32 2000/11/02 08:48:25 vt Exp $ */ public class Configuration extends Hashtable { @@ -532,6 +532,34 @@ */ public void put(String key, Object value) { + // Preprocess the value. It may turn out that the value is a comma + // separated string, which will embarrass us a little. + + boolean split = false; + + if ( value instanceof String && ((String)value).indexOf(",") != -1 ) { + + split = true; + + //System.err.println(key + " split: '" + value + "'"); + + String valueAsString = (String)value; + Vector valueAsVector = new Vector(); + + // VT: FIXME: This way, it's impossible to have a comma in the + // value. Have to process the escape with a backslash. + + for ( StringTokenizer st = new StringTokenizer(valueAsString, ","); st.hasMoreTokens(); ) { + + String element = st.nextToken().trim(); + + //System.err.println(key + " element: '" + element + "'"); + valueAsVector.addElement(element); + } + + value = valueAsVector; + } + Object found = super.get(key); if ( found == null ) { @@ -543,6 +571,18 @@ } + if ( found instanceof String ) { + + //System.err.println(key + " restructure: '" + found + "'"); + Object first = found; + Vector set = new Vector(); + + super.remove(key); + set.addElement(first); + super.put(key, set); + found = set; + } + if ( found instanceof Vector ) { // OK, there's existing sequence already. @@ -551,7 +591,17 @@ if ( vFound.indexOf(value) == -1 ) { - vFound.addElement(value); + if ( split ) { + + for ( Enumeration e = ((Vector)value).elements(); e.hasMoreElements(); ) { + + vFound.addElement(e.nextElement()); + } + + } else { + + vFound.addElement(value); + } return; } else { |