forrest-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nicola...@apache.org
Subject cvs commit: xml-forrest/src/java/org/apache/cocoon/components/modules/input AntPropertiesModule.java
Date Tue, 27 Jan 2004 14:03:38 GMT
nicolaken    2004/01/27 06:03:38

  Modified:    src/java/org/apache/cocoon/components/modules/input
                        AntPropertiesModule.java
  Log:
  Do not override properties, as Ant does, and do not pass by erroneous
  lines without '='
  
  Revision  Changes    Path
  1.2       +9 -14     xml-forrest/src/java/org/apache/cocoon/components/modules/input/AntPropertiesModule.java
  
  Index: AntPropertiesModule.java
  ===================================================================
  RCS file: /home/cvs/xml-forrest/src/java/org/apache/cocoon/components/modules/input/AntPropertiesModule.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AntPropertiesModule.java	26 Jan 2004 18:34:53 -0000	1.1
  +++ AntPropertiesModule.java	27 Jan 2004 14:03:38 -0000	1.2
  @@ -106,7 +106,7 @@
           load(file);
       }
       
  -    private void load(String file) throws ConfigurationException {
  +    protected void load(String file) throws ConfigurationException {
           Source source = null;
           BufferedReader in = null;
           try {
  @@ -120,27 +120,22 @@
               Enumeration names;
                
               while((currentLine = in.readLine()) != null) {
  -                
  +                // # == comment
                   if(!currentLine.startsWith("#")){ 
  -                    
  -                    splitIndex =  currentLine.indexOf('=');  
  -                    
  -                    if(splitIndex != -1 ) {
  -                            
  -                        name = currentLine.substring(0, splitIndex).trim() ;
  -                        value = currentLine.substring(splitIndex+1).trim() ;
  -                       
  +                    splitIndex =  currentLine.indexOf('='); 
  +                    name = currentLine.substring(0, splitIndex).trim();
  +                    //if the property is already there don't overwrite, as in Ant
  +                    //properties defined first take precedence
  +                    if(!m_properties.containsKey(name)){
  +                        value = currentLine.substring(splitIndex+1).trim();
                           names = m_properties.propertyNames();
  -                        
                           while( names.hasMoreElements() ) {
                               String currentName = (String) names.nextElement();
                               String valueToSearchFor = "${"+currentName+"}";
                               String valueToReplaceWith = (String) m_properties.get(currentName);
                               value = StringUtils.replace(value, valueToSearchFor, valueToReplaceWith);
                           }
  -                            
  -                        m_properties.put(name,value);
  -                    }   
  +                    }    
                   }    
               }
           }
  
  
  

Mime
View raw message