commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject cvs commit: jakarta-commons/configuration/src/java/org/apache/commons/configuration HierarchicalConfiguration.java
Date Sat, 13 Nov 2004 17:02:51 GMT
oheger      2004/11/13 09:02:51

  Modified:    configuration/src/java/org/apache/commons/configuration
                        HierarchicalConfiguration.java
  Log:
  Fix for Bug 31745
  
  Revision  Changes    Path
  1.13      +36 -2     jakarta-commons/configuration/src/java/org/apache/commons/configuration/HierarchicalConfiguration.java
  
  Index: HierarchicalConfiguration.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/HierarchicalConfiguration.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- HierarchicalConfiguration.java	18 Oct 2004 10:19:26 -0000	1.12
  +++ HierarchicalConfiguration.java	13 Nov 2004 17:02:51 -0000	1.13
  @@ -387,7 +387,7 @@
        */
       public Iterator getKeys(String prefix)
       {
  -        DefinedKeysVisitor visitor = new DefinedKeysVisitor();
  +        DefinedKeysVisitor visitor = new DefinedKeysVisitor(prefix);
           List nodes = fetchNodeList(prefix);
           ConfigurationKey key = new ConfigurationKey();
           
  @@ -990,6 +990,9 @@
       {
           /** Stores the list to be filled.*/
           private Set keyList;
  +        
  +        /** Stores a prefix for the keys.*/
  +        private String prefix;
   
           /**
            * Default constructor.
  @@ -998,6 +1001,18 @@
           {
               keyList = new HashSet();
           }
  +        
  +        /**
  +         * Creates a new <code>DefinedKeysVisitor</code> instance and sets
the
  +         * prefix for the keys to fetch.
  +         * 
  +         * @param prefix the prefix
  +         */
  +        public DefinedKeysVisitor(String prefix)
  +        {
  +            this();
  +            this.prefix = prefix;
  +        }
   
           /**
            * Returns the list with all defined keys.
  @@ -1020,7 +1035,26 @@
           {
               if (node.getValue() != null && key != null)
               {
  +                addKey(key);
  +            }
  +        }
  +        
  +        /**
  +         * Adds the specified key to the internal list.
  +         * 
  +         * @param key the key to add
  +         */
  +        protected void addKey(ConfigurationKey key)
  +        {
  +            if(prefix == null)
  +            {
                   keyList.add(key.toString());
  +            }
  +            else
  +            {
  +                StringBuffer buf = new StringBuffer(prefix);
  +                buf.append('.').append(key);
  +                keyList.add(buf.toString());
               }
           }
       }
  
  
  

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


Mime
View raw message