diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/image/Image.java b/src/main/org/apache/tools/ant/taskdefs/optional/image/Image.java
index a28bf6277..866c1ab95 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/image/Image.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/image/Image.java
@@ -37,15 +37,14 @@ import java.util.Iterator;
import java.util.Vector;
/**
- * A MatchingTask which relies on
- * JAI (Java Advanced Imaging)
- * to perform image manipulation operations on existing images. The
- * operations are represented as ImageOperation DataType objects.
- * The operations are arranged to conform to the Chaining Model
- * of JAI.
- * Check out the
- *
- * JAI Programming Guide
+ * A MatchingTask which relies on JAI (Java
+ * Advanced Imaging) to perform image manipulation operations on
+ * existing images. The operations are represented as ImageOperation
+ * DataType objects. The operations are arranged to conform to the
+ * Chaining Model of JAI. Check out the
+ * JAI Programming Guide
*
* @see org.apache.tools.ant.types.optional.image.ImageOperation
* @see org.apache.tools.ant.types.DataType
@@ -85,9 +84,9 @@ public class Image extends MatchingTask {
}
/**
- * Set the image encoding type.
- *
- * See this table in the JAI Programming Guide.
+ * Set the image encoding type.
+ * See this table in the JAI Programming Guide.
*/
public void setEncoding(String encoding) {
str_encoding = encoding;
@@ -101,7 +100,8 @@ public class Image extends MatchingTask {
}
/**
- * Enables Garbage Collection after each image processed. Defaults to false.
+ * Enables Garbage Collection after each image processed.
+ * Defaults to false.
*/
public void setGc(boolean gc) {
garbage_collect = gc;
@@ -166,7 +166,8 @@ public class Image extends MatchingTask {
for (int i = 0; i < instructions.size(); i++) {
Object instr = instructions.elementAt(i);
if (instr instanceof TransformOperation) {
- image = ((TransformOperation) instr).executeTransformOperation(image);
+ image = ((TransformOperation) instr)
+ .executeTransformOperation(image);
} else {
log("Not a TransformOperation: " + instr);
}
@@ -183,7 +184,8 @@ public class Image extends MatchingTask {
destDir = srcDir;
}
- File new_file = new File(destDir.getAbsolutePath() + File.separator + file.getName());
+ File new_file = new File(destDir.getAbsolutePath()
+ + File.separator + file.getName());
if ((overwrite && new_file.exists()) && (!new_file.equals(file))) {
new_file.delete();
@@ -191,7 +193,8 @@ public class Image extends MatchingTask {
FileOutputStream stream = new FileOutputStream(new_file);
- JAI.create("encode", image, stream, str_encoding.toUpperCase(), null);
+ JAI.create("encode", image, stream, str_encoding.toUpperCase(),
+ null);
stream.flush();
stream.close();
@@ -231,7 +234,8 @@ public class Image extends MatchingTask {
files = ds.getIncludedFiles();
for (int i = 0; i < files.length; i++) {
- filesList.add(new File(srcDir.getAbsolutePath() + File.separator + files[i]));
+ filesList.add(new File(srcDir.getAbsolutePath()
+ + File.separator + files[i]));
}
}
// deal with the filesets
@@ -241,7 +245,8 @@ public class Image extends MatchingTask {
files = ds.getIncludedFiles();
File fromDir = fs.getDir(getProject());
for (int j = 0; j < files.length; j++) {
- filesList.add(new File(fromDir.getAbsolutePath() + File.separator + files[j]));
+ filesList.add(new File(fromDir.getAbsolutePath()
+ + File.separator + files[j]));
}
}
@@ -251,7 +256,7 @@ public class Image extends MatchingTask {
for (Iterator i = filesList.iterator(); i.hasNext();) {
File f = (File) i.next();
File new_file = new File(destDir.getAbsolutePath()
- + File.separator + f.getName());
+ + File.separator + f.getName());
if (new_file.exists()) {
filesToRemove.add(f);
}
@@ -286,14 +291,12 @@ public class Image extends MatchingTask {
protected void validateAttributes() throws BuildException {
if (srcDir == null && filesets.size() == 0) {
throw new BuildException("Specify at least one source "
- + "- a srcDir or a fileset.");
+ + "- a srcDir or a fileset.");
}
if (srcDir == null && destDir == null) {
throw new BuildException("Specify the destDir, or the srcDir.");
}
-
-
}
}
diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/image/ImageTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/image/ImageTest.java
index 4ec96cf0b..32dd6610e 100644
--- a/src/testcases/org/apache/tools/ant/taskdefs/optional/image/ImageTest.java
+++ b/src/testcases/org/apache/tools/ant/taskdefs/optional/image/ImageTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2004 The Apache Software Foundation
+ * Copyright 2002-2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,7 +36,8 @@ import java.util.Properties;
*/
public class ImageTest extends BuildFileTest {
- private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/image/";
+ private final static String TASKDEFS_DIR =
+ "src/etc/testcases/taskdefs/optional/image/";
private final static String LARGEIMAGE = "largeimage.jpg";
public ImageTest(String name) {
@@ -58,58 +59,65 @@ public class ImageTest extends BuildFileTest {
}
public void testSimpleScale(){
- expectLogContaining("testSimpleScale", "Processing File");
- File f = createRelativeFile( "/dest/" + LARGEIMAGE );
- assertTrue(
- "Did not create "+f.getAbsolutePath(),
- f.exists() );
+ expectLogContaining("testSimpleScale", "Processing File");
+ File f = createRelativeFile("/dest/" + LARGEIMAGE);
+ assertTrue(
+ "Did not create "+f.getAbsolutePath(),
+ f.exists());
}
public void testOverwriteTrue() {
- expectLogContaining("testSimpleScale", "Processing File");
- File f = createRelativeFile( "/dest/" + LARGEIMAGE );
- long lastModified = f.lastModified();
- if (Os.isFamily("dos")) {
- try {
- Thread.sleep(2000);
- }
- catch (InterruptedException e) {}
- }
- expectLogContaining("testOverwriteTrue", "Processing File");
- f = createRelativeFile( "/dest/" + LARGEIMAGE );
- long overwrittenLastModified = f.lastModified();
- assertTrue("File was not overwritten.",lastModified < overwrittenLastModified);
+ expectLogContaining("testSimpleScale", "Processing File");
+ File f = createRelativeFile("/dest/" + LARGEIMAGE);
+ long lastModified = f.lastModified();
+ if (Os.isFamily("dos")) {
+ try {
+ Thread.sleep(2000);
+ }
+ catch (InterruptedException e) {}
+ }
+ expectLogContaining("testOverwriteTrue", "Processing File");
+ f = createRelativeFile("/dest/" + LARGEIMAGE);
+ long overwrittenLastModified = f.lastModified();
+ assertTrue("File was not overwritten.",
+ lastModified < overwrittenLastModified);
}
public void testOverwriteFalse() {
- expectLogContaining("testSimpleScale", "Processing File");
- File f = createRelativeFile( "/dest/" + LARGEIMAGE );
- long lastModified = f.lastModified();
- expectLogContaining("testOverwriteFalse", "Processing File");
- f = createRelativeFile( "/dest/" + LARGEIMAGE );
- long overwrittenLastModified = f.lastModified();
- assertTrue("File was overwritten.",lastModified == overwrittenLastModified);
+ expectLogContaining("testSimpleScale", "Processing File");
+ File f = createRelativeFile("/dest/" + LARGEIMAGE);
+ long lastModified = f.lastModified();
+ expectLogContaining("testOverwriteFalse", "Processing File");
+ f = createRelativeFile("/dest/" + LARGEIMAGE);
+ long overwrittenLastModified = f.lastModified();
+ assertTrue("File was overwritten.",
+ lastModified == overwrittenLastModified);
}
public void off_testFailOnError() {
- try {
- expectLogContaining("testFailOnError", "Unable to process image stream");
- }
- catch (RuntimeException re){
- assertTrue("Run time exception should say 'Unable to process image stream'. :" + re.toString(),re.toString().indexOf("Unable to process image stream") > -1);
- }
+ try {
+ expectLogContaining("testFailOnError",
+ "Unable to process image stream");
+ }
+ catch (RuntimeException re){
+ assertTrue("Run time exception should say "
+ + "'Unable to process image stream'. :"
+ + re.toString(),
+ re.toString()
+ .indexOf("Unable to process image stream") > -1);
+ }
}
- protected File createRelativeFile( String filename ) {
- if (filename.equals( "." )) {
+ protected File createRelativeFile(String filename) {
+ if (filename.equals(".")) {
return getProjectDir();
}
// else
- return new File( getProjectDir(), filename );
+ return new File(getProjectDir(), filename);
}
}