From 66b5bf27b7d561fbd5c71e408ed5fca66a8aa788 Mon Sep 17 00:00:00 2001 From: Conor MacNeill Date: Tue, 15 Jul 2003 14:54:15 +0000 Subject: [PATCH] style git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274824 13f79535-47bb-0310-9956-ffa450edef68 --- .../tools/ant/taskdefs/ExecuteJava.java | 6 +- .../org/apache/tools/ant/taskdefs/Zip.java | 30 +-- src/main/org/apache/tools/ant/types/Path.java | 62 +++--- .../apache/tools/ant/types/XMLCatalog.java | 191 +++++++++--------- .../apache/tools/ant/types/ZipFileSet.java | 14 +- .../apache/tools/ant/types/ZipScanner.java | 15 +- src/main/org/apache/tools/zip/ZipEntry.java | 8 +- src/main/org/apache/tools/zip/ZipFile.java | 12 +- src/main/org/apache/tools/zip/ZipLong.java | 5 +- .../org/apache/tools/zip/ZipOutputStream.java | 30 +-- src/main/org/apache/tools/zip/ZipShort.java | 3 +- 11 files changed, 183 insertions(+), 193 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java b/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java index 9755edd4d..d7e0c1620 100644 --- a/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java +++ b/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java @@ -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) { 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() { 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) { if (thread != null) { diff --git a/src/main/org/apache/tools/ant/taskdefs/Zip.java b/src/main/org/apache/tools/ant/taskdefs/Zip.java index b0cd2e3a9..96b474485 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Zip.java +++ b/src/main/org/apache/tools/ant/taskdefs/Zip.java @@ -317,8 +317,7 @@ public class Zip extends MatchingTask { executeMain(); skipWriting = false; executeMain(); - } - else { + } else { executeMain(); } } @@ -418,7 +417,7 @@ public class Zip extends MatchingTask { ZipOutputStream zOut = null; try { - if (! skipWriting) { + if (!skipWriting) { zOut = new ZipOutputStream(new FileOutputStream(zipFile)); zOut.setEncoding(encoding); @@ -464,8 +463,8 @@ public class Zip extends MatchingTask { // temporary file if (doUpdate) { 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; @@ -504,8 +503,8 @@ public class Zip extends MatchingTask { try { fileUtils.rename(renamedFile, zipFile); } 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)) { continue; } - if (resources[i].isDirectory() && ! name.endsWith("/")) { + if (resources[i].isDirectory() && !name.endsWith("/")) { name = name + "/"; } @@ -665,6 +664,7 @@ public class Zip extends MatchingTask { try { os.close(); } catch (IOException e) { + //ignore } } } @@ -744,8 +744,8 @@ public class Zip extends MatchingTask { } } else if (emptyBehavior.equals("fail")) { throw new BuildException("Cannot create " + archiveType - + " archive " + zipFile + - ": no files were included.", + + " archive " + zipFile + + ": no files were included.", getLocation()); } else { // Create. @@ -794,7 +794,7 @@ public class Zip extends MatchingTask { if (filesets[i] instanceof ZipFileSet) { ZipFileSet zfs = (ZipFileSet) filesets[i]; if (zfs.getFullpath(getProject()) != null - && !zfs.getFullpath(getProject()).equals("") ) { + && !zfs.getFullpath(getProject()).equals("")) { // in this case all files from origin map to // the fullPath attribute of the zipfileset at // destination @@ -804,7 +804,7 @@ public class Zip extends MatchingTask { } else if (zfs.getPrefix(getProject()) != null && !zfs.getPrefix(getProject()).equals("")) { - GlobPatternMapper gm=new GlobPatternMapper(); + GlobPatternMapper gm = new GlobPatternMapper(); gm.setFrom("*"); String prefix = zfs.getPrefix(getProject()); if (!prefix.endsWith("/") && !prefix.endsWith("\\")) { @@ -888,7 +888,7 @@ public class Zip extends MatchingTask { log("adding directory " + vPath, Project.MSG_VERBOSE); addedDirs.put(vPath, vPath); - if (! skipWriting) { + if (!skipWriting) { ZipEntry ze = new ZipEntry (vPath); if (dir != null && dir.exists()) { // ZIPs store time with a granularity of 2 seconds, round up @@ -943,7 +943,7 @@ public class Zip extends MatchingTask { entries.put(vPath, vPath); - if (! skipWriting) { + if (!skipWriting) { ZipEntry ze = new ZipEntry(vPath); ze.setTime(lastModified); @@ -1123,7 +1123,7 @@ public class Zip extends MatchingTask { * * @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++) { if (r[i].length > 0) { return false; diff --git a/src/main/org/apache/tools/ant/types/Path.java b/src/main/org/apache/tools/ant/types/Path.java index 0516e3aea..6be1c76cf 100644 --- a/src/main/org/apache/tools/ant/types/Path.java +++ b/src/main/org/apache/tools/ant/types/Path.java @@ -100,7 +100,7 @@ public class Path extends DataType implements Cloneable { private Vector elements; /** The system classspath as a Path object */ - public static Path systemClasspath = + public static Path systemClasspath = new Path(null, System.getProperty("java.class.path")); @@ -125,7 +125,7 @@ public class Path extends DataType implements Cloneable { /** * Invoked by IntrospectionHelper for setXXX(Path p) - * attribute setters. + * attribute setters. */ public Path(Project p, String path) { this(p); @@ -195,7 +195,7 @@ public class Path extends DataType implements Cloneable { throw noChildrenAllowed(); } elements.addElement(fs); - setChecked( false ); + setChecked(false); } /** @@ -206,7 +206,7 @@ public class Path extends DataType implements Cloneable { throw noChildrenAllowed(); } elements.addElement(fl); - setChecked( false ); + setChecked(false); } /** @@ -217,7 +217,7 @@ public class Path extends DataType implements Cloneable { throw noChildrenAllowed(); } elements.addElement(dset); - setChecked( false ); + setChecked(false); } /** @@ -229,10 +229,10 @@ public class Path extends DataType implements Cloneable { throw noChildrenAllowed(); } elements.addElement(path); - setChecked( false ); - + setChecked(false); + } - + /** * Creates a nested <path> element. */ @@ -242,7 +242,7 @@ public class Path extends DataType implements Cloneable { } Path p = new Path(getProject()); elements.addElement(p); - setChecked( false ); + setChecked(false); return p; } @@ -268,7 +268,7 @@ public class Path extends DataType implements Cloneable { * @param source - source path whose components are examined for existence */ public void addExisting(Path source) { - addExisting(source, false ); + addExisting(source, false); } /** 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) { String[] list = source.list(); - File userDir=(tryUserDir) ? new File(System.getProperty( "user.dir")) + File userDir = (tryUserDir) ? new File(System.getProperty("user.dir")) : null; 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 // 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()) { setLocation(f); @@ -328,14 +328,14 @@ public class Path extends DataType implements Cloneable { throw new BuildException(msg); } } - + if (o instanceof String) { // obtained via append addUnlessPresent(result, (String) o); } else if (o instanceof PathElement) { String[] parts = ((PathElement) o).getParts(); if (parts == null) { - throw new BuildException("You must either set location or" + throw new BuildException("You must either set location or" + " path on "); } for (int j = 0; j < parts.length; j++) { @@ -414,8 +414,8 @@ public class Path extends DataType implements Cloneable { try { element.append(resolveFile(project, pathElement)); } 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); } 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 - * replaced so that they match the local OS conventions. + * replaced so that they match the local OS conventions. */ public static String translateFile(String source) { if (source == null) { @@ -449,7 +449,7 @@ public class Path extends DataType implements Cloneable { /** * Translates all occurrences of / or \ to correct separator of the * current platform and returns whether it had to do any - * replacements. + * replacements. */ protected static boolean translateFileSep(StringBuffer buffer, int 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 - * 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 { 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]); String absolutePath = d.getAbsolutePath(); addUnlessPresent(v, translateFile(absolutePath)); - } + } } /** @@ -569,11 +569,11 @@ public class Path extends DataType implements Cloneable { order = o; } } - + if (order.equals("only")) { // only: the developer knows what (s)he is doing result.addExisting(Path.systemClasspath, true); - + } else if (order.equals("first")) { // first: developer could use a little help result.addExisting(Path.systemClasspath, true); @@ -586,14 +586,14 @@ public class Path extends DataType implements Cloneable { } else { // last: don't trust the developer if (!order.equals("last")) { - log("invalid value for build.sysclasspath: " + order, + log("invalid value for build.sysclasspath: " + order, Project.MSG_WARN); } result.addExisting(this); result.addExisting(Path.systemClasspath, true); } - + return result; @@ -606,16 +606,16 @@ public class Path extends DataType implements Cloneable { if (System.getProperty("java.vendor").toLowerCase(Locale.US).indexOf("microsoft") >= 0) { // Pull in *.zip from packages directory FileSet msZipFiles = new FileSet(); - msZipFiles.setDir(new File(System.getProperty("java.home") + msZipFiles.setDir(new File(System.getProperty("java.home") + File.separator + "Packages")); msZipFiles.setIncludes("*.ZIP"); addFileset(msZipFiles); } else if ("Kaffe".equals(System.getProperty("java.vm.name"))) { 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 + "kaffe")); - + kaffeJarFiles.setIncludes("*.jar"); addFileset(kaffeJarFiles); } else if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) { @@ -639,7 +639,7 @@ public class Path extends DataType implements Cloneable { + File.separator + "rt.jar")); // 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++) { addExisting(new Path(null, System.getProperty("java.home") diff --git a/src/main/org/apache/tools/ant/types/XMLCatalog.java b/src/main/org/apache/tools/ant/types/XMLCatalog.java index 95764aab9..3d667366d 100644 --- a/src/main/org/apache/tools/ant/types/XMLCatalog.java +++ b/src/main/org/apache/tools/ant/types/XMLCatalog.java @@ -190,8 +190,11 @@ public class XMLCatalog extends DataType //-- Methods --------------------------------------------------------------- + /** + * Default constructor + */ 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 * cannot both refer to another and contain elements or * other attributes. + * + * @return a Path instance to be configured. */ public Path createClasspath() { if (isReference()) { @@ -241,7 +246,7 @@ public class XMLCatalog extends DataType if (this.classpath == null) { this.classpath = new Path(getProject()); } - setChecked( false ); + setChecked(false); return this.classpath.createPath(); } @@ -250,6 +255,8 @@ public class XMLCatalog extends DataType * itself a reference to another catalog -- that is, a catalog * cannot both refer to another and contain elements or * other attributes. + * + * @param classpath the classpath to use to look up entities. */ public void setClasspath(Path classpath) { if (isReference()) { @@ -260,7 +267,7 @@ public class XMLCatalog extends DataType } else { 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 * cannot both refer to another and contain elements or * other attributes. + * + * @param r an Ant reference containing a classpath. */ public void setClasspathRef(Reference r) { if (isReference()) { throw tooManyAttributes(); } createClasspath().setRefid(r); - setChecked( false ); + setChecked(false); } /** Creates a nested <catalogpath> element. @@ -282,6 +291,7 @@ public class XMLCatalog extends DataType * catalog -- that is, a catalog cannot both refer to another * and contain elements or other attributes. * + * @return a path to be configured as the catalog path. * @exception BuildException * if this is a reference and no nested elements are allowed. */ @@ -292,7 +302,7 @@ public class XMLCatalog extends DataType if (this.catalogPath == null) { this.catalogPath = new Path(getProject()); } - setChecked( false ); + setChecked(false); return this.catalogPath.createPath(); } @@ -301,13 +311,16 @@ public class XMLCatalog extends DataType * itself a reference to another catalog -- that is, a catalog * cannot both refer to another and contain elements or * other attributes. + * + * @param r an Ant reference containing a classpath to be used as + * the catalog path. */ public void setCatalogPathRef(Reference r) { if (isReference()) { throw tooManyAttributes(); } createCatalogPath().setRefid(r); - setChecked( false ); + setChecked(false); } @@ -338,7 +351,7 @@ public class XMLCatalog extends DataType } getElements().addElement(dtd); - setChecked( false ); + setChecked(false); } /** @@ -384,7 +397,7 @@ public class XMLCatalog extends DataType // Append the catalog path of the nested catalog Path nestedCatalogPath = catalog.getCatalogPath(); createCatalogPath().append(nestedCatalogPath); - setChecked( false ); + setChecked(false); } /** @@ -439,8 +452,8 @@ public class XMLCatalog extends DataType getCatalogResolver().resolveEntity(publicId, systemId); 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; @@ -467,11 +480,11 @@ public class XMLCatalog extends DataType log("resolve: '" + uri + "' with base: '" + base + "'", Project.MSG_DEBUG); - source = (SAXSource)getCatalogResolver().resolve(uri, base); + source = (SAXSource) getCatalogResolver().resolve(uri, base); 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 // setEntityResolver (see setEntityResolver javadoc comment) @@ -481,14 +494,12 @@ public class XMLCatalog extends DataType try { if (base == null) { baseURL = fileUtils.getFileURL(getProject().getBaseDir()); - } - else { + } else { baseURL = new URL(base); } URL url = (uri.length() == 0 ? baseURL : new URL(baseURL, uri)); source.setInputSource(new InputSource(url.toString())); - } - catch (MalformedURLException ex) { + } catch (MalformedURLException ex) { // At this point we are probably in failure mode, but // try to use the bare URI as a last gasp source.setInputSource(new InputSource(uri)); @@ -530,19 +541,17 @@ public class XMLCatalog extends DataType // available, so use it. // catalogResolver = new ApacheResolver(clazz, obj); - } - catch (Throwable ex) { + } catch (Throwable ex) { // // The xml-commons resolver library is not // available, so we can't use it. // 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); } } @@ -577,11 +586,9 @@ public class XMLCatalog extends DataType spFactory.setNamespaceAware(true); try { reader = spFactory.newSAXParser().getXMLReader(); - } - catch (ParserConfigurationException ex) { + } catch (ParserConfigurationException ex) { throw new TransformerException(ex); - } - catch (SAXException ex) { + } catch (SAXException ex) { throw new TransformerException(ex); } } @@ -603,7 +610,7 @@ public class XMLCatalog extends DataType while (enum.hasMoreElements()) { Object o = enum.nextElement(); if (o instanceof ResourceLocation) { - element = (ResourceLocation)o; + element = (ResourceLocation) o; if (element.getPublicId().equals(publicId)) { return element; } @@ -652,8 +659,7 @@ public class XMLCatalog extends DataType } else { try { baseURL = fileUtils.getFileURL(getProject().getBaseDir()); - } - catch (MalformedURLException ex) { + } catch (MalformedURLException ex) { throw new BuildException("Project basedir cannot be converted to a URL"); } } @@ -663,8 +669,7 @@ public class XMLCatalog extends DataType try { url = new URL(baseURL, uri); - } - catch (MalformedURLException ex) { + } catch (MalformedURLException ex) { // ignore } @@ -678,11 +683,11 @@ public class XMLCatalog extends DataType source = new InputSource(new FileInputStream(resFile)); String sysid = JAXPUtils.getSystemId(resFile); 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 - } catch(IOException ex) { + } catch (IOException ex) { // ignore } } @@ -721,8 +726,8 @@ public class XMLCatalog extends DataType URL entryURL = loader.getResource(matchingEntry.getLocation()); String sysid = entryURL.toExternalForm(); 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; @@ -749,8 +754,7 @@ public class XMLCatalog extends DataType } else { try { baseURL = fileUtils.getFileURL(getProject().getBaseDir()); - } - catch (MalformedURLException ex) { + } catch (MalformedURLException ex) { throw new BuildException("Project basedir cannot be converted to a URL"); } } @@ -760,8 +764,7 @@ public class XMLCatalog extends DataType try { url = new URL(baseURL, uri); - } - catch (MalformedURLException ex) { + } catch (MalformedURLException ex) { // ignore } @@ -772,10 +775,10 @@ public class XMLCatalog extends DataType source = new InputSource(is); String sysid = url.toExternalForm(); 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 } } @@ -816,9 +819,9 @@ public class XMLCatalog extends DataType 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); result = filesystemLookup(matchingEntry); @@ -844,9 +847,9 @@ public class XMLCatalog extends DataType 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); // @@ -865,8 +868,7 @@ public class XMLCatalog extends DataType URL baseURL = new URL(base); entryCopy = new ResourceLocation(); entryCopy.setBase(baseURL); - } - catch (MalformedURLException ex) { + } catch (MalformedURLException ex) { // ignore } } @@ -926,24 +928,23 @@ public class XMLCatalog extends DataType setXMLCatalog = resolverImplClass.getMethod("setXMLCatalog", new Class[] - { XMLCatalog.class }); + {XMLCatalog.class}); parseCatalog = resolverImplClass.getMethod("parseCatalog", new Class[] - { String.class }); + {String.class}); resolveEntity = resolverImplClass.getMethod("resolveEntity", new Class[] - { String.class, String.class }); + {String.class, String.class}); resolve = resolverImplClass.getMethod("resolve", new Class[] - { String.class, String.class }); - } - catch (NoSuchMethodException ex) { + {String.class, String.class}); + } catch (NoSuchMethodException ex) { throw new BuildException(ex); } @@ -961,9 +962,9 @@ public class XMLCatalog extends DataType 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); result = filesystemLookup(matchingEntry); @@ -975,16 +976,14 @@ public class XMLCatalog extends DataType if (result == null) { try { result = - (InputSource)resolveEntity.invoke(resolverImpl, + (InputSource) resolveEntity.invoke(resolverImpl, new Object[] - { publicId, systemId }); - } - catch (Exception ex) { + {publicId, systemId}); + } catch (Exception ex) { throw new BuildException(ex); } } - } - else { + } else { // // We didn't match a ResourceLocation, but since we // only support PUBLIC and URI entry types internally, @@ -995,11 +994,10 @@ public class XMLCatalog extends DataType // try { result = - (InputSource)resolveEntity.invoke(resolverImpl, + (InputSource) resolveEntity.invoke(resolverImpl, new Object[] - { publicId, systemId }); - } - catch (Exception ex) { + {publicId, systemId}); + } catch (Exception ex) { throw new BuildException(ex); } } @@ -1019,9 +1017,9 @@ public class XMLCatalog extends DataType 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); // @@ -1042,8 +1040,7 @@ public class XMLCatalog extends DataType URL baseURL = new URL(base); entryCopy = new ResourceLocation(); entryCopy.setBase(baseURL); - } - catch (MalformedURLException ex) { + } catch (MalformedURLException ex) { // ignore } } @@ -1061,16 +1058,14 @@ public class XMLCatalog extends DataType } else { try { result = - (SAXSource)resolve.invoke(resolverImpl, + (SAXSource) resolve.invoke(resolverImpl, new Object[] - { href, base }); - } - catch (Exception ex) { + {href, base}); + } catch (Exception ex) { throw new BuildException(ex); } } - } - else { + } else { // // We didn't match a ResourceLocation, but since we // only support PUBLIC and URI entry types internally, @@ -1081,11 +1076,10 @@ public class XMLCatalog extends DataType // try { result = - (SAXSource)resolve.invoke(resolverImpl, + (SAXSource) resolve.invoke(resolverImpl, new Object[] - { href, base }); - } - catch (Exception ex) { + {href, base}); + } catch (Exception ex) { throw new BuildException(ex); } } @@ -1101,32 +1095,31 @@ public class XMLCatalog extends DataType */ private void processExternalCatalogs() { - if (externalCatalogsProcessed == false) { + if (!externalCatalogsProcessed) { try { setXMLCatalog.invoke(resolverImpl, new Object[] - { XMLCatalog.this }); - } - catch (Exception ex) { + {XMLCatalog.this}); + } catch (Exception ex) { throw new BuildException(ex); } // Parse each catalog listed in nested elements Path catPath = getCatalogPath(); if (catPath != null) { - log("Using catalogpath '" + getCatalogPath()+"'", Project.MSG_DEBUG); + log("Using catalogpath '" + getCatalogPath() + "'", + Project.MSG_DEBUG); 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]); - log("Parsing "+catFile, Project.MSG_DEBUG); + log("Parsing " + catFile, Project.MSG_DEBUG); try { parseCatalog.invoke(resolverImpl, new Object[] - { catFile.getPath() }); - } - catch (Exception ex) { + {catFile.getPath()}); + } catch (Exception ex) { throw new BuildException(ex); } } diff --git a/src/main/org/apache/tools/ant/types/ZipFileSet.java b/src/main/org/apache/tools/ant/types/ZipFileSet.java index 65e9b57f2..d3aaaea7a 100644 --- a/src/main/org/apache/tools/ant/types/ZipFileSet.java +++ b/src/main/org/apache/tools/ant/types/ZipFileSet.java @@ -160,7 +160,7 @@ public class ZipFileSet extends FileSet { */ public File getSrc(Project p) { if (isReference()) { - return ((ZipFileSet)getRef(p)).getSrc(p); + return ((ZipFileSet) getRef(p)).getSrc(p); } return srcFile; } @@ -186,7 +186,7 @@ public class ZipFileSet extends FileSet { */ public String getPrefix(Project p) { if (isReference()) { - return ((ZipFileSet)getRef(p)).getPrefix(p); + return ((ZipFileSet) getRef(p)).getPrefix(p); } return prefix; } @@ -212,7 +212,7 @@ public class ZipFileSet extends FileSet { */ public String getFullpath(Project p) { if (isReference()) { - return ((ZipFileSet)getRef(p)).getFullpath(p); + return ((ZipFileSet) getRef(p)).getFullpath(p); } return fullpath; } @@ -259,7 +259,7 @@ public class ZipFileSet extends FileSet { */ public int getFileMode(Project p) { if (isReference()) { - return ((ZipFileSet)getRef(p)).getFileMode(p); + return ((ZipFileSet) getRef(p)).getFileMode(p); } return fileMode; } @@ -271,7 +271,7 @@ public class ZipFileSet extends FileSet { */ public boolean hasFileModeBeenSet() { if (isReference()) { - return ((ZipFileSet)getRef(getProject())).hasFileModeBeenSet(); + return ((ZipFileSet) getRef(getProject())).hasFileModeBeenSet(); } return fileModeHasBeenSet; } @@ -297,7 +297,7 @@ public class ZipFileSet extends FileSet { */ public int getDirMode(Project p) { if (isReference()) { - return ((ZipFileSet)getRef(p)).getDirMode(p); + return ((ZipFileSet) getRef(p)).getDirMode(p); } return dirMode; } @@ -309,7 +309,7 @@ public class ZipFileSet extends FileSet { */ public boolean hasDirModeBeenSet() { if (isReference()) { - return ((ZipFileSet)getRef(getProject())).hasDirModeBeenSet(); + return ((ZipFileSet) getRef(getProject())).hasDirModeBeenSet(); } return dirModeHasBeenSet; } diff --git a/src/main/org/apache/tools/ant/types/ZipScanner.java b/src/main/org/apache/tools/ant/types/ZipScanner.java index 50fe22509..81ed1e3bd 100644 --- a/src/main/org/apache/tools/ant/types/ZipScanner.java +++ b/src/main/org/apache/tools/ant/types/ZipScanner.java @@ -55,7 +55,6 @@ package org.apache.tools.ant.types; import java.io.File; -import java.io.FileInputStream; import java.io.IOException; import java.util.Vector; import java.util.Hashtable; @@ -131,8 +130,8 @@ public class ZipScanner extends DirectoryScanner { Vector myvector = new Vector(); // first check if the archive needs to be scanned again 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())) { myvector.addElement(myresource.getName()); } @@ -155,11 +154,11 @@ public class ZipScanner extends DirectoryScanner { */ public String[] getIncludedDirectories() { if (srcFile != null) { - Vector myvector=new Vector(); + Vector myvector = new Vector(); // first check if the archive needs to be scanned again 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())) { myvector.addElement(myresource.getName()); } @@ -261,8 +260,8 @@ public class ZipScanner extends DirectoryScanner { while (enum.hasMoreElements()) { entry = (ZipEntry) enum.nextElement(); myentries.put(new String(entry.getName()), - new Resource(entry.getName(), true, - entry.getTime(), + new Resource(entry.getName(), true, + entry.getTime(), entry.isDirectory())); } } finally { diff --git a/src/main/org/apache/tools/zip/ZipEntry.java b/src/main/org/apache/tools/zip/ZipEntry.java index a3fb96a0a..961891be6 100644 --- a/src/main/org/apache/tools/zip/ZipEntry.java +++ b/src/main/org/apache/tools/zip/ZipEntry.java @@ -114,7 +114,7 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable { if (crc > 0) { setCrc(crc); } - + byte[] extra = entry.getExtra(); if (extra != null) { setExtraFields(ExtraFieldUtils.parse(extra)); @@ -168,7 +168,7 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable { if (crc > 0) { e.setCrc(crc); } - + e.extraFields = (Vector) extraFields.clone(); e.setInternalAttributes(getInternalAttributes()); e.setExternalAttributes(getExternalAttributes()); @@ -484,8 +484,8 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable { synchronized (lockReflection) { triedToGetMethod = true; try { - setCompressedSizeMethod = - java.util.zip.ZipEntry.class.getMethod("setCompressedSize", + setCompressedSizeMethod = + java.util.zip.ZipEntry.class.getMethod("setCompressedSize", new Class[] {Long.TYPE}); } catch (NoSuchMethodException nse) { } diff --git a/src/main/org/apache/tools/zip/ZipFile.java b/src/main/org/apache/tools/zip/ZipFile.java index dfc6d8a73..e3a0fee39 100644 --- a/src/main/org/apache/tools/zip/ZipFile.java +++ b/src/main/org/apache/tools/zip/ZipFile.java @@ -220,7 +220,7 @@ public class ZipFile { /** * 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. */ public InputStream getInputStream(ZipEntry ze) @@ -229,7 +229,7 @@ public class ZipFile { if (start == null) { return null; } - BoundedInputStream bis = + BoundedInputStream bis = new BoundedInputStream(start.longValue(), ze.getCompressedSize()); switch (ze.getMethod()) { case ZipEntry.STORED: @@ -269,7 +269,7 @@ public class ZipFile { * the central directory alone, but not the data that requires the * local file header or additional data to be read.

*/ - private void populateFromCentralDirectory() + private void populateFromCentralDirectory() throws IOException { positionAtCentralDirectory(); @@ -372,7 +372,7 @@ public class ZipFile { * it and positions the stream at the first central directory * record. */ - private void positionAtCentralDirectory() + private void positionAtCentralDirectory() throws IOException { long off = archive.length() - MIN_EOCD_SIZE; archive.seek(off); @@ -443,7 +443,7 @@ public class ZipFile { byte[] localExtraData = new byte[extraFieldLen]; archive.readFully(localExtraData); ze.setExtra(localExtraData); - dataOffsets.put(ze, + dataOffsets.put(ze, new Long(offset + LFH_OFFSET_FOR_FILENAME_LENGTH + 2 + 2 + fileNameLen + extraFieldLen)); } @@ -551,7 +551,7 @@ public class ZipFile { * Inflater's javadocs. */ void addDummy() { - addDummyByte = true; + addDummyByte = true; } } diff --git a/src/main/org/apache/tools/zip/ZipLong.java b/src/main/org/apache/tools/zip/ZipLong.java index 7c4a92378..2a1a3af89 100644 --- a/src/main/org/apache/tools/zip/ZipLong.java +++ b/src/main/org/apache/tools/zip/ZipLong.java @@ -89,7 +89,7 @@ public final class ZipLong implements Cloneable { * @since 1.1 */ 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 + 1] << 8) & 0xFF00; value += (bytes[offset] & 0xFF); @@ -138,5 +138,4 @@ public final class ZipLong implements Cloneable { public int hashCode() { return (int) value; } - -}// ZipLong +} diff --git a/src/main/org/apache/tools/zip/ZipOutputStream.java b/src/main/org/apache/tools/zip/ZipOutputStream.java index 8e1ed749c..a2c6d1cf2 100644 --- a/src/main/org/apache/tools/zip/ZipOutputStream.java +++ b/src/main/org/apache/tools/zip/ZipOutputStream.java @@ -234,7 +234,7 @@ public class ZipOutputStream extends DeflaterOutputStream { * The encoding to use for filenames and the file comment. * * @return null if using the platform's default character encoding. - * + * * @since 1.3 */ public String getEncoding() { @@ -294,17 +294,17 @@ public class ZipOutputStream extends DeflaterOutputStream { } else { if (entry.getCrc() != realCrc) { throw new ZipException("bad CRC checksum for entry " - + entry.getName() + ": " + + entry.getName() + ": " + Long.toHexString(entry.getCrc()) - + " instead of " + + " instead of " + Long.toHexString(realCrc)); } if (entry.getSize() != written - dataStart) { throw new ZipException("bad size for entry " - + entry.getName() + ": " + + entry.getName() + ": " + entry.getSize() - + " instead of " + + " instead of " + (written - dataStart)); } @@ -328,7 +328,7 @@ public class ZipOutputStream extends DeflaterOutputStream { if (entry.getMethod() == -1) { // not specified entry.setMethod(method); } - + if (entry.getTime() == -1) { // not specified entry.setTime(System.currentTimeMillis()); } @@ -344,7 +344,7 @@ public class ZipOutputStream extends DeflaterOutputStream { } else if (hasCompressionLevelChanged) { def.setLevel(level); hasCompressionLevelChanged = false; - } + } writeLocalFileHeader(entry); } @@ -471,12 +471,12 @@ public class ZipOutputStream extends DeflaterOutputStream { out.write((new ZipLong(ze.getSize())).getBytes()); } written += 12; - + // file name length byte[] name = getBytes(ze.getName()); out.write((new ZipShort(name.length)).getBytes()); written += 2; - + // extra field length byte[] extra = ze.getLocalFileDataExtra(); 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.getSize())).getBytes()); written += 12; - + // file name length byte[] name = getBytes(ze.getName()); out.write((new ZipShort(name.length)).getBytes()); written += 2; - + // extra field length byte[] extra = ze.getCentralDirectoryExtra(); out.write((new ZipShort(extra.length)).getBytes()); @@ -571,7 +571,7 @@ public class ZipOutputStream extends DeflaterOutputStream { byte[] comment = getBytes(comm); out.write((new ZipShort(comment.length)).getBytes()); written += 2; - + // disk number start out.write(ZERO); written += 2; @@ -608,7 +608,7 @@ public class ZipOutputStream extends DeflaterOutputStream { */ protected void writeCentralDirectoryEnd() throws IOException { out.write(EOCD_SIG.getBytes()); - + // disk numbers out.write(ZERO); out.write(ZERO); @@ -654,12 +654,12 @@ public class ZipOutputStream extends DeflaterOutputStream { | (time.getHours() << 11) | (time.getMinutes() << 5) | (time.getSeconds() >> 1); - + byte[] result = new byte[4]; result[0] = (byte) ((value & 0xFF)); result[1] = (byte) ((value & 0xFF00) >> 8); result[2] = (byte) ((value & 0xFF0000) >> 16); - result[3] = (byte) ((value & 0xFF000000l) >> 24); + result[3] = (byte) ((value & 0xFF000000L) >> 24); return new ZipLong(result); } diff --git a/src/main/org/apache/tools/zip/ZipShort.java b/src/main/org/apache/tools/zip/ZipShort.java index 856e9595c..74e84c702 100644 --- a/src/main/org/apache/tools/zip/ZipShort.java +++ b/src/main/org/apache/tools/zip/ZipShort.java @@ -134,5 +134,4 @@ public final class ZipShort implements Cloneable { public int hashCode() { return value; } - -}// ZipShort +}