ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From umag...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Property.java
Date Fri, 28 Dec 2001 21:45:29 GMT
umagesh     01/12/28 13:45:29

  Modified:    src/main/org/apache/tools/ant/taskdefs Property.java
  Log:
  setFile(File) deprecated and replaced with setFile(DestFile).
  
  DestFile is used in this case eventhough SrcFile would make more sense
  because currently, <property> does not throw an exception if the file
  is not found - it just logs a message.  If SrcFile were used, it would have
  thrown an exception if the file was not found thereby being backwards
  incompatible.
  
  <property> was not checking to see if the supplied file was a directory.
  It used to throw a java.io.FileNotFoundException previously.  Now it
  prints a message saying that it is not a file.
  
  Revision  Changes    Path
  1.39      +38 -25    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Property.java
  
  Index: Property.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Property.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- Property.java	12 Dec 2001 09:17:36 -0000	1.38
  +++ Property.java	28 Dec 2001 21:45:29 -0000	1.39
  @@ -59,6 +59,7 @@
   import org.apache.tools.ant.Project;
   import org.apache.tools.ant.AntClassLoader;
   import org.apache.tools.ant.ProjectHelper;
  +import org.apache.tools.ant.types.DestFile;
   import org.apache.tools.ant.types.Path;
   import org.apache.tools.ant.types.Reference;
   import java.io.File;
  @@ -88,15 +89,15 @@
       protected Reference ref;
   
       protected boolean userProperty; // set read-only properties
  -    
  +
       public Property() {
           super();
       }
  -    
  +
       protected Property(boolean userProperty) {
           this.userProperty = userProperty;
       }
  -    
  +
       public void setName(String name) {
           this.name = name;
       }
  @@ -117,8 +118,20 @@
           return value;
       }
   
  +    /**
  +     * @deprecated setFile(File) is deprecated and is replaced with
  +     *             setFile(DestFile) to let Ant's core perform validation
  +     */
       public void setFile(File file) {
  -        this.file = file;
  +        log("DEPRECATED - The setFile(File) method has been deprecated."
  +            + " Use setFile(DestFile) instead.");
  +        DestFile destFile = new DestFile();
  +        destFile.setFile(file);
  +        setFile(destFile);
  +    }
  +
  +    public void setFile(DestFile file) {
  +        this.file = file.getFile();
       }
   
       public File getFile() {
  @@ -156,14 +169,14 @@
               this.classpath.append(classpath);
           }
       }
  -    
  +
       public Path createClasspath() {
           if (this.classpath == null) {
               this.classpath = new Path(project);
           }
           return this.classpath.createPath();
       }
  -    
  +
       public void setClasspathRef(Reference r) {
           createClasspath().setRefid(r);
       }
  @@ -172,7 +185,7 @@
        * @deprecated This was never a supported feature and has been deprecated without replacement
        */
       public void setUserProperty(boolean userProperty) {
  -        log("DEPRECATED: Ignoring request to set user property in Property task.", 
  +        log("DEPRECATED: Ignoring request to set user property in Property task.",
               Project.MSG_WARN);
       }
   
  @@ -196,13 +209,13 @@
           if ((name != null) && (value != null)) {
               addProperty(name, value);
           }
  -        
  +
           if (file != null) loadFile(file);
  -        
  +
           if (resource != null) loadResource(resource);
  -        
  +
           if (env != null) loadEnvironment(env);
  -        
  +
           if ((name != null) && (ref != null)) {
               Object obj = ref.getReferencedObject(getProject());
               if (obj != null) {
  @@ -215,18 +228,18 @@
           Properties props = new Properties();
           log("Loading " + file.getAbsolutePath(), Project.MSG_VERBOSE);
           try {
  -            if (file.exists()) { 
  +            if (file.exists()) {
                   FileInputStream fis = new FileInputStream(file);
  -                try { 
  +                try {
                       props.load(fis);
                   } finally {
  -                    if (fis != null) { 
  +                    if (fis != null) {
                           fis.close();
                       }
                   }
                   addProperties(props);
               } else {
  -                log("Unable to find property file: " + file.getAbsolutePath(), 
  +                log("Unable to find property file: " + file.getAbsolutePath(),
                       Project.MSG_VERBOSE);
               }
           } catch(IOException ex) {
  @@ -238,21 +251,21 @@
           Properties props = new Properties();
           log("Resource Loading " + name, Project.MSG_VERBOSE);
           try {
  -            ClassLoader cL = null; 
  +            ClassLoader cL = null;
               InputStream is = null;
   
  -            if (classpath != null) { 
  -                cL = new AntClassLoader(project, classpath); 
  -            } else { 
  -                cL = this.getClass().getClassLoader(); 
  -            } 
  +            if (classpath != null) {
  +                cL = new AntClassLoader(project, classpath);
  +            } else {
  +                cL = this.getClass().getClassLoader();
  +            }
   
               if (cL == null) {
                   is = ClassLoader.getSystemResourceAsStream(name);
               } else {
                   is = cL.getResourceAsStream(name);
               }
  -            
  +
               if (is != null) {
                   props.load(is);
                   addProperties(props);
  @@ -275,7 +288,7 @@
               if (pos == -1) {
                   log("Ignoring: " + entry, Project.MSG_WARN);
               } else {
  -                props.put(prefix + entry.substring(0, pos), 
  +                props.put(prefix + entry.substring(0, pos),
                   entry.substring(pos + 1));
               }
           }
  @@ -316,7 +329,7 @@
                   Vector fragments = new Vector();
                   Vector propertyRefs = new Vector();
                   ProjectHelper.parsePropertyString(value, fragments, propertyRefs);
  -                
  +
                   resolved = true;
                   if (propertyRefs.size() != 0) {
                       StringBuffer sb = new StringBuffer();
  @@ -347,5 +360,5 @@
                   }
               }
           }
  -    }    
  +    }
   }
  
  
  

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


Mime
View raw message