Browse Source

checkstyle

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@487797 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 18 years ago
parent
commit
9b1453cb6f
1 changed files with 20 additions and 7 deletions
  1. +20
    -7
      src/main/org/apache/tools/ant/taskdefs/condition/HasFreeSpace.java

+ 20
- 7
src/main/org/apache/tools/ant/taskdefs/condition/HasFreeSpace.java View File

@@ -27,7 +27,7 @@ import org.apache.tools.ant.util.StringUtils;
/**
* <hasfreespace>
* <p>Condition returns true if selected partition
* <p>Condition returns true if selected partition
* has the requested space, false otherwise.</p>
* @since Ant 1.7
*/
@@ -36,6 +36,11 @@ public class HasFreeSpace implements Condition {
private String partition;
private String needed;
/**
* Evaluate the condition.
* @return true if there enough free space.
* @throws BuildException if there is a problem.
*/
public boolean eval() throws BuildException {
validate();
try {
@@ -43,7 +48,7 @@ public class HasFreeSpace implements Condition {
//reflection to avoid bootstrap/build problems
File fs = new File(partition);
ReflectWrapper w = new ReflectWrapper(fs);
long free = ((Long)w.invoke("getFreeSpace")).longValue();
long free = ((Long) w.invoke("getFreeSpace")).longValue();
return free >= StringUtils.parseHumanSizes(needed);
} else {
throw new BuildException("HasFreeSpace condition not supported on Java5 or less.");
@@ -54,22 +59,26 @@ public class HasFreeSpace implements Condition {
}
private void validate() throws BuildException {
if(null == partition) {
if (null == partition) {
throw new BuildException("Please set the partition attribute.");
}
if(null == needed) {
if (null == needed) {
throw new BuildException("Please set the needed attribute.");
}
}
/**
* The partition/device to check
* @return
* @return the partition.
*/
public String getPartition() {
return partition;
}
/**
* Set the partition name.
* @param partition the name to use.
*/
public void setPartition(String partition) {
this.partition = partition;
}
@@ -82,7 +91,11 @@ public class HasFreeSpace implements Condition {
return needed;
}
/**
* Set the amount of space required.
* @param needed the amount required.
*/
public void setNeeded(String needed) {
this.needed = needed;
}
}
}

Loading…
Cancel
Save