Browse Source

checkstyle: reduce method length

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@491046 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 18 years ago
parent
commit
94e18bdaaa
1 changed files with 51 additions and 41 deletions
  1. +51
    -41
      src/main/org/apache/tools/ant/taskdefs/Copy.java

+ 51
- 41
src/main/org/apache/tools/ant/taskdefs/Copy.java View File

@@ -397,30 +397,8 @@ public class Copy extends Task {

try {
// deal with the single file
if (file != null) {
if (file.exists()) {
if (destFile == null) {
destFile = new File(destDir, file.getName());
}
if (forceOverwrite || !destFile.exists()
|| (file.lastModified() - granularity
> destFile.lastModified())) {
fileCopyMap.put(file.getAbsolutePath(),
new String[] {destFile.getAbsolutePath()});
} else {
log(file + " omitted as " + destFile
+ " is up to date.", Project.MSG_VERBOSE);
}
} else {
String message = "Warning: Could not find file "
+ file.getAbsolutePath() + " to copy.";
if (!failonerror) {
log(message, Project.MSG_ERR);
} else {
throw new BuildException(message);
}
}
}
copySingleFile();

// deal with the ResourceCollections

/* for historical and performance reasons we have to do
@@ -511,23 +489,7 @@ public class Copy extends Task {
}
}

Iterator iter = baseDirs.iterator();
while (iter.hasNext()) {
File f = (File) iter.next();
List files = (List) filesByBasedir.get(f);
List dirs = (List) dirsByBasedir.get(f);

String[] srcFiles = new String[0];
if (files != null) {
srcFiles = (String[]) files.toArray(srcFiles);
}
String[] srcDirs = new String[0];
if (dirs != null) {
srcDirs = (String[]) dirs.toArray(srcDirs);
}
scan(f == NULL_FILE_PLACEHOLDER ? null : f, destDir, srcFiles,
srcDirs);
}
iterateOverBaseDirs(baseDirs, dirsByBasedir, filesByBasedir);

// do all the copy operations now...
try {
@@ -574,6 +536,54 @@ public class Copy extends Task {
** protected and private methods
************************************************************************/

private void copySingleFile() {
// deal with the single file
if (file != null) {
if (file.exists()) {
if (destFile == null) {
destFile = new File(destDir, file.getName());
}
if (forceOverwrite || !destFile.exists()
|| (file.lastModified() - granularity
> destFile.lastModified())) {
fileCopyMap.put(file.getAbsolutePath(),
new String[] {destFile.getAbsolutePath()});
} else {
log(file + " omitted as " + destFile
+ " is up to date.", Project.MSG_VERBOSE);
}
} else {
String message = "Warning: Could not find file "
+ file.getAbsolutePath() + " to copy.";
if (!failonerror) {
log(message, Project.MSG_ERR);
} else {
throw new BuildException(message);
}
}
}
}
private void iterateOverBaseDirs(
HashSet baseDirs, HashMap dirsByBasedir, HashMap filesByBasedir) {
Iterator iter = baseDirs.iterator();
while (iter.hasNext()) {
File f = (File) iter.next();
List files = (List) filesByBasedir.get(f);
List dirs = (List) dirsByBasedir.get(f);

String[] srcFiles = new String[0];
if (files != null) {
srcFiles = (String[]) files.toArray(srcFiles);
}
String[] srcDirs = new String[0];
if (dirs != null) {
srcDirs = (String[]) dirs.toArray(srcDirs);
}
scan(f == NULL_FILE_PLACEHOLDER ? null : f, destDir, srcFiles,
srcDirs);
}
}

/**
* Ensure we have a consistent and legal set of attributes, and set
* any internal flags necessary based on different combinations


Loading…
Cancel
Save