From e24825b3b81014e025f1181702cff049a41adc65 Mon Sep 17 00:00:00 2001 From: Peter Reilly Date: Wed, 27 Dec 2006 23:41:33 +0000 Subject: [PATCH] checkstyle: make the execute method a litte smaller git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@490599 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/tools/ant/taskdefs/Get.java | 39 +++++++++++-------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/Get.java b/src/main/org/apache/tools/ant/taskdefs/Get.java index 7b56fd81e..d3e522adc 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Get.java +++ b/src/main/org/apache/tools/ant/taskdefs/Get.java @@ -97,23 +97,8 @@ public class Get extends Task { */ public boolean doGet(int logLevel, DownloadProgress progress) throws IOException { - if (source == null) { - throw new BuildException("src attribute is required", getLocation()); - } - - if (dest == null) { - throw new BuildException("dest attribute is required", getLocation()); - } - - if (dest.exists() && dest.isDirectory()) { - throw new BuildException("The specified destination is a directory", - getLocation()); - } + checkAttributes(); - if (dest.exists() && !dest.canWrite()) { - throw new BuildException("Can't write to " + dest.getAbsolutePath(), - getLocation()); - } //dont do any progress, unless asked if (progress == null) { progress = new NullProgress(); @@ -258,6 +243,28 @@ public class Get extends Task { return true; } + /** + * Check the attributes. + */ + private void checkAttributes() { + if (source == null) { + throw new BuildException("src attribute is required", getLocation()); + } + + if (dest == null) { + throw new BuildException("dest attribute is required", getLocation()); + } + + if (dest.exists() && dest.isDirectory()) { + throw new BuildException("The specified destination is a directory", + getLocation()); + } + + if (dest.exists() && !dest.canWrite()) { + throw new BuildException("Can't write to " + dest.getAbsolutePath(), + getLocation()); + } + } /** * Set the URL to get.