ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From k...@apache.org
Subject svn commit: r486161 - /ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/HasFreeSpace.java
Date Tue, 12 Dec 2006 14:24:51 GMT
Author: kevj
Date: Tue Dec 12 06:24:51 2006
New Revision: 486161

URL: http://svn.apache.org/viewvc?view=rev&rev=486161
Log:
-fix tabs, add validate method

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/HasFreeSpace.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/HasFreeSpace.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/HasFreeSpace.java?view=diff&rev=486161&r1=486160&r2=486161
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/HasFreeSpace.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/HasFreeSpace.java Tue
Dec 12 06:24:51 2006
@@ -31,46 +31,56 @@
  */
 public class HasFreeSpace implements Condition {
 
-	private String partition;
-	private String needed;
-	
-	public boolean eval() throws BuildException {
-		try {
-			if (JavaEnvUtils.isAtLeastJavaVersion("1.6")) {
-				//reflection to avoid bootstrap/build problems
-				String j6FileUtils = "org.apache.tools.ant.util.java16.Java6FileUtils";
-				ReflectWrapper w = new ReflectWrapper(getClass().getClassLoader(), j6FileUtils);
-				long free = ((Long)w.invoke("freeSpace", String.class, partition)).longValue();
-				return free >= StringUtils.parseHumanSizes(needed);
-			} else {
-				throw new BuildException("HasFreeSpace condition not supported on Java5 or less.");
-			}
-		} catch (Exception e) {
-			throw new BuildException(e);
-		}
-	}
+    private String partition;
+    private String needed;
 
-	/**
-	 * The partition/device to check
-	 * @return
-	 */
-	public String getPartition() {
-		return partition;
-	}
+    public boolean eval() throws BuildException {
+        validate();
+        try {
+            if (JavaEnvUtils.isAtLeastJavaVersion("1.6")) {
+                //reflection to avoid bootstrap/build problems
+                String j6FileUtils = "org.apache.tools.ant.util.java16.Java6FileUtils";
+                ReflectWrapper w = new ReflectWrapper(getClass().getClassLoader(), j6FileUtils);
+                long free = ((Long)w.invoke("freeSpace", String.class, partition)).longValue();
+                return free >= StringUtils.parseHumanSizes(needed);
+            } else {
+                throw new BuildException("HasFreeSpace condition not supported on Java5 or
less.");
+            }
+        } catch (Exception e) {
+            throw new BuildException(e);
+        }
+    }
 
-	public void setPartition(String partition) {
-		this.partition = partition;
-	}
+    private void validate() throws BuildException {
+        if(null == partition) {
+            throw new BuildException("Please set the partition attribute.");
+        }
+        if(null == needed) {
+            throw new BuildException("Please set the needed attribute.");
+        }
+    }
+    
+    /**
+     * The partition/device to check
+     * @return
+     */
+    public String getPartition() {
+        return partition;
+    }
 
-	/**
-	 * The amount of free space required
-	 * @return the amount required
-	 */
-	public String getNeeded() {
-		return needed;
-	}
+    public void setPartition(String partition) {
+        this.partition = partition;
+    }
 
-	public void setNeeded(String needed) {
-		this.needed = needed;
-	}
+    /**
+     * The amount of free space required
+     * @return the amount required
+     */
+    public String getNeeded() {
+        return needed;
+    }
+
+    public void setNeeded(String needed) {
+        this.needed = needed;
+    }
 }



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


Mime
View raw message