commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mpoes...@apache.org
Subject cvs commit: jakarta-commons-sandbox/configuration/src/java/org/apache/commons/configuration BaseConfiguration.java ConfigurationConverter.java PropertiesConfiguration.java
Date Wed, 17 Jul 2002 17:36:43 GMT
mpoeschl    2002/07/17 10:36:43

  Modified:    configuration/src/java/org/apache/commons/configuration
                        BaseConfiguration.java ConfigurationConverter.java
                        PropertiesConfiguration.java
  Log:
  - code formatting
  - javadocs
  
  Revision  Changes    Path
  1.2       +29 -37    jakarta-commons-sandbox/configuration/src/java/org/apache/commons/configuration/BaseConfiguration.java
  
  Index: BaseConfiguration.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/configuration/src/java/org/apache/commons/configuration/BaseConfiguration.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BaseConfiguration.java	16 Apr 2002 19:05:24 -0000	1.1
  +++ BaseConfiguration.java	17 Jul 2002 17:36:43 -0000	1.2
  @@ -85,10 +85,10 @@
    */
   public class BaseConfiguration implements Configuration
   {
  -    /* stores the configuration key-value pairs */
  +    /** stores the configuration key-value pairs */
       private Hashtable store = new Hashtable();
   
  -    /* stores the configuration key-value pairs */
  +    /** stores the configuration key-value pairs */
       protected Configuration defaults = null;
   
       /**
  @@ -115,8 +115,8 @@
        *
        * ["file", "classpath"]
        *
  -     * @param String key
  -     * @param String value
  +     * @param key
  +     * @param token
        */
       public void addProperty(String key, Object token)
       {
  @@ -158,10 +158,10 @@
                * parse multiple same key values.
                */
               if (token instanceof String &&
  -                ((String)token).indexOf(PropertiesTokenizer.DELIMITER) > 0)
  +                ((String) token).indexOf(PropertiesTokenizer.DELIMITER) > 0)
               {
                   PropertiesTokenizer tokenizer =
  -                    new PropertiesTokenizer((String)token);
  +                    new PropertiesTokenizer((String) token);
   
                   while (tokenizer.hasMoreTokens())
                   {
  @@ -199,7 +199,7 @@
       protected void addPropertyDirect(String key, Object obj)
       {
           // safety check
  -        if(! store.containsKey(key))
  +        if (!store.containsKey(key))
           {
               keysAsListed.add(key);
           }
  @@ -268,8 +268,8 @@
           StringBuffer result = new StringBuffer();
   
           // FIXME: we should probably allow the escaping of the start token
  -        while ( ((begin = base.indexOf(START_TOKEN, prec + END_TOKEN.length())) >-1)
  -                && ((end = base.indexOf(END_TOKEN, begin)) > -1) )
  +        while (((begin = base.indexOf(START_TOKEN, prec + END_TOKEN.length())) > -1)
  +                && ((end = base.indexOf(END_TOKEN, begin)) > -1))
           {
               result.append(base.substring(prec + END_TOKEN.length(), begin));
               variable = base.substring(begin + START_TOKEN.length(), end);
  @@ -301,13 +301,13 @@
        * <code>false</code> boolean values.  Case of value to test for
        * boolean status is ignored.
        *
  -     * @param String The value to test for boolean state.
  +     * @param value The value to test for boolean state.
        * @return <code>true</code> or <code>false</code> if the supplied
        * text maps to a boolean value, or <code>null</code> otherwise.
        */
       public String testBoolean(String value)
       {
  -        String s = ((String)value).toLowerCase();
  +        String s = ((String) value).toLowerCase();
   
           if (s.equals("true") || s.equals("on") || s.equals("yes"))
           {
  @@ -328,7 +328,7 @@
        * of this one. Take into account duplicate keys
        * by using the setProperty() in ExtendedProperties.
        *
  -     * @param String prefix
  +     * @param prefix
        */
       public Configuration subset(String prefix)
       {
  @@ -336,11 +336,11 @@
           Iterator keys = this.getKeys();
           boolean validSubset = false;
   
  -        while( keys.hasNext() )
  +        while (keys.hasNext())
           {
               Object key = keys.next();
   
  -            if( key instanceof String && ((String) key).startsWith(prefix) )
  +            if (key instanceof String && ((String) key).startsWith(prefix))
               {
                   if (!validSubset)
                   {
  @@ -354,13 +354,13 @@
                    * there is only a single property with the key prefix. This is
                    * not a useful subset but it is a valid subset.
                    */
  -                if ( ((String)key).length() == prefix.length())
  +                if (((String) key).length() == prefix.length())
                   {
                       newKey = prefix;
                   }
                   else
                   {
  -                    newKey = ((String)key).substring(prefix.length() + 1);
  +                    newKey = ((String) key).substring(prefix.length() + 1);
                   }
   
                   /*
  @@ -370,7 +370,7 @@
                   Object value = store.get(key);
                   if (value instanceof String)
                   {
  -                    c.addPropertyDirect(newKey,interpolate((String)value));
  +                    c.addPropertyDirect(newKey, interpolate((String) value));
                   }
                   else
                   {
  @@ -410,19 +410,19 @@
        * set values. Set values is implicitly a call
        * to clearProperty(key), addProperty(key,value).
        *
  -     * @param String key
  -     * @param String value
  +     * @param key
  +     * @param value
        */
       public void setProperty(String key, Object value)
       {
           clearProperty(key);
  -        addProperty(key,value);
  +        addProperty(key, value);
       }
   
       /**
        * Clear a property in the configuration.
        *
  -     * @param String key to remove along with corresponding value.
  +     * @param key the key to remove along with corresponding value.
        */
       public void clearProperty(String key)
       {
  @@ -432,9 +432,9 @@
                * we also need to rebuild the keysAsListed or else things get
                * *very* confusing
                */
  -            for(int i = 0; i < keysAsListed.size(); i++)
  +            for (int i = 0; i < keysAsListed.size(); i++)
               {
  -                if ( ( (String) keysAsListed.get(i)).equals( key ) )
  +                if (((String) keysAsListed.get(i)).equals(key))
                   {
                       keysAsListed.remove(i);
                       break;
  @@ -467,11 +467,11 @@
           Iterator keys = getKeys();
           ArrayList matchingKeys = new ArrayList();
   
  -        while( keys.hasNext() )
  +        while (keys.hasNext())
           {
               Object key = keys.next();
   
  -            if( key instanceof String && ((String) key).startsWith(prefix) )
  +            if (key instanceof String && ((String) key).startsWith(prefix))
               {
                   matchingKeys.add(key);
               }
  @@ -529,9 +529,8 @@
               }
               else
               {
  -                throw new IllegalArgumentException('\'' + token +
  -                                                   "' does not contain " +
  -                                                   "an equals sign");
  +                throw new IllegalArgumentException('\'' + token
  +                        + "' does not contain an equals sign");
               }
           }
           return props;
  @@ -549,7 +548,7 @@
           // first, try to get from the 'user value' store
           Object o = store.get(key);
   
  -        if ( o == null)
  +        if (o == null)
           {
               // if there isn't a value there, get it from the defaults if we have
               // them
  @@ -1271,11 +1270,6 @@
           return tokens;
       }
   
  -
  -
  -
  -
  -
       /**
        * Get a Vector of strings associated with the given configuration key.
        *
  @@ -1332,7 +1326,6 @@
           }
       }
   
  -
       /**
        * This class divides into tokens a property value.  Token
        * separator is "," but commas into the property value are escaped
  @@ -1392,5 +1385,4 @@
               return buffer.toString().trim();
           }
       } // class PropertiesTokenizer
  -
   }
  
  
  
  1.2       +5 -5      jakarta-commons-sandbox/configuration/src/java/org/apache/commons/configuration/ConfigurationConverter.java
  
  Index: ConfigurationConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/configuration/src/java/org/apache/commons/configuration/ConfigurationConverter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ConfigurationConverter.java	16 Apr 2002 19:05:24 -0000	1.1
  +++ ConfigurationConverter.java	17 Jul 2002 17:36:43 -0000	1.2
  @@ -113,7 +113,7 @@
       public static ExtendedProperties getExtendedProperties(Configuration c)
       {
           ExtendedProperties props = new ExtendedProperties();
  -        for (Iterator i = c.getKeys() ; i.hasNext() ;)
  +        for (Iterator i = c.getKeys() ; i.hasNext() ; )
           {
               String key = (String) i.next();
               props.setProperty(key, c.getProperty(key));
  @@ -128,16 +128,16 @@
        * @param c Configuration object to convert
        * @return Properties created from the Configuration
        */
  -    public static Properties getProperties( Configuration c )
  +    public static Properties getProperties(Configuration c)
       {
           Properties props = new Properties();
   
           Iterator iter = c.getKeys();
   
  -        while ( iter.hasNext() )
  +        while (iter.hasNext())
           {
               String key = (String) iter.next();
  -            props.setProperty( key, c.getString( key ) );
  +            props.setProperty(key, c.getString(key));
           }
   
           return props;
  
  
  
  1.2       +4 -5      jakarta-commons-sandbox/configuration/src/java/org/apache/commons/configuration/PropertiesConfiguration.java
  
  Index: PropertiesConfiguration.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/configuration/src/java/org/apache/commons/configuration/PropertiesConfiguration.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PropertiesConfiguration.java	16 Apr 2002 19:05:25 -0000	1.1
  +++ PropertiesConfiguration.java	17 Jul 2002 17:36:43 -0000	1.2
  @@ -63,13 +63,10 @@
   import java.io.Reader;
   import java.io.UnsupportedEncodingException;
   
  -// Borrow a lot of the code from ExtendedProperties, but leave
  -// the resource handling to the resources package.
  -
   /**
    * loads the configuration from a properties file. <p>
    *
  - * <p>The Extended Properties syntax is explained here:
  + * <p>The properties file syntax is explained here:
    *
    * <ul>
    *  <li>
  @@ -292,7 +289,9 @@
                        * ignore them.
                        */
                       if ("".equals(value))
  +                    {
                           continue;
  +                    }
   
                       if (getInclude() != null &&
                           key.equalsIgnoreCase(getInclude()))
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message