velocity-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject cvs commit: jakarta-velocity/src/java/org/apache/velocity/runtime/configuration Configuration.java
Date Tue, 20 Mar 2001 20:29:48 GMT
geirm       01/03/20 12:29:47

  Modified:    src/java/org/apache/velocity/runtime/configuration
                        Configuration.java
  Log:
  Noted Leon as an author (he contributed the setStringProp() patch)
  
  Revision  Changes    Path
  1.18      +77 -2     jakarta-velocity/src/java/org/apache/velocity/runtime/configuration/Configuration.java
  
  Index: Configuration.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/configuration/Configuration.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- Configuration.java	2001/03/20 17:19:24	1.17
  +++ Configuration.java	2001/03/20 20:29:41	1.18
  @@ -153,7 +153,8 @@
    * @author <a href="mailto:daveb@miceda-data">Dave Bryson</a>
    * @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
    * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
  - * @version $Id: Configuration.java,v 1.17 2001/03/20 17:19:24 geirm Exp $
  + * @author <a href="mailto:leon@opticode.co.za">Leon Messerschmidt</a>
  + * @version $Id: Configuration.java,v 1.18 2001/03/20 20:29:41 geirm Exp $
    */
   public class Configuration extends Hashtable
   {
  @@ -472,6 +473,19 @@
       public void setProperty(String key, Object token)
       {
           Object o = this.get(key);
  +
  +        /*
  +         *  $$$ GMJ
  +         *  FIXME : post 1.0 release, we need to not assume
  +         *  that a scalar is a String - it can be an Object
  +         *  so we should make a little vector-like class
  +         *  say, Foo that wraps (not extends Vector),
  +         *  so we can do things like
  +         *  if ( !( o instanceof Foo) )
  +         *  so we know it's our 'vector' container
  +         *
  +         *  This applies throughout
  +         */
           
           if (o instanceof String)
           {
  @@ -508,7 +522,13 @@
                   while (tokenizer.hasMoreTokens())
                   {
                       String value = tokenizer.nextToken();
  -                    setProperty(key,value);
  +                    
  +                    /*
  +                     * we know this is a string, so make sure it
  +                     * just goes in rather than risking vectorization
  +                     * if it contains an escaped comma
  +                     */
  +                    setStringProperty(key,value);
                   }
               }
               else
  @@ -537,6 +557,61 @@
                    */
                   put(key, token);
               }                
  +        }
  +    }
  +
  +
  +    /**
  +     *  Sets a string property w/o checking for commas - used
  +     *  internally when a property has been broken up into
  +     *  strings that could contain escaped commas to prevent
  +     *  the inadvertant vectorization.
  +     *
  +     *  Thanks to Leon Messerschmidt for this one.
  +     *
  +     */
  +    private  void setStringProperty(String key, String token)
  +    {
  +        Object o = this.get(key);
  +
  +        /*
  +         *  $$$ GMJ
  +         *  FIXME : post 1.0 release, we need to not assume
  +         *  that a scalar is a String - it can be an Object
  +         *  so we should make a little vector-like class
  +         *  say, Foo that wraps (not extends Vector),
  +         *  so we can do things like
  +         *  if ( !( o instanceof Foo) )
  +         *  so we know it's our 'vector' container
  +         *
  +         *  This applies throughout
  +         */
  +
  +        /*
  +         *  do the usual thing - if we have a value and 
  +         *  it's scalar, make a vector, otherwise add
  +         *  to the vector
  +         */
  + 
  +        if (o instanceof String)
  +        {
  +            Vector v = new Vector(2);
  +            v.addElement(o);
  +            v.addElement(token);
  +            put(key, v);
  +        }
  +        else if (o instanceof Vector)
  +        {
  +            ((Vector) o).addElement(token);
  +        }
  +        else
  +        {
  +            if( !containsKey( key ) )
  +            {
  +                keysAsListed.add(key);
  +            }
  +
  +            put( key, token);
           }
       }
   
  
  
  

Mime
View raw message