git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274824 13f79535-47bb-0310-9956-ffa450edef68master
@@ -112,7 +112,7 @@ public class ExecuteJava implements Runnable, TimeoutObserver { | |||||
} | } | ||||
/** | /** | ||||
* @since 1.19, Ant 1.5 | |||||
* @since Ant 1.5 | |||||
*/ | */ | ||||
public void setTimeout(Long timeout) { | public void setTimeout(Long timeout) { | ||||
this.timeout = timeout; | this.timeout = timeout; | ||||
@@ -201,7 +201,7 @@ public class ExecuteJava implements Runnable, TimeoutObserver { | |||||
} | } | ||||
/** | /** | ||||
* @since 1.19, Ant 1.5 | |||||
* @since Ant 1.5 | |||||
*/ | */ | ||||
public void run() { | public void run() { | ||||
final Object[] argument = { javaCommand.getArguments() }; | final Object[] argument = { javaCommand.getArguments() }; | ||||
@@ -222,7 +222,7 @@ public class ExecuteJava implements Runnable, TimeoutObserver { | |||||
} | } | ||||
/** | /** | ||||
* @since 1.19, Ant 1.5 | |||||
* @since Ant 1.5 | |||||
*/ | */ | ||||
public synchronized void timeoutOccured(Watchdog w) { | public synchronized void timeoutOccured(Watchdog w) { | ||||
if (thread != null) { | if (thread != null) { | ||||
@@ -317,8 +317,7 @@ public class Zip extends MatchingTask { | |||||
executeMain(); | executeMain(); | ||||
skipWriting = false; | skipWriting = false; | ||||
executeMain(); | executeMain(); | ||||
} | |||||
else { | |||||
} else { | |||||
executeMain(); | executeMain(); | ||||
} | } | ||||
} | } | ||||
@@ -418,7 +417,7 @@ public class Zip extends MatchingTask { | |||||
ZipOutputStream zOut = null; | ZipOutputStream zOut = null; | ||||
try { | try { | ||||
if (! skipWriting) { | |||||
if (!skipWriting) { | |||||
zOut = new ZipOutputStream(new FileOutputStream(zipFile)); | zOut = new ZipOutputStream(new FileOutputStream(zipFile)); | ||||
zOut.setEncoding(encoding); | zOut.setEncoding(encoding); | ||||
@@ -464,8 +463,8 @@ public class Zip extends MatchingTask { | |||||
// temporary file | // temporary file | ||||
if (doUpdate) { | if (doUpdate) { | ||||
if (!renamedFile.delete()) { | if (!renamedFile.delete()) { | ||||
log ("Warning: unable to delete temporary file " + | |||||
renamedFile.getName(), Project.MSG_WARN); | |||||
log ("Warning: unable to delete temporary file " | |||||
+ renamedFile.getName(), Project.MSG_WARN); | |||||
} | } | ||||
} | } | ||||
success = true; | success = true; | ||||
@@ -504,8 +503,8 @@ public class Zip extends MatchingTask { | |||||
try { | try { | ||||
fileUtils.rename(renamedFile, zipFile); | fileUtils.rename(renamedFile, zipFile); | ||||
} catch (IOException e) { | } catch (IOException e) { | ||||
msg += " (and I couldn't rename the temporary file " + | |||||
renamedFile.getName() + " back)"; | |||||
msg += " (and I couldn't rename the temporary file " | |||||
+ renamedFile.getName() + " back)"; | |||||
} | } | ||||
} | } | ||||
@@ -593,7 +592,7 @@ public class Zip extends MatchingTask { | |||||
if ("".equals(name)) { | if ("".equals(name)) { | ||||
continue; | continue; | ||||
} | } | ||||
if (resources[i].isDirectory() && ! name.endsWith("/")) { | |||||
if (resources[i].isDirectory() && !name.endsWith("/")) { | |||||
name = name + "/"; | name = name + "/"; | ||||
} | } | ||||
@@ -665,6 +664,7 @@ public class Zip extends MatchingTask { | |||||
try { | try { | ||||
os.close(); | os.close(); | ||||
} catch (IOException e) { | } catch (IOException e) { | ||||
//ignore | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -744,8 +744,8 @@ public class Zip extends MatchingTask { | |||||
} | } | ||||
} else if (emptyBehavior.equals("fail")) { | } else if (emptyBehavior.equals("fail")) { | ||||
throw new BuildException("Cannot create " + archiveType | throw new BuildException("Cannot create " + archiveType | ||||
+ " archive " + zipFile + | |||||
": no files were included.", | |||||
+ " archive " + zipFile | |||||
+ ": no files were included.", | |||||
getLocation()); | getLocation()); | ||||
} else { | } else { | ||||
// Create. | // Create. | ||||
@@ -794,7 +794,7 @@ public class Zip extends MatchingTask { | |||||
if (filesets[i] instanceof ZipFileSet) { | if (filesets[i] instanceof ZipFileSet) { | ||||
ZipFileSet zfs = (ZipFileSet) filesets[i]; | ZipFileSet zfs = (ZipFileSet) filesets[i]; | ||||
if (zfs.getFullpath(getProject()) != null | if (zfs.getFullpath(getProject()) != null | ||||
&& !zfs.getFullpath(getProject()).equals("") ) { | |||||
&& !zfs.getFullpath(getProject()).equals("")) { | |||||
// in this case all files from origin map to | // in this case all files from origin map to | ||||
// the fullPath attribute of the zipfileset at | // the fullPath attribute of the zipfileset at | ||||
// destination | // destination | ||||
@@ -804,7 +804,7 @@ public class Zip extends MatchingTask { | |||||
} else if (zfs.getPrefix(getProject()) != null | } else if (zfs.getPrefix(getProject()) != null | ||||
&& !zfs.getPrefix(getProject()).equals("")) { | && !zfs.getPrefix(getProject()).equals("")) { | ||||
GlobPatternMapper gm=new GlobPatternMapper(); | |||||
GlobPatternMapper gm = new GlobPatternMapper(); | |||||
gm.setFrom("*"); | gm.setFrom("*"); | ||||
String prefix = zfs.getPrefix(getProject()); | String prefix = zfs.getPrefix(getProject()); | ||||
if (!prefix.endsWith("/") && !prefix.endsWith("\\")) { | if (!prefix.endsWith("/") && !prefix.endsWith("\\")) { | ||||
@@ -888,7 +888,7 @@ public class Zip extends MatchingTask { | |||||
log("adding directory " + vPath, Project.MSG_VERBOSE); | log("adding directory " + vPath, Project.MSG_VERBOSE); | ||||
addedDirs.put(vPath, vPath); | addedDirs.put(vPath, vPath); | ||||
if (! skipWriting) { | |||||
if (!skipWriting) { | |||||
ZipEntry ze = new ZipEntry (vPath); | ZipEntry ze = new ZipEntry (vPath); | ||||
if (dir != null && dir.exists()) { | if (dir != null && dir.exists()) { | ||||
// ZIPs store time with a granularity of 2 seconds, round up | // ZIPs store time with a granularity of 2 seconds, round up | ||||
@@ -943,7 +943,7 @@ public class Zip extends MatchingTask { | |||||
entries.put(vPath, vPath); | entries.put(vPath, vPath); | ||||
if (! skipWriting) { | |||||
if (!skipWriting) { | |||||
ZipEntry ze = new ZipEntry(vPath); | ZipEntry ze = new ZipEntry(vPath); | ||||
ze.setTime(lastModified); | ze.setTime(lastModified); | ||||
@@ -1123,7 +1123,7 @@ public class Zip extends MatchingTask { | |||||
* | * | ||||
* @since Ant 1.5.2 | * @since Ant 1.5.2 | ||||
*/ | */ | ||||
protected final static boolean isEmpty(Resource[][] r) { | |||||
protected static final boolean isEmpty(Resource[][] r) { | |||||
for (int i = 0; i < r.length; i++) { | for (int i = 0; i < r.length; i++) { | ||||
if (r[i].length > 0) { | if (r[i].length > 0) { | ||||
return false; | return false; | ||||
@@ -100,7 +100,7 @@ public class Path extends DataType implements Cloneable { | |||||
private Vector elements; | private Vector elements; | ||||
/** The system classspath as a Path object */ | /** The system classspath as a Path object */ | ||||
public static Path systemClasspath = | |||||
public static Path systemClasspath = | |||||
new Path(null, System.getProperty("java.class.path")); | new Path(null, System.getProperty("java.class.path")); | ||||
@@ -125,7 +125,7 @@ public class Path extends DataType implements Cloneable { | |||||
/** | /** | ||||
* Invoked by IntrospectionHelper for <code>setXXX(Path p)</code> | * Invoked by IntrospectionHelper for <code>setXXX(Path p)</code> | ||||
* attribute setters. | |||||
* attribute setters. | |||||
*/ | */ | ||||
public Path(Project p, String path) { | public Path(Project p, String path) { | ||||
this(p); | this(p); | ||||
@@ -195,7 +195,7 @@ public class Path extends DataType implements Cloneable { | |||||
throw noChildrenAllowed(); | throw noChildrenAllowed(); | ||||
} | } | ||||
elements.addElement(fs); | elements.addElement(fs); | ||||
setChecked( false ); | |||||
setChecked(false); | |||||
} | } | ||||
/** | /** | ||||
@@ -206,7 +206,7 @@ public class Path extends DataType implements Cloneable { | |||||
throw noChildrenAllowed(); | throw noChildrenAllowed(); | ||||
} | } | ||||
elements.addElement(fl); | elements.addElement(fl); | ||||
setChecked( false ); | |||||
setChecked(false); | |||||
} | } | ||||
/** | /** | ||||
@@ -217,7 +217,7 @@ public class Path extends DataType implements Cloneable { | |||||
throw noChildrenAllowed(); | throw noChildrenAllowed(); | ||||
} | } | ||||
elements.addElement(dset); | elements.addElement(dset); | ||||
setChecked( false ); | |||||
setChecked(false); | |||||
} | } | ||||
/** | /** | ||||
@@ -229,10 +229,10 @@ public class Path extends DataType implements Cloneable { | |||||
throw noChildrenAllowed(); | throw noChildrenAllowed(); | ||||
} | } | ||||
elements.addElement(path); | elements.addElement(path); | ||||
setChecked( false ); | |||||
setChecked(false); | |||||
} | } | ||||
/** | /** | ||||
* Creates a nested <code><path></code> element. | * Creates a nested <code><path></code> element. | ||||
*/ | */ | ||||
@@ -242,7 +242,7 @@ public class Path extends DataType implements Cloneable { | |||||
} | } | ||||
Path p = new Path(getProject()); | Path p = new Path(getProject()); | ||||
elements.addElement(p); | elements.addElement(p); | ||||
setChecked( false ); | |||||
setChecked(false); | |||||
return p; | return p; | ||||
} | } | ||||
@@ -268,7 +268,7 @@ public class Path extends DataType implements Cloneable { | |||||
* @param source - source path whose components are examined for existence | * @param source - source path whose components are examined for existence | ||||
*/ | */ | ||||
public void addExisting(Path source) { | public void addExisting(Path source) { | ||||
addExisting(source, false ); | |||||
addExisting(source, false); | |||||
} | } | ||||
/** Same as addExisting, but support classpath behavior if tryUserDir | /** Same as addExisting, but support classpath behavior if tryUserDir | ||||
@@ -280,7 +280,7 @@ public class Path extends DataType implements Cloneable { | |||||
*/ | */ | ||||
public void addExisting(Path source, boolean tryUserDir) { | public void addExisting(Path source, boolean tryUserDir) { | ||||
String[] list = source.list(); | String[] list = source.list(); | ||||
File userDir=(tryUserDir) ? new File(System.getProperty( "user.dir")) | |||||
File userDir = (tryUserDir) ? new File(System.getProperty("user.dir")) | |||||
: null; | : null; | ||||
for (int i = 0; i < list.length; i++) { | for (int i = 0; i < list.length; i++) { | ||||
@@ -292,8 +292,8 @@ public class Path extends DataType implements Cloneable { | |||||
} | } | ||||
// probably not the best choice, but it solves the problem of | // probably not the best choice, but it solves the problem of | ||||
// relative paths in CLASSPATH | // relative paths in CLASSPATH | ||||
if( tryUserDir && ! f.exists()) { | |||||
f=new File( userDir, list[i]); | |||||
if (tryUserDir && !f.exists()) { | |||||
f = new File(userDir, list[i]); | |||||
} | } | ||||
if (f.exists()) { | if (f.exists()) { | ||||
setLocation(f); | setLocation(f); | ||||
@@ -328,14 +328,14 @@ public class Path extends DataType implements Cloneable { | |||||
throw new BuildException(msg); | throw new BuildException(msg); | ||||
} | } | ||||
} | } | ||||
if (o instanceof String) { | if (o instanceof String) { | ||||
// obtained via append | // obtained via append | ||||
addUnlessPresent(result, (String) o); | addUnlessPresent(result, (String) o); | ||||
} else if (o instanceof PathElement) { | } else if (o instanceof PathElement) { | ||||
String[] parts = ((PathElement) o).getParts(); | String[] parts = ((PathElement) o).getParts(); | ||||
if (parts == null) { | if (parts == null) { | ||||
throw new BuildException("You must either set location or" | |||||
throw new BuildException("You must either set location or" | |||||
+ " path on <pathelement>"); | + " path on <pathelement>"); | ||||
} | } | ||||
for (int j = 0; j < parts.length; j++) { | for (int j = 0; j < parts.length; j++) { | ||||
@@ -414,8 +414,8 @@ public class Path extends DataType implements Cloneable { | |||||
try { | try { | ||||
element.append(resolveFile(project, pathElement)); | element.append(resolveFile(project, pathElement)); | ||||
} catch (BuildException e) { | } catch (BuildException e) { | ||||
project.log("Dropping path element " + pathElement | |||||
+ " as it is not valid relative to the project", | |||||
project.log("Dropping path element " + pathElement | |||||
+ " as it is not valid relative to the project", | |||||
Project.MSG_VERBOSE); | Project.MSG_VERBOSE); | ||||
} | } | ||||
for (int i = 0; i < element.length(); i++) { | for (int i = 0; i < element.length(); i++) { | ||||
@@ -431,7 +431,7 @@ public class Path extends DataType implements Cloneable { | |||||
/** | /** | ||||
* Returns its argument with all file separator characters | * Returns its argument with all file separator characters | ||||
* replaced so that they match the local OS conventions. | |||||
* replaced so that they match the local OS conventions. | |||||
*/ | */ | ||||
public static String translateFile(String source) { | public static String translateFile(String source) { | ||||
if (source == null) { | if (source == null) { | ||||
@@ -449,7 +449,7 @@ public class Path extends DataType implements Cloneable { | |||||
/** | /** | ||||
* Translates all occurrences of / or \ to correct separator of the | * Translates all occurrences of / or \ to correct separator of the | ||||
* current platform and returns whether it had to do any | * current platform and returns whether it had to do any | ||||
* replacements. | |||||
* replacements. | |||||
*/ | */ | ||||
protected static boolean translateFileSep(StringBuffer buffer, int pos) { | protected static boolean translateFileSep(StringBuffer buffer, int pos) { | ||||
if (buffer.charAt(pos) == '/' || buffer.charAt(pos) == '\\') { | if (buffer.charAt(pos) == '/' || buffer.charAt(pos) == '\\') { | ||||
@@ -481,9 +481,9 @@ public class Path extends DataType implements Cloneable { | |||||
/** | /** | ||||
* Overrides the version of DataType to recurse on all DataType | * Overrides the version of DataType to recurse on all DataType | ||||
* child elements that may have been added. | |||||
* child elements that may have been added. | |||||
*/ | */ | ||||
protected void dieOnCircularReference(Stack stk, Project p) | |||||
protected void dieOnCircularReference(Stack stk, Project p) | |||||
throws BuildException { | throws BuildException { | ||||
if (isChecked()) { | if (isChecked()) { | ||||
@@ -507,7 +507,7 @@ public class Path extends DataType implements Cloneable { | |||||
} | } | ||||
} | } | ||||
} | } | ||||
setChecked( true ); | |||||
setChecked(true); | |||||
} | } | ||||
/** | /** | ||||
@@ -541,7 +541,7 @@ public class Path extends DataType implements Cloneable { | |||||
File d = new File(dir, s[j]); | File d = new File(dir, s[j]); | ||||
String absolutePath = d.getAbsolutePath(); | String absolutePath = d.getAbsolutePath(); | ||||
addUnlessPresent(v, translateFile(absolutePath)); | addUnlessPresent(v, translateFile(absolutePath)); | ||||
} | |||||
} | |||||
} | } | ||||
/** | /** | ||||
@@ -569,11 +569,11 @@ public class Path extends DataType implements Cloneable { | |||||
order = o; | order = o; | ||||
} | } | ||||
} | } | ||||
if (order.equals("only")) { | if (order.equals("only")) { | ||||
// only: the developer knows what (s)he is doing | // only: the developer knows what (s)he is doing | ||||
result.addExisting(Path.systemClasspath, true); | result.addExisting(Path.systemClasspath, true); | ||||
} else if (order.equals("first")) { | } else if (order.equals("first")) { | ||||
// first: developer could use a little help | // first: developer could use a little help | ||||
result.addExisting(Path.systemClasspath, true); | result.addExisting(Path.systemClasspath, true); | ||||
@@ -586,14 +586,14 @@ public class Path extends DataType implements Cloneable { | |||||
} else { | } else { | ||||
// last: don't trust the developer | // last: don't trust the developer | ||||
if (!order.equals("last")) { | if (!order.equals("last")) { | ||||
log("invalid value for build.sysclasspath: " + order, | |||||
log("invalid value for build.sysclasspath: " + order, | |||||
Project.MSG_WARN); | Project.MSG_WARN); | ||||
} | } | ||||
result.addExisting(this); | result.addExisting(this); | ||||
result.addExisting(Path.systemClasspath, true); | result.addExisting(Path.systemClasspath, true); | ||||
} | } | ||||
return result; | return result; | ||||
@@ -606,16 +606,16 @@ public class Path extends DataType implements Cloneable { | |||||
if (System.getProperty("java.vendor").toLowerCase(Locale.US).indexOf("microsoft") >= 0) { | if (System.getProperty("java.vendor").toLowerCase(Locale.US).indexOf("microsoft") >= 0) { | ||||
// Pull in *.zip from packages directory | // Pull in *.zip from packages directory | ||||
FileSet msZipFiles = new FileSet(); | FileSet msZipFiles = new FileSet(); | ||||
msZipFiles.setDir(new File(System.getProperty("java.home") | |||||
msZipFiles.setDir(new File(System.getProperty("java.home") | |||||
+ File.separator + "Packages")); | + File.separator + "Packages")); | ||||
msZipFiles.setIncludes("*.ZIP"); | msZipFiles.setIncludes("*.ZIP"); | ||||
addFileset(msZipFiles); | addFileset(msZipFiles); | ||||
} else if ("Kaffe".equals(System.getProperty("java.vm.name"))) { | } else if ("Kaffe".equals(System.getProperty("java.vm.name"))) { | ||||
FileSet kaffeJarFiles = new FileSet(); | FileSet kaffeJarFiles = new FileSet(); | ||||
kaffeJarFiles.setDir(new File(System.getProperty("java.home") | |||||
kaffeJarFiles.setDir(new File(System.getProperty("java.home") | |||||
+ File.separator + "share" | + File.separator + "share" | ||||
+ File.separator + "kaffe")); | + File.separator + "kaffe")); | ||||
kaffeJarFiles.setIncludes("*.jar"); | kaffeJarFiles.setIncludes("*.jar"); | ||||
addFileset(kaffeJarFiles); | addFileset(kaffeJarFiles); | ||||
} else if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) { | } else if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) { | ||||
@@ -639,7 +639,7 @@ public class Path extends DataType implements Cloneable { | |||||
+ File.separator + "rt.jar")); | + File.separator + "rt.jar")); | ||||
// Sun's and Apple's 1.4 have JCE and JSSE in separate jars. | // Sun's and Apple's 1.4 have JCE and JSSE in separate jars. | ||||
String[] secJars = { "jce", "jsse" }; | |||||
String[] secJars = {"jce", "jsse"}; | |||||
for (int i = 0; i < secJars.length; i++) { | for (int i = 0; i < secJars.length; i++) { | ||||
addExisting(new Path(null, | addExisting(new Path(null, | ||||
System.getProperty("java.home") | System.getProperty("java.home") | ||||
@@ -190,8 +190,11 @@ public class XMLCatalog extends DataType | |||||
//-- Methods --------------------------------------------------------------- | //-- Methods --------------------------------------------------------------- | ||||
/** | |||||
* Default constructor | |||||
*/ | |||||
public XMLCatalog() { | public XMLCatalog() { | ||||
setChecked( false ); | |||||
setChecked(false); | |||||
} | } | ||||
/** | /** | ||||
@@ -233,6 +236,8 @@ public class XMLCatalog extends DataType | |||||
* is itself a reference to another catalog -- that is, a catalog | * is itself a reference to another catalog -- that is, a catalog | ||||
* cannot both refer to another <em>and</em> contain elements or | * cannot both refer to another <em>and</em> contain elements or | ||||
* other attributes. | * other attributes. | ||||
* | |||||
* @return a Path instance to be configured. | |||||
*/ | */ | ||||
public Path createClasspath() { | public Path createClasspath() { | ||||
if (isReference()) { | if (isReference()) { | ||||
@@ -241,7 +246,7 @@ public class XMLCatalog extends DataType | |||||
if (this.classpath == null) { | if (this.classpath == null) { | ||||
this.classpath = new Path(getProject()); | this.classpath = new Path(getProject()); | ||||
} | } | ||||
setChecked( false ); | |||||
setChecked(false); | |||||
return this.classpath.createPath(); | return this.classpath.createPath(); | ||||
} | } | ||||
@@ -250,6 +255,8 @@ public class XMLCatalog extends DataType | |||||
* itself a reference to another catalog -- that is, a catalog | * itself a reference to another catalog -- that is, a catalog | ||||
* cannot both refer to another <em>and</em> contain elements or | * cannot both refer to another <em>and</em> contain elements or | ||||
* other attributes. | * other attributes. | ||||
* | |||||
* @param classpath the classpath to use to look up entities. | |||||
*/ | */ | ||||
public void setClasspath(Path classpath) { | public void setClasspath(Path classpath) { | ||||
if (isReference()) { | if (isReference()) { | ||||
@@ -260,7 +267,7 @@ public class XMLCatalog extends DataType | |||||
} else { | } else { | ||||
this.classpath.append(classpath); | this.classpath.append(classpath); | ||||
} | } | ||||
setChecked( false ); | |||||
setChecked(false); | |||||
} | } | ||||
/** | /** | ||||
@@ -268,13 +275,15 @@ public class XMLCatalog extends DataType | |||||
* itself a reference to another catalog -- that is, a catalog | * itself a reference to another catalog -- that is, a catalog | ||||
* cannot both refer to another <em>and</em> contain elements or | * cannot both refer to another <em>and</em> contain elements or | ||||
* other attributes. | * other attributes. | ||||
* | |||||
* @param r an Ant reference containing a classpath. | |||||
*/ | */ | ||||
public void setClasspathRef(Reference r) { | public void setClasspathRef(Reference r) { | ||||
if (isReference()) { | if (isReference()) { | ||||
throw tooManyAttributes(); | throw tooManyAttributes(); | ||||
} | } | ||||
createClasspath().setRefid(r); | createClasspath().setRefid(r); | ||||
setChecked( false ); | |||||
setChecked(false); | |||||
} | } | ||||
/** Creates a nested <code><catalogpath></code> element. | /** Creates a nested <code><catalogpath></code> element. | ||||
@@ -282,6 +291,7 @@ public class XMLCatalog extends DataType | |||||
* catalog -- that is, a catalog cannot both refer to another | * catalog -- that is, a catalog cannot both refer to another | ||||
* <em>and</em> contain elements or other attributes. | * <em>and</em> contain elements or other attributes. | ||||
* | * | ||||
* @return a path to be configured as the catalog path. | |||||
* @exception BuildException | * @exception BuildException | ||||
* if this is a reference and no nested elements are allowed. | * if this is a reference and no nested elements are allowed. | ||||
*/ | */ | ||||
@@ -292,7 +302,7 @@ public class XMLCatalog extends DataType | |||||
if (this.catalogPath == null) { | if (this.catalogPath == null) { | ||||
this.catalogPath = new Path(getProject()); | this.catalogPath = new Path(getProject()); | ||||
} | } | ||||
setChecked( false ); | |||||
setChecked(false); | |||||
return this.catalogPath.createPath(); | return this.catalogPath.createPath(); | ||||
} | } | ||||
@@ -301,13 +311,16 @@ public class XMLCatalog extends DataType | |||||
* itself a reference to another catalog -- that is, a catalog | * itself a reference to another catalog -- that is, a catalog | ||||
* cannot both refer to another <em>and</em> contain elements or | * cannot both refer to another <em>and</em> contain elements or | ||||
* other attributes. | * other attributes. | ||||
* | |||||
* @param r an Ant reference containing a classpath to be used as | |||||
* the catalog path. | |||||
*/ | */ | ||||
public void setCatalogPathRef(Reference r) { | public void setCatalogPathRef(Reference r) { | ||||
if (isReference()) { | if (isReference()) { | ||||
throw tooManyAttributes(); | throw tooManyAttributes(); | ||||
} | } | ||||
createCatalogPath().setRefid(r); | createCatalogPath().setRefid(r); | ||||
setChecked( false ); | |||||
setChecked(false); | |||||
} | } | ||||
@@ -338,7 +351,7 @@ public class XMLCatalog extends DataType | |||||
} | } | ||||
getElements().addElement(dtd); | getElements().addElement(dtd); | ||||
setChecked( false ); | |||||
setChecked(false); | |||||
} | } | ||||
/** | /** | ||||
@@ -384,7 +397,7 @@ public class XMLCatalog extends DataType | |||||
// Append the catalog path of the nested catalog | // Append the catalog path of the nested catalog | ||||
Path nestedCatalogPath = catalog.getCatalogPath(); | Path nestedCatalogPath = catalog.getCatalogPath(); | ||||
createCatalogPath().append(nestedCatalogPath); | createCatalogPath().append(nestedCatalogPath); | ||||
setChecked( false ); | |||||
setChecked(false); | |||||
} | } | ||||
/** | /** | ||||
@@ -439,8 +452,8 @@ public class XMLCatalog extends DataType | |||||
getCatalogResolver().resolveEntity(publicId, systemId); | getCatalogResolver().resolveEntity(publicId, systemId); | ||||
if (inputSource == null) { | if (inputSource == null) { | ||||
log("No matching catalog entry found, parser will use: '" + | |||||
systemId + "'", Project.MSG_DEBUG); | |||||
log("No matching catalog entry found, parser will use: '" | |||||
+ systemId + "'", Project.MSG_DEBUG); | |||||
} | } | ||||
return inputSource; | return inputSource; | ||||
@@ -467,11 +480,11 @@ public class XMLCatalog extends DataType | |||||
log("resolve: '" + uri + "' with base: '" + base + "'", Project.MSG_DEBUG); | log("resolve: '" + uri + "' with base: '" + base + "'", Project.MSG_DEBUG); | ||||
source = (SAXSource)getCatalogResolver().resolve(uri, base); | |||||
source = (SAXSource) getCatalogResolver().resolve(uri, base); | |||||
if (source == null) { | if (source == null) { | ||||
log("No matching catalog entry found, parser will use: '" + | |||||
href + "'", Project.MSG_DEBUG); | |||||
log("No matching catalog entry found, parser will use: '" | |||||
+ href + "'", Project.MSG_DEBUG); | |||||
// | // | ||||
// Cannot return a null source, because we have to call | // Cannot return a null source, because we have to call | ||||
// setEntityResolver (see setEntityResolver javadoc comment) | // setEntityResolver (see setEntityResolver javadoc comment) | ||||
@@ -481,14 +494,12 @@ public class XMLCatalog extends DataType | |||||
try { | try { | ||||
if (base == null) { | if (base == null) { | ||||
baseURL = fileUtils.getFileURL(getProject().getBaseDir()); | baseURL = fileUtils.getFileURL(getProject().getBaseDir()); | ||||
} | |||||
else { | |||||
} else { | |||||
baseURL = new URL(base); | baseURL = new URL(base); | ||||
} | } | ||||
URL url = (uri.length() == 0 ? baseURL : new URL(baseURL, uri)); | URL url = (uri.length() == 0 ? baseURL : new URL(baseURL, uri)); | ||||
source.setInputSource(new InputSource(url.toString())); | source.setInputSource(new InputSource(url.toString())); | ||||
} | |||||
catch (MalformedURLException ex) { | |||||
} catch (MalformedURLException ex) { | |||||
// At this point we are probably in failure mode, but | // At this point we are probably in failure mode, but | ||||
// try to use the bare URI as a last gasp | // try to use the bare URI as a last gasp | ||||
source.setInputSource(new InputSource(uri)); | source.setInputSource(new InputSource(uri)); | ||||
@@ -530,19 +541,17 @@ public class XMLCatalog extends DataType | |||||
// available, so use it. | // available, so use it. | ||||
// | // | ||||
catalogResolver = new ApacheResolver(clazz, obj); | catalogResolver = new ApacheResolver(clazz, obj); | ||||
} | |||||
catch (Throwable ex) { | |||||
} catch (Throwable ex) { | |||||
// | // | ||||
// The xml-commons resolver library is not | // The xml-commons resolver library is not | ||||
// available, so we can't use it. | // available, so we can't use it. | ||||
// | // | ||||
catalogResolver = new InternalResolver(); | catalogResolver = new InternalResolver(); | ||||
if (getCatalogPath() != null && | |||||
getCatalogPath().list().length != 0) { | |||||
log("Warning: catalogpath listing external catalogs"+ | |||||
" will be ignored", | |||||
Project.MSG_WARN); | |||||
log("Failed to load Apache resolver: " | |||||
if (getCatalogPath() != null | |||||
&& getCatalogPath().list().length != 0) { | |||||
log("Warning: catalogpath listing external catalogs" | |||||
+ " will be ignored", Project.MSG_WARN); | |||||
log("Failed to load Apache resolver: " | |||||
+ ex, Project.MSG_DEBUG); | + ex, Project.MSG_DEBUG); | ||||
} | } | ||||
} | } | ||||
@@ -577,11 +586,9 @@ public class XMLCatalog extends DataType | |||||
spFactory.setNamespaceAware(true); | spFactory.setNamespaceAware(true); | ||||
try { | try { | ||||
reader = spFactory.newSAXParser().getXMLReader(); | reader = spFactory.newSAXParser().getXMLReader(); | ||||
} | |||||
catch (ParserConfigurationException ex) { | |||||
} catch (ParserConfigurationException ex) { | |||||
throw new TransformerException(ex); | throw new TransformerException(ex); | ||||
} | |||||
catch (SAXException ex) { | |||||
} catch (SAXException ex) { | |||||
throw new TransformerException(ex); | throw new TransformerException(ex); | ||||
} | } | ||||
} | } | ||||
@@ -603,7 +610,7 @@ public class XMLCatalog extends DataType | |||||
while (enum.hasMoreElements()) { | while (enum.hasMoreElements()) { | ||||
Object o = enum.nextElement(); | Object o = enum.nextElement(); | ||||
if (o instanceof ResourceLocation) { | if (o instanceof ResourceLocation) { | ||||
element = (ResourceLocation)o; | |||||
element = (ResourceLocation) o; | |||||
if (element.getPublicId().equals(publicId)) { | if (element.getPublicId().equals(publicId)) { | ||||
return element; | return element; | ||||
} | } | ||||
@@ -652,8 +659,7 @@ public class XMLCatalog extends DataType | |||||
} else { | } else { | ||||
try { | try { | ||||
baseURL = fileUtils.getFileURL(getProject().getBaseDir()); | baseURL = fileUtils.getFileURL(getProject().getBaseDir()); | ||||
} | |||||
catch (MalformedURLException ex) { | |||||
} catch (MalformedURLException ex) { | |||||
throw new BuildException("Project basedir cannot be converted to a URL"); | throw new BuildException("Project basedir cannot be converted to a URL"); | ||||
} | } | ||||
} | } | ||||
@@ -663,8 +669,7 @@ public class XMLCatalog extends DataType | |||||
try { | try { | ||||
url = new URL(baseURL, uri); | url = new URL(baseURL, uri); | ||||
} | |||||
catch (MalformedURLException ex) { | |||||
} catch (MalformedURLException ex) { | |||||
// ignore | // ignore | ||||
} | } | ||||
@@ -678,11 +683,11 @@ public class XMLCatalog extends DataType | |||||
source = new InputSource(new FileInputStream(resFile)); | source = new InputSource(new FileInputStream(resFile)); | ||||
String sysid = JAXPUtils.getSystemId(resFile); | String sysid = JAXPUtils.getSystemId(resFile); | ||||
source.setSystemId(sysid); | source.setSystemId(sysid); | ||||
log("catalog entry matched a readable file: '" + | |||||
sysid + "'", Project.MSG_DEBUG); | |||||
} catch(FileNotFoundException ex) { | |||||
log("catalog entry matched a readable file: '" | |||||
+ sysid + "'", Project.MSG_DEBUG); | |||||
} catch (FileNotFoundException ex) { | |||||
// ignore | // ignore | ||||
} catch(IOException ex) { | |||||
} catch (IOException ex) { | |||||
// ignore | // ignore | ||||
} | } | ||||
} | } | ||||
@@ -721,8 +726,8 @@ public class XMLCatalog extends DataType | |||||
URL entryURL = loader.getResource(matchingEntry.getLocation()); | URL entryURL = loader.getResource(matchingEntry.getLocation()); | ||||
String sysid = entryURL.toExternalForm(); | String sysid = entryURL.toExternalForm(); | ||||
source.setSystemId(sysid); | source.setSystemId(sysid); | ||||
log("catalog entry matched a resource in the classpath: '" + | |||||
sysid + "'", Project.MSG_DEBUG); | |||||
log("catalog entry matched a resource in the classpath: '" | |||||
+ sysid + "'", Project.MSG_DEBUG); | |||||
} | } | ||||
return source; | return source; | ||||
@@ -749,8 +754,7 @@ public class XMLCatalog extends DataType | |||||
} else { | } else { | ||||
try { | try { | ||||
baseURL = fileUtils.getFileURL(getProject().getBaseDir()); | baseURL = fileUtils.getFileURL(getProject().getBaseDir()); | ||||
} | |||||
catch (MalformedURLException ex) { | |||||
} catch (MalformedURLException ex) { | |||||
throw new BuildException("Project basedir cannot be converted to a URL"); | throw new BuildException("Project basedir cannot be converted to a URL"); | ||||
} | } | ||||
} | } | ||||
@@ -760,8 +764,7 @@ public class XMLCatalog extends DataType | |||||
try { | try { | ||||
url = new URL(baseURL, uri); | url = new URL(baseURL, uri); | ||||
} | |||||
catch (MalformedURLException ex) { | |||||
} catch (MalformedURLException ex) { | |||||
// ignore | // ignore | ||||
} | } | ||||
@@ -772,10 +775,10 @@ public class XMLCatalog extends DataType | |||||
source = new InputSource(is); | source = new InputSource(is); | ||||
String sysid = url.toExternalForm(); | String sysid = url.toExternalForm(); | ||||
source.setSystemId(sysid); | source.setSystemId(sysid); | ||||
log("catalog entry matched as a URL: '" + | |||||
sysid + "'", Project.MSG_DEBUG); | |||||
log("catalog entry matched as a URL: '" | |||||
+ sysid + "'", Project.MSG_DEBUG); | |||||
} | } | ||||
} catch(IOException ex) { | |||||
} catch (IOException ex) { | |||||
// ignore | // ignore | ||||
} | } | ||||
} | } | ||||
@@ -816,9 +819,9 @@ public class XMLCatalog extends DataType | |||||
if (matchingEntry != null) { | if (matchingEntry != null) { | ||||
log("Matching catalog entry found for publicId: '" + | |||||
matchingEntry.getPublicId() + "' location: '" + | |||||
matchingEntry.getLocation() + "'", | |||||
log("Matching catalog entry found for publicId: '" | |||||
+ matchingEntry.getPublicId() + "' location: '" | |||||
+ matchingEntry.getLocation() + "'", | |||||
Project.MSG_DEBUG); | Project.MSG_DEBUG); | ||||
result = filesystemLookup(matchingEntry); | result = filesystemLookup(matchingEntry); | ||||
@@ -844,9 +847,9 @@ public class XMLCatalog extends DataType | |||||
if (matchingEntry != null) { | if (matchingEntry != null) { | ||||
log("Matching catalog entry found for uri: '" + | |||||
matchingEntry.getPublicId() + "' location: '" + | |||||
matchingEntry.getLocation() + "'", | |||||
log("Matching catalog entry found for uri: '" | |||||
+ matchingEntry.getPublicId() + "' location: '" | |||||
+ matchingEntry.getLocation() + "'", | |||||
Project.MSG_DEBUG); | Project.MSG_DEBUG); | ||||
// | // | ||||
@@ -865,8 +868,7 @@ public class XMLCatalog extends DataType | |||||
URL baseURL = new URL(base); | URL baseURL = new URL(base); | ||||
entryCopy = new ResourceLocation(); | entryCopy = new ResourceLocation(); | ||||
entryCopy.setBase(baseURL); | entryCopy.setBase(baseURL); | ||||
} | |||||
catch (MalformedURLException ex) { | |||||
} catch (MalformedURLException ex) { | |||||
// ignore | // ignore | ||||
} | } | ||||
} | } | ||||
@@ -926,24 +928,23 @@ public class XMLCatalog extends DataType | |||||
setXMLCatalog = | setXMLCatalog = | ||||
resolverImplClass.getMethod("setXMLCatalog", | resolverImplClass.getMethod("setXMLCatalog", | ||||
new Class[] | new Class[] | ||||
{ XMLCatalog.class }); | |||||
{XMLCatalog.class}); | |||||
parseCatalog = | parseCatalog = | ||||
resolverImplClass.getMethod("parseCatalog", | resolverImplClass.getMethod("parseCatalog", | ||||
new Class[] | new Class[] | ||||
{ String.class }); | |||||
{String.class}); | |||||
resolveEntity = | resolveEntity = | ||||
resolverImplClass.getMethod("resolveEntity", | resolverImplClass.getMethod("resolveEntity", | ||||
new Class[] | new Class[] | ||||
{ String.class, String.class }); | |||||
{String.class, String.class}); | |||||
resolve = | resolve = | ||||
resolverImplClass.getMethod("resolve", | resolverImplClass.getMethod("resolve", | ||||
new Class[] | new Class[] | ||||
{ String.class, String.class }); | |||||
} | |||||
catch (NoSuchMethodException ex) { | |||||
{String.class, String.class}); | |||||
} catch (NoSuchMethodException ex) { | |||||
throw new BuildException(ex); | throw new BuildException(ex); | ||||
} | } | ||||
@@ -961,9 +962,9 @@ public class XMLCatalog extends DataType | |||||
if (matchingEntry != null) { | if (matchingEntry != null) { | ||||
log("Matching catalog entry found for publicId: '" + | |||||
matchingEntry.getPublicId() + "' location: '" + | |||||
matchingEntry.getLocation() + "'", | |||||
log("Matching catalog entry found for publicId: '" | |||||
+ matchingEntry.getPublicId() + "' location: '" | |||||
+ matchingEntry.getLocation() + "'", | |||||
Project.MSG_DEBUG); | Project.MSG_DEBUG); | ||||
result = filesystemLookup(matchingEntry); | result = filesystemLookup(matchingEntry); | ||||
@@ -975,16 +976,14 @@ public class XMLCatalog extends DataType | |||||
if (result == null) { | if (result == null) { | ||||
try { | try { | ||||
result = | result = | ||||
(InputSource)resolveEntity.invoke(resolverImpl, | |||||
(InputSource) resolveEntity.invoke(resolverImpl, | |||||
new Object[] | new Object[] | ||||
{ publicId, systemId }); | |||||
} | |||||
catch (Exception ex) { | |||||
{publicId, systemId}); | |||||
} catch (Exception ex) { | |||||
throw new BuildException(ex); | throw new BuildException(ex); | ||||
} | } | ||||
} | } | ||||
} | |||||
else { | |||||
} else { | |||||
// | // | ||||
// We didn't match a ResourceLocation, but since we | // We didn't match a ResourceLocation, but since we | ||||
// only support PUBLIC and URI entry types internally, | // only support PUBLIC and URI entry types internally, | ||||
@@ -995,11 +994,10 @@ public class XMLCatalog extends DataType | |||||
// | // | ||||
try { | try { | ||||
result = | result = | ||||
(InputSource)resolveEntity.invoke(resolverImpl, | |||||
(InputSource) resolveEntity.invoke(resolverImpl, | |||||
new Object[] | new Object[] | ||||
{ publicId, systemId }); | |||||
} | |||||
catch (Exception ex) { | |||||
{publicId, systemId}); | |||||
} catch (Exception ex) { | |||||
throw new BuildException(ex); | throw new BuildException(ex); | ||||
} | } | ||||
} | } | ||||
@@ -1019,9 +1017,9 @@ public class XMLCatalog extends DataType | |||||
if (matchingEntry != null) { | if (matchingEntry != null) { | ||||
log("Matching catalog entry found for uri: '" + | |||||
matchingEntry.getPublicId() + "' location: '" + | |||||
matchingEntry.getLocation() + "'", | |||||
log("Matching catalog entry found for uri: '" | |||||
+ matchingEntry.getPublicId() + "' location: '" | |||||
+ matchingEntry.getLocation() + "'", | |||||
Project.MSG_DEBUG); | Project.MSG_DEBUG); | ||||
// | // | ||||
@@ -1042,8 +1040,7 @@ public class XMLCatalog extends DataType | |||||
URL baseURL = new URL(base); | URL baseURL = new URL(base); | ||||
entryCopy = new ResourceLocation(); | entryCopy = new ResourceLocation(); | ||||
entryCopy.setBase(baseURL); | entryCopy.setBase(baseURL); | ||||
} | |||||
catch (MalformedURLException ex) { | |||||
} catch (MalformedURLException ex) { | |||||
// ignore | // ignore | ||||
} | } | ||||
} | } | ||||
@@ -1061,16 +1058,14 @@ public class XMLCatalog extends DataType | |||||
} else { | } else { | ||||
try { | try { | ||||
result = | result = | ||||
(SAXSource)resolve.invoke(resolverImpl, | |||||
(SAXSource) resolve.invoke(resolverImpl, | |||||
new Object[] | new Object[] | ||||
{ href, base }); | |||||
} | |||||
catch (Exception ex) { | |||||
{href, base}); | |||||
} catch (Exception ex) { | |||||
throw new BuildException(ex); | throw new BuildException(ex); | ||||
} | } | ||||
} | } | ||||
} | |||||
else { | |||||
} else { | |||||
// | // | ||||
// We didn't match a ResourceLocation, but since we | // We didn't match a ResourceLocation, but since we | ||||
// only support PUBLIC and URI entry types internally, | // only support PUBLIC and URI entry types internally, | ||||
@@ -1081,11 +1076,10 @@ public class XMLCatalog extends DataType | |||||
// | // | ||||
try { | try { | ||||
result = | result = | ||||
(SAXSource)resolve.invoke(resolverImpl, | |||||
(SAXSource) resolve.invoke(resolverImpl, | |||||
new Object[] | new Object[] | ||||
{ href, base }); | |||||
} | |||||
catch (Exception ex) { | |||||
{href, base}); | |||||
} catch (Exception ex) { | |||||
throw new BuildException(ex); | throw new BuildException(ex); | ||||
} | } | ||||
} | } | ||||
@@ -1101,32 +1095,31 @@ public class XMLCatalog extends DataType | |||||
*/ | */ | ||||
private void processExternalCatalogs() { | private void processExternalCatalogs() { | ||||
if (externalCatalogsProcessed == false) { | |||||
if (!externalCatalogsProcessed) { | |||||
try { | try { | ||||
setXMLCatalog.invoke(resolverImpl, | setXMLCatalog.invoke(resolverImpl, | ||||
new Object[] | new Object[] | ||||
{ XMLCatalog.this }); | |||||
} | |||||
catch (Exception ex) { | |||||
{XMLCatalog.this}); | |||||
} catch (Exception ex) { | |||||
throw new BuildException(ex); | throw new BuildException(ex); | ||||
} | } | ||||
// Parse each catalog listed in nested <catalogpath> elements | // Parse each catalog listed in nested <catalogpath> elements | ||||
Path catPath = getCatalogPath(); | Path catPath = getCatalogPath(); | ||||
if (catPath != null) { | if (catPath != null) { | ||||
log("Using catalogpath '" + getCatalogPath()+"'", Project.MSG_DEBUG); | |||||
log("Using catalogpath '" + getCatalogPath() + "'", | |||||
Project.MSG_DEBUG); | |||||
String[] catPathList = getCatalogPath().list(); | String[] catPathList = getCatalogPath().list(); | ||||
for (int i=0; i< catPathList.length; i++) { | |||||
for (int i = 0; i < catPathList.length; i++) { | |||||
File catFile = new File(catPathList[i]); | File catFile = new File(catPathList[i]); | ||||
log("Parsing "+catFile, Project.MSG_DEBUG); | |||||
log("Parsing " + catFile, Project.MSG_DEBUG); | |||||
try { | try { | ||||
parseCatalog.invoke(resolverImpl, | parseCatalog.invoke(resolverImpl, | ||||
new Object[] | new Object[] | ||||
{ catFile.getPath() }); | |||||
} | |||||
catch (Exception ex) { | |||||
{catFile.getPath()}); | |||||
} catch (Exception ex) { | |||||
throw new BuildException(ex); | throw new BuildException(ex); | ||||
} | } | ||||
} | } | ||||
@@ -160,7 +160,7 @@ public class ZipFileSet extends FileSet { | |||||
*/ | */ | ||||
public File getSrc(Project p) { | public File getSrc(Project p) { | ||||
if (isReference()) { | if (isReference()) { | ||||
return ((ZipFileSet)getRef(p)).getSrc(p); | |||||
return ((ZipFileSet) getRef(p)).getSrc(p); | |||||
} | } | ||||
return srcFile; | return srcFile; | ||||
} | } | ||||
@@ -186,7 +186,7 @@ public class ZipFileSet extends FileSet { | |||||
*/ | */ | ||||
public String getPrefix(Project p) { | public String getPrefix(Project p) { | ||||
if (isReference()) { | if (isReference()) { | ||||
return ((ZipFileSet)getRef(p)).getPrefix(p); | |||||
return ((ZipFileSet) getRef(p)).getPrefix(p); | |||||
} | } | ||||
return prefix; | return prefix; | ||||
} | } | ||||
@@ -212,7 +212,7 @@ public class ZipFileSet extends FileSet { | |||||
*/ | */ | ||||
public String getFullpath(Project p) { | public String getFullpath(Project p) { | ||||
if (isReference()) { | if (isReference()) { | ||||
return ((ZipFileSet)getRef(p)).getFullpath(p); | |||||
return ((ZipFileSet) getRef(p)).getFullpath(p); | |||||
} | } | ||||
return fullpath; | return fullpath; | ||||
} | } | ||||
@@ -259,7 +259,7 @@ public class ZipFileSet extends FileSet { | |||||
*/ | */ | ||||
public int getFileMode(Project p) { | public int getFileMode(Project p) { | ||||
if (isReference()) { | if (isReference()) { | ||||
return ((ZipFileSet)getRef(p)).getFileMode(p); | |||||
return ((ZipFileSet) getRef(p)).getFileMode(p); | |||||
} | } | ||||
return fileMode; | return fileMode; | ||||
} | } | ||||
@@ -271,7 +271,7 @@ public class ZipFileSet extends FileSet { | |||||
*/ | */ | ||||
public boolean hasFileModeBeenSet() { | public boolean hasFileModeBeenSet() { | ||||
if (isReference()) { | if (isReference()) { | ||||
return ((ZipFileSet)getRef(getProject())).hasFileModeBeenSet(); | |||||
return ((ZipFileSet) getRef(getProject())).hasFileModeBeenSet(); | |||||
} | } | ||||
return fileModeHasBeenSet; | return fileModeHasBeenSet; | ||||
} | } | ||||
@@ -297,7 +297,7 @@ public class ZipFileSet extends FileSet { | |||||
*/ | */ | ||||
public int getDirMode(Project p) { | public int getDirMode(Project p) { | ||||
if (isReference()) { | if (isReference()) { | ||||
return ((ZipFileSet)getRef(p)).getDirMode(p); | |||||
return ((ZipFileSet) getRef(p)).getDirMode(p); | |||||
} | } | ||||
return dirMode; | return dirMode; | ||||
} | } | ||||
@@ -309,7 +309,7 @@ public class ZipFileSet extends FileSet { | |||||
*/ | */ | ||||
public boolean hasDirModeBeenSet() { | public boolean hasDirModeBeenSet() { | ||||
if (isReference()) { | if (isReference()) { | ||||
return ((ZipFileSet)getRef(getProject())).hasDirModeBeenSet(); | |||||
return ((ZipFileSet) getRef(getProject())).hasDirModeBeenSet(); | |||||
} | } | ||||
return dirModeHasBeenSet; | return dirModeHasBeenSet; | ||||
} | } | ||||
@@ -55,7 +55,6 @@ | |||||
package org.apache.tools.ant.types; | package org.apache.tools.ant.types; | ||||
import java.io.File; | import java.io.File; | ||||
import java.io.FileInputStream; | |||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.util.Vector; | import java.util.Vector; | ||||
import java.util.Hashtable; | import java.util.Hashtable; | ||||
@@ -131,8 +130,8 @@ public class ZipScanner extends DirectoryScanner { | |||||
Vector myvector = new Vector(); | Vector myvector = new Vector(); | ||||
// first check if the archive needs to be scanned again | // first check if the archive needs to be scanned again | ||||
scanme(); | scanme(); | ||||
for (Enumeration e = myentries.elements(); e.hasMoreElements() ;) { | |||||
Resource myresource= (Resource) e.nextElement(); | |||||
for (Enumeration e = myentries.elements(); e.hasMoreElements();) { | |||||
Resource myresource = (Resource) e.nextElement(); | |||||
if (!myresource.isDirectory() && match(myresource.getName())) { | if (!myresource.isDirectory() && match(myresource.getName())) { | ||||
myvector.addElement(myresource.getName()); | myvector.addElement(myresource.getName()); | ||||
} | } | ||||
@@ -155,11 +154,11 @@ public class ZipScanner extends DirectoryScanner { | |||||
*/ | */ | ||||
public String[] getIncludedDirectories() { | public String[] getIncludedDirectories() { | ||||
if (srcFile != null) { | if (srcFile != null) { | ||||
Vector myvector=new Vector(); | |||||
Vector myvector = new Vector(); | |||||
// first check if the archive needs to be scanned again | // first check if the archive needs to be scanned again | ||||
scanme(); | scanme(); | ||||
for (Enumeration e = myentries.elements(); e.hasMoreElements() ;) { | |||||
Resource myresource= (Resource) e.nextElement(); | |||||
for (Enumeration e = myentries.elements(); e.hasMoreElements();) { | |||||
Resource myresource = (Resource) e.nextElement(); | |||||
if (myresource.isDirectory() && match(myresource.getName())) { | if (myresource.isDirectory() && match(myresource.getName())) { | ||||
myvector.addElement(myresource.getName()); | myvector.addElement(myresource.getName()); | ||||
} | } | ||||
@@ -261,8 +260,8 @@ public class ZipScanner extends DirectoryScanner { | |||||
while (enum.hasMoreElements()) { | while (enum.hasMoreElements()) { | ||||
entry = (ZipEntry) enum.nextElement(); | entry = (ZipEntry) enum.nextElement(); | ||||
myentries.put(new String(entry.getName()), | myentries.put(new String(entry.getName()), | ||||
new Resource(entry.getName(), true, | |||||
entry.getTime(), | |||||
new Resource(entry.getName(), true, | |||||
entry.getTime(), | |||||
entry.isDirectory())); | entry.isDirectory())); | ||||
} | } | ||||
} finally { | } finally { | ||||
@@ -114,7 +114,7 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable { | |||||
if (crc > 0) { | if (crc > 0) { | ||||
setCrc(crc); | setCrc(crc); | ||||
} | } | ||||
byte[] extra = entry.getExtra(); | byte[] extra = entry.getExtra(); | ||||
if (extra != null) { | if (extra != null) { | ||||
setExtraFields(ExtraFieldUtils.parse(extra)); | setExtraFields(ExtraFieldUtils.parse(extra)); | ||||
@@ -168,7 +168,7 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable { | |||||
if (crc > 0) { | if (crc > 0) { | ||||
e.setCrc(crc); | e.setCrc(crc); | ||||
} | } | ||||
e.extraFields = (Vector) extraFields.clone(); | e.extraFields = (Vector) extraFields.clone(); | ||||
e.setInternalAttributes(getInternalAttributes()); | e.setInternalAttributes(getInternalAttributes()); | ||||
e.setExternalAttributes(getExternalAttributes()); | e.setExternalAttributes(getExternalAttributes()); | ||||
@@ -484,8 +484,8 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable { | |||||
synchronized (lockReflection) { | synchronized (lockReflection) { | ||||
triedToGetMethod = true; | triedToGetMethod = true; | ||||
try { | try { | ||||
setCompressedSizeMethod = | |||||
java.util.zip.ZipEntry.class.getMethod("setCompressedSize", | |||||
setCompressedSizeMethod = | |||||
java.util.zip.ZipEntry.class.getMethod("setCompressedSize", | |||||
new Class[] {Long.TYPE}); | new Class[] {Long.TYPE}); | ||||
} catch (NoSuchMethodException nse) { | } catch (NoSuchMethodException nse) { | ||||
} | } | ||||
@@ -220,7 +220,7 @@ public class ZipFile { | |||||
/** | /** | ||||
* Returns an InputStream for reading the contents of the given entry. | * Returns an InputStream for reading the contents of the given entry. | ||||
* @param the entry to get the stream for. | |||||
* @param ze the entry to get the stream for. | |||||
* @return a stream to read the entry from. | * @return a stream to read the entry from. | ||||
*/ | */ | ||||
public InputStream getInputStream(ZipEntry ze) | public InputStream getInputStream(ZipEntry ze) | ||||
@@ -229,7 +229,7 @@ public class ZipFile { | |||||
if (start == null) { | if (start == null) { | ||||
return null; | return null; | ||||
} | } | ||||
BoundedInputStream bis = | |||||
BoundedInputStream bis = | |||||
new BoundedInputStream(start.longValue(), ze.getCompressedSize()); | new BoundedInputStream(start.longValue(), ze.getCompressedSize()); | ||||
switch (ze.getMethod()) { | switch (ze.getMethod()) { | ||||
case ZipEntry.STORED: | case ZipEntry.STORED: | ||||
@@ -269,7 +269,7 @@ public class ZipFile { | |||||
* the central directory alone, but not the data that requires the | * the central directory alone, but not the data that requires the | ||||
* local file header or additional data to be read.</p> | * local file header or additional data to be read.</p> | ||||
*/ | */ | ||||
private void populateFromCentralDirectory() | |||||
private void populateFromCentralDirectory() | |||||
throws IOException { | throws IOException { | ||||
positionAtCentralDirectory(); | positionAtCentralDirectory(); | ||||
@@ -372,7 +372,7 @@ public class ZipFile { | |||||
* it and positions the stream at the first central directory | * it and positions the stream at the first central directory | ||||
* record. | * record. | ||||
*/ | */ | ||||
private void positionAtCentralDirectory() | |||||
private void positionAtCentralDirectory() | |||||
throws IOException { | throws IOException { | ||||
long off = archive.length() - MIN_EOCD_SIZE; | long off = archive.length() - MIN_EOCD_SIZE; | ||||
archive.seek(off); | archive.seek(off); | ||||
@@ -443,7 +443,7 @@ public class ZipFile { | |||||
byte[] localExtraData = new byte[extraFieldLen]; | byte[] localExtraData = new byte[extraFieldLen]; | ||||
archive.readFully(localExtraData); | archive.readFully(localExtraData); | ||||
ze.setExtra(localExtraData); | ze.setExtra(localExtraData); | ||||
dataOffsets.put(ze, | |||||
dataOffsets.put(ze, | |||||
new Long(offset + LFH_OFFSET_FOR_FILENAME_LENGTH | new Long(offset + LFH_OFFSET_FOR_FILENAME_LENGTH | ||||
+ 2 + 2 + fileNameLen + extraFieldLen)); | + 2 + 2 + fileNameLen + extraFieldLen)); | ||||
} | } | ||||
@@ -551,7 +551,7 @@ public class ZipFile { | |||||
* Inflater's javadocs. | * Inflater's javadocs. | ||||
*/ | */ | ||||
void addDummy() { | void addDummy() { | ||||
addDummyByte = true; | |||||
addDummyByte = true; | |||||
} | } | ||||
} | } | ||||
@@ -89,7 +89,7 @@ public final class ZipLong implements Cloneable { | |||||
* @since 1.1 | * @since 1.1 | ||||
*/ | */ | ||||
public ZipLong (byte[] bytes, int offset) { | public ZipLong (byte[] bytes, int offset) { | ||||
value = (bytes[offset + 3] << 24) & 0xFF000000l; | |||||
value = (bytes[offset + 3] << 24) & 0xFF000000L; | |||||
value += (bytes[offset + 2] << 16) & 0xFF0000; | value += (bytes[offset + 2] << 16) & 0xFF0000; | ||||
value += (bytes[offset + 1] << 8) & 0xFF00; | value += (bytes[offset + 1] << 8) & 0xFF00; | ||||
value += (bytes[offset] & 0xFF); | value += (bytes[offset] & 0xFF); | ||||
@@ -138,5 +138,4 @@ public final class ZipLong implements Cloneable { | |||||
public int hashCode() { | public int hashCode() { | ||||
return (int) value; | return (int) value; | ||||
} | } | ||||
}// ZipLong | |||||
} |
@@ -234,7 +234,7 @@ public class ZipOutputStream extends DeflaterOutputStream { | |||||
* The encoding to use for filenames and the file comment. | * The encoding to use for filenames and the file comment. | ||||
* | * | ||||
* @return null if using the platform's default character encoding. | * @return null if using the platform's default character encoding. | ||||
* | |||||
* | |||||
* @since 1.3 | * @since 1.3 | ||||
*/ | */ | ||||
public String getEncoding() { | public String getEncoding() { | ||||
@@ -294,17 +294,17 @@ public class ZipOutputStream extends DeflaterOutputStream { | |||||
} else { | } else { | ||||
if (entry.getCrc() != realCrc) { | if (entry.getCrc() != realCrc) { | ||||
throw new ZipException("bad CRC checksum for entry " | throw new ZipException("bad CRC checksum for entry " | ||||
+ entry.getName() + ": " | |||||
+ entry.getName() + ": " | |||||
+ Long.toHexString(entry.getCrc()) | + Long.toHexString(entry.getCrc()) | ||||
+ " instead of " | |||||
+ " instead of " | |||||
+ Long.toHexString(realCrc)); | + Long.toHexString(realCrc)); | ||||
} | } | ||||
if (entry.getSize() != written - dataStart) { | if (entry.getSize() != written - dataStart) { | ||||
throw new ZipException("bad size for entry " | throw new ZipException("bad size for entry " | ||||
+ entry.getName() + ": " | |||||
+ entry.getName() + ": " | |||||
+ entry.getSize() | + entry.getSize() | ||||
+ " instead of " | |||||
+ " instead of " | |||||
+ (written - dataStart)); | + (written - dataStart)); | ||||
} | } | ||||
@@ -328,7 +328,7 @@ public class ZipOutputStream extends DeflaterOutputStream { | |||||
if (entry.getMethod() == -1) { // not specified | if (entry.getMethod() == -1) { // not specified | ||||
entry.setMethod(method); | entry.setMethod(method); | ||||
} | } | ||||
if (entry.getTime() == -1) { // not specified | if (entry.getTime() == -1) { // not specified | ||||
entry.setTime(System.currentTimeMillis()); | entry.setTime(System.currentTimeMillis()); | ||||
} | } | ||||
@@ -344,7 +344,7 @@ public class ZipOutputStream extends DeflaterOutputStream { | |||||
} else if (hasCompressionLevelChanged) { | } else if (hasCompressionLevelChanged) { | ||||
def.setLevel(level); | def.setLevel(level); | ||||
hasCompressionLevelChanged = false; | hasCompressionLevelChanged = false; | ||||
} | |||||
} | |||||
writeLocalFileHeader(entry); | writeLocalFileHeader(entry); | ||||
} | } | ||||
@@ -471,12 +471,12 @@ public class ZipOutputStream extends DeflaterOutputStream { | |||||
out.write((new ZipLong(ze.getSize())).getBytes()); | out.write((new ZipLong(ze.getSize())).getBytes()); | ||||
} | } | ||||
written += 12; | written += 12; | ||||
// file name length | // file name length | ||||
byte[] name = getBytes(ze.getName()); | byte[] name = getBytes(ze.getName()); | ||||
out.write((new ZipShort(name.length)).getBytes()); | out.write((new ZipShort(name.length)).getBytes()); | ||||
written += 2; | written += 2; | ||||
// extra field length | // extra field length | ||||
byte[] extra = ze.getLocalFileDataExtra(); | byte[] extra = ze.getLocalFileDataExtra(); | ||||
out.write((new ZipShort(extra.length)).getBytes()); | out.write((new ZipShort(extra.length)).getBytes()); | ||||
@@ -552,12 +552,12 @@ public class ZipOutputStream extends DeflaterOutputStream { | |||||
out.write((new ZipLong(ze.getCompressedSize())).getBytes()); | out.write((new ZipLong(ze.getCompressedSize())).getBytes()); | ||||
out.write((new ZipLong(ze.getSize())).getBytes()); | out.write((new ZipLong(ze.getSize())).getBytes()); | ||||
written += 12; | written += 12; | ||||
// file name length | // file name length | ||||
byte[] name = getBytes(ze.getName()); | byte[] name = getBytes(ze.getName()); | ||||
out.write((new ZipShort(name.length)).getBytes()); | out.write((new ZipShort(name.length)).getBytes()); | ||||
written += 2; | written += 2; | ||||
// extra field length | // extra field length | ||||
byte[] extra = ze.getCentralDirectoryExtra(); | byte[] extra = ze.getCentralDirectoryExtra(); | ||||
out.write((new ZipShort(extra.length)).getBytes()); | out.write((new ZipShort(extra.length)).getBytes()); | ||||
@@ -571,7 +571,7 @@ public class ZipOutputStream extends DeflaterOutputStream { | |||||
byte[] comment = getBytes(comm); | byte[] comment = getBytes(comm); | ||||
out.write((new ZipShort(comment.length)).getBytes()); | out.write((new ZipShort(comment.length)).getBytes()); | ||||
written += 2; | written += 2; | ||||
// disk number start | // disk number start | ||||
out.write(ZERO); | out.write(ZERO); | ||||
written += 2; | written += 2; | ||||
@@ -608,7 +608,7 @@ public class ZipOutputStream extends DeflaterOutputStream { | |||||
*/ | */ | ||||
protected void writeCentralDirectoryEnd() throws IOException { | protected void writeCentralDirectoryEnd() throws IOException { | ||||
out.write(EOCD_SIG.getBytes()); | out.write(EOCD_SIG.getBytes()); | ||||
// disk numbers | // disk numbers | ||||
out.write(ZERO); | out.write(ZERO); | ||||
out.write(ZERO); | out.write(ZERO); | ||||
@@ -654,12 +654,12 @@ public class ZipOutputStream extends DeflaterOutputStream { | |||||
| (time.getHours() << 11) | | (time.getHours() << 11) | ||||
| (time.getMinutes() << 5) | | (time.getMinutes() << 5) | ||||
| (time.getSeconds() >> 1); | | (time.getSeconds() >> 1); | ||||
byte[] result = new byte[4]; | byte[] result = new byte[4]; | ||||
result[0] = (byte) ((value & 0xFF)); | result[0] = (byte) ((value & 0xFF)); | ||||
result[1] = (byte) ((value & 0xFF00) >> 8); | result[1] = (byte) ((value & 0xFF00) >> 8); | ||||
result[2] = (byte) ((value & 0xFF0000) >> 16); | result[2] = (byte) ((value & 0xFF0000) >> 16); | ||||
result[3] = (byte) ((value & 0xFF000000l) >> 24); | |||||
result[3] = (byte) ((value & 0xFF000000L) >> 24); | |||||
return new ZipLong(result); | return new ZipLong(result); | ||||
} | } | ||||
@@ -134,5 +134,4 @@ public final class ZipShort implements Cloneable { | |||||
public int hashCode() { | public int hashCode() { | ||||
return value; | return value; | ||||
} | } | ||||
}// ZipShort | |||||
} |