You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by jh...@apache.org on 2014/07/04 09:17:51 UTC
[09/17] checkstyle
http://git-wip-us.apache.org/repos/asf/ant/blob/1b76f1b6/src/main/org/apache/tools/ant/util/LineOrientedOutputStreamRedirector.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/LineOrientedOutputStreamRedirector.java b/src/main/org/apache/tools/ant/util/LineOrientedOutputStreamRedirector.java
index 6ce302d..a4e6d8e 100644
--- a/src/main/org/apache/tools/ant/util/LineOrientedOutputStreamRedirector.java
+++ b/src/main/org/apache/tools/ant/util/LineOrientedOutputStreamRedirector.java
@@ -26,12 +26,12 @@ import java.io.OutputStream;
* If the source stream doesn't end with a end of line, one will be added. This
* is particularly useful in combination with the OutputStreamFunneler so each
* funneled stream get its line.
- *
+ *
* @since Ant 1.8.3
*/
public class LineOrientedOutputStreamRedirector
- extends
- LineOrientedOutputStream {
+ extends LineOrientedOutputStream {
+
private OutputStream stream;
// these should be in the ASCII range and hopefully are single bytes
@@ -42,22 +42,26 @@ public class LineOrientedOutputStreamRedirector
public LineOrientedOutputStreamRedirector(OutputStream stream) {
this.stream = stream;
}
-
- protected void processLine(byte[] b) throws IOException {
+
+ @Override
+ protected void processLine(byte[] b) throws IOException {
stream.write(b);
stream.write(EOL);
}
-
- protected void processLine(String line) throws IOException {
+
+ @Override
+ protected void processLine(String line) throws IOException {
stream.write((line + System.getProperty("line.separator")).getBytes());
}
-
- public void close() throws IOException {
+
+ @Override
+ public void close() throws IOException {
super.close();
stream.close();
}
- public void flush() throws IOException {
+ @Override
+ public void flush() throws IOException {
super.flush();
stream.flush();
}
http://git-wip-us.apache.org/repos/asf/ant/blob/1b76f1b6/src/main/org/apache/tools/ant/util/ResourceUtils.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/ResourceUtils.java b/src/main/org/apache/tools/ant/util/ResourceUtils.java
index 50c34c2..891447c 100644
--- a/src/main/org/apache/tools/ant/util/ResourceUtils.java
+++ b/src/main/org/apache/tools/ant/util/ResourceUtils.java
@@ -88,10 +88,10 @@ public class ResourceUtils {
* copied or processed, because the targets are out of date or do
* not exist.
*/
- public static Resource[] selectOutOfDateSources(ProjectComponent logTo,
- Resource[] source,
- FileNameMapper mapper,
- ResourceFactory targets) {
+ public static Resource[] selectOutOfDateSources(final ProjectComponent logTo,
+ final Resource[] source,
+ final FileNameMapper mapper,
+ final ResourceFactory targets) {
return selectOutOfDateSources(logTo, source, mapper, targets,
FILE_UTILS.getFileTimestampGranularity());
}
@@ -113,14 +113,14 @@ public class ResourceUtils {
* not exist.
* @since Ant 1.6.2
*/
- public static Resource[] selectOutOfDateSources(ProjectComponent logTo,
- Resource[] source,
- FileNameMapper mapper,
- ResourceFactory targets,
- long granularity) {
- Union u = new Union();
+ public static Resource[] selectOutOfDateSources(final ProjectComponent logTo,
+ final Resource[] source,
+ final FileNameMapper mapper,
+ final ResourceFactory targets,
+ final long granularity) {
+ final Union u = new Union();
u.addAll(Arrays.asList(source));
- ResourceCollection rc
+ final ResourceCollection rc
= selectOutOfDateSources(logTo, u, mapper, targets, granularity);
return rc.size() == 0 ? new Resource[0] : ((Union) rc).listResources();
}
@@ -137,18 +137,20 @@ public class ResourceUtils {
* @return ResourceCollection.
* @since Ant 1.7
*/
- public static ResourceCollection selectOutOfDateSources(ProjectComponent logTo,
- ResourceCollection source,
- FileNameMapper mapper,
- ResourceFactory targets,
+ public static ResourceCollection selectOutOfDateSources(final ProjectComponent logTo,
+ final ResourceCollection source,
+ final FileNameMapper mapper,
+ final ResourceFactory targets,
final long granularity) {
logFuture(logTo, source, granularity);
- ResourceSelectorProvider p =
+ final ResourceSelectorProvider p =
new ResourceSelectorProvider() {
- public ResourceSelector
+ @Override
+ public ResourceSelector
getTargetSelectorForSource(final Resource sr) {
return new ResourceSelector() {
- public boolean isSelected(Resource target) {
+ @Override
+ public boolean isSelected(final Resource target) {
/* Extra I/O, probably wasted:
if (target.isDirectory()) {
return false;
@@ -166,7 +168,7 @@ public class ResourceUtils {
/**
* Tells which sources should be reprocessed because the given
* selector selects at least one target.
- *
+ *
* @param logTo where to send (more or less) interesting output.
* @param source ResourceCollection.
* @param mapper filename mapper indicating how to find the target Resources.
@@ -177,19 +179,19 @@ public class ResourceUtils {
* @return ResourceCollection.
* @since Ant 1.8.0
*/
- public static ResourceCollection selectSources(ProjectComponent logTo,
+ public static ResourceCollection selectSources(final ProjectComponent logTo,
ResourceCollection source,
- FileNameMapper mapper,
- ResourceFactory targets,
- ResourceSelectorProvider selector) {
+ final FileNameMapper mapper,
+ final ResourceFactory targets,
+ final ResourceSelectorProvider selector) {
if (source.size() == 0) {
logTo.log("No sources found.", Project.MSG_VERBOSE);
return Resources.NONE;
}
source = Union.getInstance(source);
- Union result = new Union();
- for (Resource sr : source) {
+ final Union result = new Union();
+ for (final Resource sr : source) {
String srName = sr.getName();
srName = srName == null
? srName : srName.replace('/', File.separatorChar);
@@ -197,7 +199,7 @@ public class ResourceUtils {
String[] targetnames = null;
try {
targetnames = mapper.mapFileName(srName);
- } catch (Exception e) {
+ } catch (final Exception e) {
logTo.log("Caught " + e + " mapping resource " + sr,
Project.MSG_VERBOSE);
}
@@ -211,18 +213,18 @@ public class ResourceUtils {
targetnames[i] = "(no name)";
}
}
- Union targetColl = new Union();
+ final Union targetColl = new Union();
for (int i = 0; i < targetnames.length; i++) {
targetColl.add(targets.getResource(
targetnames[i].replace(File.separatorChar, '/')));
}
//find the out-of-date targets:
- Restrict r = new Restrict();
+ final Restrict r = new Restrict();
r.add(selector.getTargetSelectorForSource(sr));
r.add(targetColl);
if (r.size() > 0) {
result.add(sr);
- Resource t = r.iterator().next();
+ final Resource t = r.iterator().next();
logTo.log(sr.getName() + " added as " + t.getName()
+ (t.isExists() ? " is outdated." : " doesn\'t exist."),
Project.MSG_VERBOSE);
@@ -250,7 +252,7 @@ public class ResourceUtils {
*
* @since Ant 1.7
*/
- public static void copyResource(Resource source, Resource dest) throws IOException {
+ public static void copyResource(final Resource source, final Resource dest) throws IOException {
copyResource(source, dest, null);
}
@@ -268,7 +270,7 @@ public class ResourceUtils {
*
* @since Ant 1.7
*/
- public static void copyResource(Resource source, Resource dest, Project project)
+ public static void copyResource(final Resource source, final Resource dest, final Project project)
throws IOException {
copyResource(source, dest, null, null, false,
false, null, null, project);
@@ -301,11 +303,11 @@ public class ResourceUtils {
*
* @since Ant 1.7
*/
- public static void copyResource(Resource source, Resource dest,
- FilterSetCollection filters, Vector filterChains,
- boolean overwrite, boolean preserveLastModified,
- String inputEncoding, String outputEncoding,
- Project project)
+ public static void copyResource(final Resource source, final Resource dest,
+ final FilterSetCollection filters, final Vector filterChains,
+ final boolean overwrite, final boolean preserveLastModified,
+ final String inputEncoding, final String outputEncoding,
+ final Project project)
throws IOException {
copyResource(source, dest, filters, filterChains, overwrite, preserveLastModified, false, inputEncoding, outputEncoding, project);
}
@@ -338,12 +340,12 @@ public class ResourceUtils {
*
* @since Ant 1.8
*/
- public static void copyResource(Resource source, Resource dest,
- FilterSetCollection filters, Vector filterChains,
- boolean overwrite, boolean preserveLastModified,
- boolean append,
- String inputEncoding, String outputEncoding,
- Project project)
+ public static void copyResource(final Resource source, final Resource dest,
+ final FilterSetCollection filters, final Vector filterChains,
+ final boolean overwrite, final boolean preserveLastModified,
+ final boolean append,
+ final String inputEncoding, final String outputEncoding,
+ final Project project)
throws IOException {
copyResource(source, dest, filters, filterChains, overwrite,
preserveLastModified, append, inputEncoding,
@@ -378,12 +380,12 @@ public class ResourceUtils {
*
* @since Ant 1.8.2
*/
- public static void copyResource(Resource source, Resource dest,
- FilterSetCollection filters, Vector filterChains,
- boolean overwrite, boolean preserveLastModified,
- boolean append,
- String inputEncoding, String outputEncoding,
- Project project, boolean force)
+ public static void copyResource(final Resource source, final Resource dest,
+ final FilterSetCollection filters, final Vector filterChains,
+ final boolean overwrite, final boolean preserveLastModified,
+ final boolean append,
+ final String inputEncoding, final String outputEncoding,
+ final Project project, final boolean force)
throws IOException {
if (!(overwrite || SelectorUtils.isOutOfDate(source, dest, FileUtils.getFileUtils()
.getFileTimestampGranularity()))) {
@@ -429,12 +431,12 @@ public class ResourceUtils {
boolean copied = false;
if (source.as(FileProvider.class) != null
&& destFile != null && !append) {
- File sourceFile =
+ final File sourceFile =
source.as(FileProvider.class).getFile();
try {
copyUsingFileChannels(sourceFile, destFile);
copied = true;
- } catch (IOException ex) {
+ } catch (final IOException ex) {
project.log("Attempt to copy " + sourceFile
+ " to " + destFile + " using NIO Channels"
+ " failed due to '" + ex.getMessage()
@@ -447,7 +449,7 @@ public class ResourceUtils {
}
}
if (preserveLastModified) {
- Touchable t = dest.as(Touchable.class);
+ final Touchable t = dest.as(Touchable.class);
if (t != null) {
setLastModified(t, source.getLastModified());
}
@@ -464,7 +466,7 @@ public class ResourceUtils {
* if this is -1, the current time is used.
* @since Ant 1.7
*/
- public static void setLastModified(Touchable t, long time) {
+ public static void setLastModified(final Touchable t, final long time) {
t.touch((time < 0) ? System.currentTimeMillis() : time);
}
@@ -481,7 +483,7 @@ public class ResourceUtils {
* @throws IOException if the Resources cannot be read.
* @since Ant 1.7
*/
- public static boolean contentEquals(Resource r1, Resource r2, boolean text) throws IOException {
+ public static boolean contentEquals(final Resource r1, final Resource r2, final boolean text) throws IOException {
if (r1.isExists() != r2.isExists()) {
return false;
}
@@ -499,8 +501,8 @@ public class ResourceUtils {
return true;
}
if (!text) {
- long s1 = r1.getSize();
- long s2 = r2.getSize();
+ final long s1 = r1.getSize();
+ final long s2 = r2.getSize();
if (s1 != Resource.UNKNOWN_SIZE && s2 != Resource.UNKNOWN_SIZE
&& s1 != s2) {
return false;
@@ -522,20 +524,20 @@ public class ResourceUtils {
* @throws IOException if the Resources cannot be read.
* @since Ant 1.7
*/
- public static int compareContent(Resource r1, Resource r2, boolean text) throws IOException {
+ public static int compareContent(final Resource r1, final Resource r2, final boolean text) throws IOException {
if (r1.equals(r2)) {
return 0;
}
- boolean e1 = r1.isExists();
- boolean e2 = r2.isExists();
+ final boolean e1 = r1.isExists();
+ final boolean e2 = r2.isExists();
if (!(e1 || e2)) {
return 0;
}
if (e1 != e2) {
return e1 ? 1 : -1;
}
- boolean d1 = r1.isDirectory();
- boolean d2 = r2.isDirectory();
+ final boolean d1 = r1.isDirectory();
+ final boolean d2 = r2.isDirectory();
if (d1 && d2) {
return 0;
}
@@ -554,11 +556,11 @@ public class ResourceUtils {
* FileResource with fileProvider's file.
* @since Ant 1.8
*/
- public static FileResource asFileResource(FileProvider fileProvider) {
+ public static FileResource asFileResource(final FileProvider fileProvider) {
if (fileProvider instanceof FileResource || fileProvider == null) {
return (FileResource) fileProvider;
}
- FileResource result = new FileResource(fileProvider.getFile());
+ final FileResource result = new FileResource(fileProvider.getFile());
result.setProject(Project.getProject(fileProvider));
return result;
}
@@ -578,7 +580,7 @@ public class ResourceUtils {
* @throws IOException if the Resources cannot be read.
* @since Ant 1.7
*/
- private static int binaryCompare(Resource r1, Resource r2) throws IOException {
+ private static int binaryCompare(final Resource r1, final Resource r2) throws IOException {
InputStream in1 = null;
InputStream in2 = null;
try {
@@ -586,7 +588,7 @@ public class ResourceUtils {
in2 = new BufferedInputStream(r2.getInputStream());
for (int b1 = in1.read(); b1 != -1; b1 = in1.read()) {
- int b2 = in2.read();
+ final int b2 = in2.read();
if (b1 != b2) {
return b1 > b2 ? 1 : -1;
}
@@ -608,7 +610,7 @@ public class ResourceUtils {
* @throws IOException if the Resources cannot be read.
* @since Ant 1.7
*/
- private static int textCompare(Resource r1, Resource r2) throws IOException {
+ private static int textCompare(final Resource r1, final Resource r2) throws IOException {
BufferedReader in1 = null;
BufferedReader in2 = null;
try {
@@ -617,7 +619,7 @@ public class ResourceUtils {
String expected = in1.readLine();
while (expected != null) {
- String actual = in2.readLine();
+ final String actual = in2.readLine();
if (!expected.equals(actual)) {
if (actual == null) {
return 1;
@@ -640,27 +642,27 @@ public class ResourceUtils {
* @param granularity the timestamp granularity to use.
* @since Ant 1.7
*/
- private static void logFuture(ProjectComponent logTo,
- ResourceCollection rc, long granularity) {
- long now = System.currentTimeMillis() + granularity;
- Date sel = new Date();
+ private static void logFuture(final ProjectComponent logTo,
+ final ResourceCollection rc, final long granularity) {
+ final long now = System.currentTimeMillis() + granularity;
+ final Date sel = new Date();
sel.setMillis(now);
sel.setWhen(TimeComparison.AFTER);
- Restrict future = new Restrict();
+ final Restrict future = new Restrict();
future.add(sel);
future.add(rc);
- for (Resource r : future) {
+ for (final Resource r : future) {
logTo.log("Warning: " + r.getName() + " modified in the future.", Project.MSG_WARN);
}
}
- private static void copyWithFilterSets(Resource source, Resource dest,
- FilterSetCollection filters,
- Vector filterChains,
- boolean filterChainsAvailable,
- boolean append, String inputEncoding,
- String outputEncoding,
- Project project)
+ private static void copyWithFilterSets(final Resource source, final Resource dest,
+ final FilterSetCollection filters,
+ final Vector filterChains,
+ final boolean filterChainsAvailable,
+ final boolean append, final String inputEncoding,
+ final String outputEncoding,
+ final Project project)
throws IOException {
BufferedReader in = null;
BufferedWriter out = null;
@@ -673,7 +675,7 @@ public class ResourceUtils {
inputEncoding);
}
in = new BufferedReader(isr);
- OutputStream os = getOutputStream(dest, append, project);
+ final OutputStream os = getOutputStream(dest, append, project);
OutputStreamWriter osw;
if (outputEncoding == null) {
osw = new OutputStreamWriter(os);
@@ -682,15 +684,15 @@ public class ResourceUtils {
}
out = new BufferedWriter(osw);
if (filterChainsAvailable) {
- ChainReaderHelper crh = new ChainReaderHelper();
+ final ChainReaderHelper crh = new ChainReaderHelper();
crh.setBufferSize(FileUtils.BUF_SIZE);
crh.setPrimaryReader(in);
crh.setFilterChains(filterChains);
crh.setProject(project);
- Reader rdr = crh.getAssembledReader();
+ final Reader rdr = crh.getAssembledReader();
in = new BufferedReader(rdr);
}
- LineTokenizer lineTokenizer = new LineTokenizer();
+ final LineTokenizer lineTokenizer = new LineTokenizer();
lineTokenizer.setIncludeDelims(true);
String newline = null;
String line = lineTokenizer.getToken(in);
@@ -711,14 +713,14 @@ public class ResourceUtils {
}
}
- private static void copyWithFilterChainsOrTranscoding(Resource source,
- Resource dest,
- Vector filterChains,
- boolean filterChainsAvailable,
- boolean append,
- String inputEncoding,
- String outputEncoding,
- Project project)
+ private static void copyWithFilterChainsOrTranscoding(final Resource source,
+ final Resource dest,
+ final Vector filterChains,
+ final boolean filterChainsAvailable,
+ final boolean append,
+ final String inputEncoding,
+ final String outputEncoding,
+ final Project project)
throws IOException {
BufferedReader in = null;
BufferedWriter out = null;
@@ -731,7 +733,7 @@ public class ResourceUtils {
inputEncoding);
}
in = new BufferedReader(isr);
- OutputStream os = getOutputStream(dest, append, project);
+ final OutputStream os = getOutputStream(dest, append, project);
OutputStreamWriter osw;
if (outputEncoding == null) {
osw = new OutputStreamWriter(os);
@@ -740,17 +742,17 @@ public class ResourceUtils {
}
out = new BufferedWriter(osw);
if (filterChainsAvailable) {
- ChainReaderHelper crh = new ChainReaderHelper();
+ final ChainReaderHelper crh = new ChainReaderHelper();
crh.setBufferSize(FileUtils.BUF_SIZE);
crh.setPrimaryReader(in);
crh.setFilterChains(filterChains);
crh.setProject(project);
- Reader rdr = crh.getAssembledReader();
+ final Reader rdr = crh.getAssembledReader();
in = new BufferedReader(rdr);
}
- char[] buffer = new char[FileUtils.BUF_SIZE];
+ final char[] buffer = new char[FileUtils.BUF_SIZE];
while (true) {
- int nRead = in.read(buffer, 0, buffer.length);
+ final int nRead = in.read(buffer, 0, buffer.length);
if (nRead == -1) {
break;
}
@@ -762,11 +764,11 @@ public class ResourceUtils {
}
}
- private static void copyUsingFileChannels(File sourceFile,
- File destFile)
+ private static void copyUsingFileChannels(final File sourceFile,
+ final File destFile)
throws IOException {
- File parent = destFile.getParentFile();
+ final File parent = destFile.getParentFile();
if (parent != null && !parent.isDirectory()
&& !(parent.mkdirs() || parent.isDirectory())) {
throw new IOException("failed to create the parent directory"
@@ -781,14 +783,14 @@ public class ResourceUtils {
try {
in = new FileInputStream(sourceFile);
out = new FileOutputStream(destFile);
-
+
srcChannel = in.getChannel();
destChannel = out.getChannel();
-
+
long position = 0;
- long count = srcChannel.size();
+ final long count = srcChannel.size();
while (position < count) {
- long chunk = Math.min(MAX_IO_CHUNK_SIZE, count - position);
+ final long chunk = Math.min(MAX_IO_CHUNK_SIZE, count - position);
position +=
destChannel.transferFrom(srcChannel, position, chunk);
}
@@ -800,8 +802,8 @@ public class ResourceUtils {
}
}
- private static void copyUsingStreams(Resource source, Resource dest,
- boolean append, Project project)
+ private static void copyUsingStreams(final Resource source, final Resource dest,
+ final boolean append, final Project project)
throws IOException {
InputStream in = null;
OutputStream out = null;
@@ -809,7 +811,7 @@ public class ResourceUtils {
in = source.getInputStream();
out = getOutputStream(dest, append, project);
- byte[] buffer = new byte[FileUtils.BUF_SIZE];
+ final byte[] buffer = new byte[FileUtils.BUF_SIZE];
int count = 0;
do {
out.write(buffer, 0, count);
@@ -821,10 +823,10 @@ public class ResourceUtils {
}
}
- private static OutputStream getOutputStream(Resource resource, boolean append, Project project)
+ private static OutputStream getOutputStream(final Resource resource, final boolean append, final Project project)
throws IOException {
if (append) {
- Appendable a = resource.as(Appendable.class);
+ final Appendable a = resource.as(Appendable.class);
if (a != null) {
return a.getAppendOutputStream();
}
@@ -834,7 +836,7 @@ public class ResourceUtils {
return resource.getOutputStream();
}
- public static interface ResourceSelectorProvider {
+ public interface ResourceSelectorProvider {
ResourceSelector getTargetSelectorForSource(Resource source);
}
@@ -842,7 +844,9 @@ public class ResourceUtils {
* @since Ant 1.9.4
*/
public static class ReadOnlyTargetFileException extends IOException {
- public ReadOnlyTargetFileException(File destFile) {
+ private static final long serialVersionUID = 1L;
+
+ public ReadOnlyTargetFileException(final File destFile) {
super("can't write to read-only destination file " + destFile);
}
}
http://git-wip-us.apache.org/repos/asf/ant/blob/1b76f1b6/src/main/org/apache/tools/ant/util/SymbolicLinkUtils.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/SymbolicLinkUtils.java b/src/main/org/apache/tools/ant/util/SymbolicLinkUtils.java
index d6c7353..36024ec 100644
--- a/src/main/org/apache/tools/ant/util/SymbolicLinkUtils.java
+++ b/src/main/org/apache/tools/ant/util/SymbolicLinkUtils.java
@@ -171,13 +171,14 @@ public class SymbolicLinkUtils {
* @return true if the file is a broken symbolic link.
* @throws IOException on error.
*/
- public boolean isDanglingSymbolicLink(File parent, String name)
+ public boolean isDanglingSymbolicLink(File parent, String name)
throws IOException {
File f = new File(parent, name);
if (!f.exists()) {
final String localName = f.getName();
String[] c = parent.list(new FilenameFilter() {
- public boolean accept(File d, String n) {
+ @Override
+ public boolean accept(File d, String n) {
return localName.equals(n);
}
});
http://git-wip-us.apache.org/repos/asf/ant/blob/1b76f1b6/src/main/org/apache/tools/ant/util/UnicodeUtil.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/UnicodeUtil.java b/src/main/org/apache/tools/ant/util/UnicodeUtil.java
index f4d52aa..bb64f73 100644
--- a/src/main/org/apache/tools/ant/util/UnicodeUtil.java
+++ b/src/main/org/apache/tools/ant/util/UnicodeUtil.java
@@ -41,6 +41,6 @@ public class UnicodeUtil {
- s.length() + i,
s.charAt(i));
}
- return unicodeBuf;
+ return unicodeBuf;
}
}
http://git-wip-us.apache.org/repos/asf/ant/blob/1b76f1b6/src/main/org/apache/tools/tar/TarConstants.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/tar/TarConstants.java b/src/main/org/apache/tools/tar/TarConstants.java
index 2944a40..06d0fac 100644
--- a/src/main/org/apache/tools/tar/TarConstants.java
+++ b/src/main/org/apache/tools/tar/TarConstants.java
@@ -67,7 +67,7 @@ public interface TarConstants {
* be expressed in octal char notation (that's 7 sevens, octal).
*/
long MAXID = 07777777L;
-
+
/**
* The length of the checksum field in a header buffer.
*/
@@ -80,7 +80,7 @@ public interface TarConstants {
int SIZELEN = 12;
/**
- * The maximum size of a file in a tar archive
+ * The maximum size of a file in a tar archive
* which can be expressed in octal char notation (that's 11 sevens, octal).
*/
long MAXSIZE = 077777777777L;
@@ -127,67 +127,67 @@ public interface TarConstants {
/**
* Length of the prefix field.
- *
+ *
*/
int PREFIXLEN = 155;
/**
* The length of the access time field in an old GNU header buffer.
- *
+ *
*/
int ATIMELEN_GNU = 12;
/**
* The length of the created time field in an old GNU header buffer.
- *
+ *
*/
int CTIMELEN_GNU = 12;
/**
- * The length of the multivolume start offset field in an old GNU header buffer.
- *
+ * The length of the multivolume start offset field in an old GNU header buffer.
+ *
*/
int OFFSETLEN_GNU = 12;
/**
- * The length of the long names field in an old GNU header buffer.
- *
+ * The length of the long names field in an old GNU header buffer.
+ *
*/
int LONGNAMESLEN_GNU = 4;
/**
- * The length of the padding field in an old GNU header buffer.
- *
+ * The length of the padding field in an old GNU header buffer.
+ *
*/
int PAD2LEN_GNU = 1;
/**
- * The sum of the length of all sparse headers in an old GNU header buffer.
- *
+ * The sum of the length of all sparse headers in an old GNU header buffer.
+ *
*/
int SPARSELEN_GNU = 96;
/**
- * The length of the is extension field in an old GNU header buffer.
- *
+ * The length of the is extension field in an old GNU header buffer.
+ *
*/
int ISEXTENDEDLEN_GNU = 1;
/**
- * The length of the real size field in an old GNU header buffer.
- *
+ * The length of the real size field in an old GNU header buffer.
+ *
*/
int REALSIZELEN_GNU = 12;
/**
- * The sum of the length of all sparse headers in a sparse header buffer.
- *
+ * The sum of the length of all sparse headers in a sparse header buffer.
+ *
*/
int SPARSELEN_GNU_SPARSE = 504;
/**
- * The length of the is extension field in a sparse header buffer.
- *
+ * The length of the is extension field in a sparse header buffer.
+ *
*/
int ISEXTENDEDLEN_GNU_SPARSE = 1;
http://git-wip-us.apache.org/repos/asf/ant/blob/1b76f1b6/src/main/org/apache/tools/tar/TarInputStream.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/tar/TarInputStream.java b/src/main/org/apache/tools/tar/TarInputStream.java
index 154f14e..651f206 100644
--- a/src/main/org/apache/tools/tar/TarInputStream.java
+++ b/src/main/org/apache/tools/tar/TarInputStream.java
@@ -506,10 +506,10 @@ public class TarInputStream extends FilterInputStream {
/**
* Adds the sparse chunks from the current entry to the sparse chunks,
* including any additional sparse entries following the current entry.
- *
- * @throws IOException on error
- *
- * @todo Sparse files get not yet really processed.
+ *
+ * @throws IOException on error
+ *
+ * @todo Sparse files get not yet really processed.
*/
private void readGNUSparse() throws IOException {
/* we do not really process sparse files yet
@@ -543,7 +543,7 @@ public class TarInputStream extends FilterInputStream {
@Override
public int read() throws IOException {
int num = read(oneBuf, 0, 1);
- return num == -1 ? -1 : ((int) oneBuf[0]) & BYTE_MASK;
+ return num == -1 ? -1 : (oneBuf[0]) & BYTE_MASK;
}
/**
http://git-wip-us.apache.org/repos/asf/ant/blob/1b76f1b6/src/main/org/apache/tools/tar/TarOutputStream.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/tar/TarOutputStream.java b/src/main/org/apache/tools/tar/TarOutputStream.java
index e90576f..6babde7 100644
--- a/src/main/org/apache/tools/tar/TarOutputStream.java
+++ b/src/main/org/apache/tools/tar/TarOutputStream.java
@@ -206,11 +206,11 @@ public class TarOutputStream extends FilterOutputStream {
/**
* Ends the TAR archive without closing the underlying OutputStream.
- *
+ *
* An archive consists of a series of file entries terminated by an
- * end-of-archive entry, which consists of two 512 blocks of zero bytes.
+ * end-of-archive entry, which consists of two 512 blocks of zero bytes.
* POSIX.1 requires two EOF records, like some other implementations.
- *
+ *
* @throws IOException on error
*/
public void finish() throws IOException {
@@ -377,7 +377,8 @@ public class TarOutputStream extends FilterOutputStream {
* @param wBuf The buffer to write to the archive.
* @throws IOException on error
*/
- public void write(byte[] wBuf) throws IOException {
+ @Override
+ public void write(byte[] wBuf) throws IOException {
write(wBuf, 0, wBuf.length);
}
http://git-wip-us.apache.org/repos/asf/ant/blob/1b76f1b6/src/main/org/apache/tools/tar/TarUtils.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/tar/TarUtils.java b/src/main/org/apache/tools/tar/TarUtils.java
index c057441..d6d6623 100644
--- a/src/main/org/apache/tools/tar/TarUtils.java
+++ b/src/main/org/apache/tools/tar/TarUtils.java
@@ -46,9 +46,11 @@ public class TarUtils {
* Encapsulates the algorithms used up to Ant 1.8 as ZipEncoding.
*/
static final ZipEncoding FALLBACK_ENCODING = new ZipEncoding() {
- public boolean canEncode(String name) { return true; }
+ @Override
+ public boolean canEncode(String name) { return true; }
- public ByteBuffer encode(String name) {
+ @Override
+ public ByteBuffer encode(String name) {
final int length = name.length();
byte[] buf = new byte[length];
@@ -59,7 +61,8 @@ public class TarUtils {
return ByteBuffer.wrap(buf);
}
- public String decode(byte[] buffer) {
+ @Override
+ public String decode(byte[] buffer) {
final int length = buffer.length;
StringBuilder result = new StringBuilder(length);
@@ -146,7 +149,7 @@ public class TarUtils {
return result;
}
- /**
+ /**
* Compute the value contained in a byte buffer. If the most
* significant bit of the first byte in the buffer is set, this
* bit is ignored and the rest of the buffer is interpreted as a
@@ -303,7 +306,7 @@ public class TarUtils {
/**
* Copy a name into a buffer.
* Copies characters from the name into the buffer
- * starting at the specified offset.
+ * starting at the specified offset.
* If the buffer is longer than the name, the buffer
* is filled with trailing NULs.
* If the name is longer than the buffer,
@@ -332,7 +335,7 @@ public class TarUtils {
/**
* Copy a name into a buffer.
* Copies characters from the name into the buffer
- * starting at the specified offset.
+ * starting at the specified offset.
* If the buffer is longer than the name, the buffer
* is filled with trailing NULs.
* If the name is longer than the buffer,
@@ -367,7 +370,7 @@ public class TarUtils {
/**
* Fill buffer with unsigned octal number, padded with leading zeroes.
- *
+ *
* @param value number to convert to octal - treated as unsigned
* @param buffer destination buffer
* @param offset starting offset in buffer
@@ -405,7 +408,7 @@ public class TarUtils {
* Uses {@link #formatUnsignedOctalString} to format
* the value as an octal string with leading zeros.
* The converted number is followed by space and NUL
- *
+ *
* @param value The value to write
* @param buf The buffer to receive the output
* @param offset The starting offset into the buffer
@@ -426,11 +429,11 @@ public class TarUtils {
/**
* Write an octal long integer into a buffer.
- *
+ *
* Uses {@link #formatUnsignedOctalString} to format
* the value as an octal string with leading zeros.
* The converted number is followed by a space.
- *
+ *
* @param value The value to write as octal
* @param buf The destinationbuffer.
* @param offset The starting offset into the buffer.
@@ -451,11 +454,11 @@ public class TarUtils {
/**
* Write an long integer into a buffer as an octal string if this
* will fit, or as a binary number otherwise.
- *
+ *
* Uses {@link #formatUnsignedOctalString} to format
* the value as an octal string with leading zeros.
* The converted number is followed by a space.
- *
+ *
* @param value The value to write into the buffer.
* @param buf The destination buffer.
* @param offset The starting offset into the buffer.
@@ -488,7 +491,7 @@ public class TarUtils {
final int offset, final int length,
final boolean negative) {
final int bits = (length - 1) * 8;
- final long max = 1l << bits;
+ final long max = 1L << bits;
long val = Math.abs(value);
if (val >= max) {
throw new IllegalArgumentException("Value " + value +
@@ -522,7 +525,7 @@ public class TarUtils {
/**
* Writes an octal value into a buffer.
- *
+ *
* Uses {@link #formatUnsignedOctalString} to format
* the value as an octal string with leading zeros.
* The converted number is followed by NUL and then space.
http://git-wip-us.apache.org/repos/asf/ant/blob/1b76f1b6/src/main/org/apache/tools/zip/AbstractUnicodeExtraField.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/zip/AbstractUnicodeExtraField.java b/src/main/org/apache/tools/zip/AbstractUnicodeExtraField.java
index 0a7eec2..731d261 100644
--- a/src/main/org/apache/tools/zip/AbstractUnicodeExtraField.java
+++ b/src/main/org/apache/tools/zip/AbstractUnicodeExtraField.java
@@ -36,7 +36,7 @@ public abstract class AbstractUnicodeExtraField implements ZipExtraField {
/**
* Assemble as unicode extension from the name/comment and
* encoding of the original zip entry.
- *
+ *
* @param text The file name or comment.
* @param bytes The encoded of the filename or comment in the zip
* file.
@@ -62,7 +62,7 @@ public abstract class AbstractUnicodeExtraField implements ZipExtraField {
/**
* Assemble as unicode extension from the name/comment and
* encoding of the original zip entry.
- *
+ *
* @param text The file name or comment.
* @param bytes The encoded of the filename or comment in the zip
* file.
@@ -128,7 +128,8 @@ public abstract class AbstractUnicodeExtraField implements ZipExtraField {
}
/** {@inheritDoc} */
- public byte[] getCentralDirectoryData() {
+ @Override
+ public byte[] getCentralDirectoryData() {
if (data == null) {
this.assembleData();
}
@@ -141,7 +142,8 @@ public abstract class AbstractUnicodeExtraField implements ZipExtraField {
}
/** {@inheritDoc} */
- public ZipShort getCentralDirectoryLength() {
+ @Override
+ public ZipShort getCentralDirectoryLength() {
if (data == null) {
assembleData();
}
@@ -149,17 +151,20 @@ public abstract class AbstractUnicodeExtraField implements ZipExtraField {
}
/** {@inheritDoc} */
- public byte[] getLocalFileDataData() {
+ @Override
+ public byte[] getLocalFileDataData() {
return getCentralDirectoryData();
}
/** {@inheritDoc} */
- public ZipShort getLocalFileDataLength() {
+ @Override
+ public ZipShort getLocalFileDataLength() {
return getCentralDirectoryLength();
}
/** {@inheritDoc} */
- public void parseFromLocalFileData(byte[] buffer, int offset, int length)
+ @Override
+ public void parseFromLocalFileData(byte[] buffer, int offset, int length)
throws ZipException {
if (length < 5) {
http://git-wip-us.apache.org/repos/asf/ant/blob/1b76f1b6/src/main/org/apache/tools/zip/FallbackZipEncoding.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/zip/FallbackZipEncoding.java b/src/main/org/apache/tools/zip/FallbackZipEncoding.java
index facc63e..545d6c7 100644
--- a/src/main/org/apache/tools/zip/FallbackZipEncoding.java
+++ b/src/main/org/apache/tools/zip/FallbackZipEncoding.java
@@ -29,14 +29,14 @@ import java.nio.ByteBuffer;
* utf-8, because java.io encodes unmappable character as question
* marks leading to unreadable ZIP entries on some operating
* systems.</p>
- *
+ *
* <p>Furthermore this implementation is unable to tell whether a
* given name can be safely encoded or not.</p>
- *
+ *
* <p>This implementation acts as a last resort implementation, when
* neither {@link Simple8BitZipEnoding} nor {@link NioZipEncoding} is
* available.</p>
- *
+ *
* <p>The methods of this class are reentrant.</p>
*/
class FallbackZipEncoding implements ZipEncoding {
@@ -52,7 +52,7 @@ class FallbackZipEncoding implements ZipEncoding {
/**
* Construct a fallback zip encoding, which uses the given charset.
- *
+ *
* @param charset The name of the charset or {@code null} for
* the platform's default character set.
*/
@@ -64,7 +64,8 @@ class FallbackZipEncoding implements ZipEncoding {
* @see
* org.apache.tools.zip.ZipEncoding#canEncode(java.lang.String)
*/
- public boolean canEncode(String name) {
+ @Override
+ public boolean canEncode(String name) {
return true;
}
@@ -72,7 +73,8 @@ class FallbackZipEncoding implements ZipEncoding {
* @see
* org.apache.tools.zip.ZipEncoding#encode(java.lang.String)
*/
- public ByteBuffer encode(String name) throws IOException {
+ @Override
+ public ByteBuffer encode(String name) throws IOException {
if (this.charset == null) { // i.e. use default charset, see no-args constructor
return ByteBuffer.wrap(name.getBytes());
} else {
@@ -84,7 +86,8 @@ class FallbackZipEncoding implements ZipEncoding {
* @see
* org.apache.tools.zip.ZipEncoding#decode(byte[])
*/
- public String decode(byte[] data) throws IOException {
+ @Override
+ public String decode(byte[] data) throws IOException {
if (this.charset == null) { // i.e. use default charset, see no-args constructor
return new String(data);
} else {
http://git-wip-us.apache.org/repos/asf/ant/blob/1b76f1b6/src/main/org/apache/tools/zip/GeneralPurposeBit.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/zip/GeneralPurposeBit.java b/src/main/org/apache/tools/zip/GeneralPurposeBit.java
index 1e92103..eaafc2c 100644
--- a/src/main/org/apache/tools/zip/GeneralPurposeBit.java
+++ b/src/main/org/apache/tools/zip/GeneralPurposeBit.java
@@ -122,7 +122,7 @@ public final class GeneralPurposeBit {
* Encodes the set bits in a form suitable for ZIP archives.
*/
public byte[] encode() {
- return
+ return
ZipShort.getBytes((dataDescriptorFlag ? DATA_DESCRIPTOR_FLAG : 0)
|
(languageEncodingFlag ? UFT8_NAMES_FLAG : 0)
http://git-wip-us.apache.org/repos/asf/ant/blob/1b76f1b6/src/main/org/apache/tools/zip/NioZipEncoding.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/zip/NioZipEncoding.java b/src/main/org/apache/tools/zip/NioZipEncoding.java
index e2274e5..cc5e40b 100644
--- a/src/main/org/apache/tools/zip/NioZipEncoding.java
+++ b/src/main/org/apache/tools/zip/NioZipEncoding.java
@@ -34,7 +34,7 @@ import java.nio.charset.CodingErrorAction;
* <p>This implementation works for all cases under java-1.5 or
* later. However, in java-1.4, some charsets don't have a java.nio
* implementation, most notably the default ZIP encoding Cp437.</p>
- *
+ *
* <p>The methods of this class are reentrant.</p>
*/
class NioZipEncoding implements ZipEncoding {
@@ -43,7 +43,7 @@ class NioZipEncoding implements ZipEncoding {
/**
* Construct an NIO based zip encoding, which wraps the given
* charset.
- *
+ *
* @param charset The NIO charset to wrap.
*/
public NioZipEncoding(Charset charset) {
@@ -54,7 +54,8 @@ class NioZipEncoding implements ZipEncoding {
* @see
* org.apache.tools.zip.ZipEncoding#canEncode(java.lang.String)
*/
- public boolean canEncode(String name) {
+ @Override
+ public boolean canEncode(String name) {
CharsetEncoder enc = this.charset.newEncoder();
enc.onMalformedInput(CodingErrorAction.REPORT);
enc.onUnmappableCharacter(CodingErrorAction.REPORT);
@@ -66,7 +67,8 @@ class NioZipEncoding implements ZipEncoding {
* @see
* org.apache.tools.zip.ZipEncoding#encode(java.lang.String)
*/
- public ByteBuffer encode(String name) {
+ @Override
+ public ByteBuffer encode(String name) {
CharsetEncoder enc = this.charset.newEncoder();
enc.onMalformedInput(CodingErrorAction.REPORT);
@@ -113,7 +115,8 @@ class NioZipEncoding implements ZipEncoding {
* @see
* org.apache.tools.zip.ZipEncoding#decode(byte[])
*/
- public String decode(byte[] data) throws IOException {
+ @Override
+ public String decode(byte[] data) throws IOException {
return this.charset.newDecoder()
.onMalformedInput(CodingErrorAction.REPORT)
.onUnmappableCharacter(CodingErrorAction.REPORT)
http://git-wip-us.apache.org/repos/asf/ant/blob/1b76f1b6/src/main/org/apache/tools/zip/Simple8BitZipEncoding.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/zip/Simple8BitZipEncoding.java b/src/main/org/apache/tools/zip/Simple8BitZipEncoding.java
index 5bff472..4db24b8 100644
--- a/src/main/org/apache/tools/zip/Simple8BitZipEncoding.java
+++ b/src/main/org/apache/tools/zip/Simple8BitZipEncoding.java
@@ -28,7 +28,7 @@ import java.util.List;
/**
* This ZipEncoding implementation implements a simple 8bit character
* set, which mets the following restrictions:
- *
+ *
* <ul>
* <li>Characters 0x0000 to 0x007f are encoded as the corresponding
* byte values 0x00 to 0x7f.</li>
@@ -36,11 +36,11 @@ import java.util.List;
* character in the range 0x0080 to 0x7fff. (No support for
* UTF-16 surrogates)
* </ul>
- *
+ *
* <p>These restrictions most notably apply to the most prominent
* omissions of java-1.4's {@link java.nio.charset.Charset Charset}
* implementation, Cp437 and Cp850.</p>
- *
+ *
* <p>The methods of this class are reentrant.</p>
*/
class Simple8BitZipEncoding implements ZipEncoding {
@@ -58,7 +58,8 @@ class Simple8BitZipEncoding implements ZipEncoding {
this.unicode = unicode;
}
- public int compareTo(Simple8BitChar a) {
+ @Override
+ public int compareTo(Simple8BitChar a) {
return this.unicode - a.unicode;
}
@@ -117,7 +118,7 @@ class Simple8BitZipEncoding implements ZipEncoding {
/**
* Return the character code for a given encoded byte.
- *
+ *
* @param b The byte to decode.
* @return The associated character value.
*/
@@ -147,12 +148,12 @@ class Simple8BitZipEncoding implements ZipEncoding {
/**
* Pushes the encoded form of the given character to the given byte buffer.
- *
+ *
* @param bb The byte buffer to write to.
* @param c The character to encode.
* @return Whether the given unicode character is covered by this encoding.
* If {@code false} is returned, nothing is pushed to the
- * byte buffer.
+ * byte buffer.
*/
public boolean pushEncodedChar(ByteBuffer bb, char c) {
@@ -215,7 +216,8 @@ class Simple8BitZipEncoding implements ZipEncoding {
* @see
* org.apache.tools.zip.ZipEncoding#canEncode(java.lang.String)
*/
- public boolean canEncode(String name) {
+ @Override
+ public boolean canEncode(String name) {
for (int i=0;i<name.length();++i) {
@@ -233,7 +235,8 @@ class Simple8BitZipEncoding implements ZipEncoding {
* @see
* org.apache.tools.zip.ZipEncoding#encode(java.lang.String)
*/
- public ByteBuffer encode(String name) {
+ @Override
+ public ByteBuffer encode(String name) {
ByteBuffer out = ByteBuffer.allocate(name.length()
+ 6 + (name.length() + 1) / 2);
@@ -260,7 +263,8 @@ class Simple8BitZipEncoding implements ZipEncoding {
* @see
* org.apache.tools.zip.ZipEncoding#decode(byte[])
*/
- public String decode(byte[] data) throws IOException {
+ @Override
+ public String decode(byte[] data) throws IOException {
char [] ret = new char[data.length];
for (int i=0;i<data.length;++i) {
http://git-wip-us.apache.org/repos/asf/ant/blob/1b76f1b6/src/main/org/apache/tools/zip/UnicodeCommentExtraField.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/zip/UnicodeCommentExtraField.java b/src/main/org/apache/tools/zip/UnicodeCommentExtraField.java
index 205f52b..ea73a47 100644
--- a/src/main/org/apache/tools/zip/UnicodeCommentExtraField.java
+++ b/src/main/org/apache/tools/zip/UnicodeCommentExtraField.java
@@ -33,13 +33,13 @@ public class UnicodeCommentExtraField extends AbstractUnicodeExtraField {
public static final ZipShort UCOM_ID = new ZipShort(0x6375);
- public UnicodeCommentExtraField () {
+ public UnicodeCommentExtraField () {
}
/**
* Assemble as unicode comment extension from the name given as
* text as well as the encoded bytes actually written to the archive.
- *
+ *
* @param text The file name
* @param bytes the bytes actually written to the archive
* @param off The offset of the encoded comment in <code>bytes</code>.
@@ -54,7 +54,7 @@ public class UnicodeCommentExtraField extends AbstractUnicodeExtraField {
/**
* Assemble as unicode comment extension from the comment given as
* text as well as the bytes actually written to the archive.
- *
+ *
* @param comment The file comment
* @param bytes the bytes actually written to the archive
*/
@@ -63,7 +63,8 @@ public class UnicodeCommentExtraField extends AbstractUnicodeExtraField {
}
/** {@inheritDoc} */
- public ZipShort getHeaderId() {
+ @Override
+ public ZipShort getHeaderId() {
return UCOM_ID;
}
http://git-wip-us.apache.org/repos/asf/ant/blob/1b76f1b6/src/main/org/apache/tools/zip/UnicodePathExtraField.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/zip/UnicodePathExtraField.java b/src/main/org/apache/tools/zip/UnicodePathExtraField.java
index 4fb8772..2f6e0c2 100644
--- a/src/main/org/apache/tools/zip/UnicodePathExtraField.java
+++ b/src/main/org/apache/tools/zip/UnicodePathExtraField.java
@@ -21,7 +21,7 @@ package org.apache.tools.zip;
/**
* Info-ZIP Unicode Path Extra Field (0x7075):
*
- * <p>Stores the UTF-8 version of the file name field as stored in the
+ * <p>Stores the UTF-8 version of the file name field as stored in the
* local header and central directory header.</p>
*
* <p>See {@link
@@ -32,13 +32,13 @@ public class UnicodePathExtraField extends AbstractUnicodeExtraField {
public static final ZipShort UPATH_ID = new ZipShort(0x7075);
- public UnicodePathExtraField () {
+ public UnicodePathExtraField () {
}
/**
* Assemble as unicode path extension from the name given as
* text as well as the encoded bytes actually written to the archive.
- *
+ *
* @param text The file name
* @param bytes the bytes actually written to the archive
* @param off The offset of the encoded filename in <code>bytes</code>.
@@ -52,7 +52,7 @@ public class UnicodePathExtraField extends AbstractUnicodeExtraField {
/**
* Assemble as unicode path extension from the name given as
* text as well as the encoded bytes actually written to the archive.
- *
+ *
* @param name The file name
* @param bytes the bytes actually written to the archive
*/
@@ -61,7 +61,8 @@ public class UnicodePathExtraField extends AbstractUnicodeExtraField {
}
/** {@inheritDoc} */
- public ZipShort getHeaderId() {
+ @Override
+ public ZipShort getHeaderId() {
return UPATH_ID;
}
}
http://git-wip-us.apache.org/repos/asf/ant/blob/1b76f1b6/src/main/org/apache/tools/zip/ZipEncoding.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/zip/ZipEncoding.java b/src/main/org/apache/tools/zip/ZipEncoding.java
index 0852473..7265383 100644
--- a/src/main/org/apache/tools/zip/ZipEncoding.java
+++ b/src/main/org/apache/tools/zip/ZipEncoding.java
@@ -30,14 +30,14 @@ import java.nio.ByteBuffer;
* {@link java.nio.charset.Charset Charset} and one implementation,
* which copes with simple 8 bit charsets, because java-1.4 did not
* support Cp437 in java.nio.</p>
- *
+ *
* <p>The main reason for defining an own encoding layer comes from
* the problems with {@link java.lang.String#getBytes(String)
* String.getBytes}, which encodes unknown characters as ASCII
* quotation marks ('?'). Quotation marks are per definition an
* invalid filename on some operating systems like Windows, which
* leads to ignored ZIP entries.</p>
- *
+ *
* <p>All implementations should implement this interface in a
* reentrant way.</p>
*/
@@ -45,7 +45,7 @@ public interface ZipEncoding {
/**
* Check, whether the given string may be losslessly encoded using this
* encoding.
- *
+ *
* @param name A filename or ZIP comment.
* @return Whether the given name may be encoded with out any losses.
*/
@@ -54,15 +54,15 @@ public interface ZipEncoding {
/**
* Encode a filename or a comment to a byte array suitable for
* storing it to a serialized zip entry.
- *
+ *
* <p>Examples for CP 437 (in pseudo-notation, right hand side is
* C-style notation):</p>
* <pre>
* encode("\u20AC_for_Dollar.txt") = "%U20AC_for_Dollar.txt"
* encode("\u00D6lf\u00E4sser.txt") = "\231lf\204sser.txt"
* </pre>
- *
- * @param name A filename or ZIP comment.
+ *
+ * @param name A filename or ZIP comment.
* @return A byte buffer with a backing array containing the
* encoded name. Unmappable characters or malformed
* character sequences are mapped to a sequence of utf-16
@@ -71,14 +71,14 @@ public interface ZipEncoding {
* beginning of the encoded result, the byte buffer has a
* backing array and the limit of the byte buffer points
* to the end of the encoded result.
- * @throws IOException
+ * @throws IOException
*/
ByteBuffer encode(String name) throws IOException;
/**
* @param data The byte values to decode.
* @return The decoded string.
- * @throws IOException
+ * @throws IOException
*/
String decode(byte [] data) throws IOException;
}
http://git-wip-us.apache.org/repos/asf/ant/blob/1b76f1b6/src/main/org/apache/tools/zip/ZipEncodingHelper.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/zip/ZipEncodingHelper.java b/src/main/org/apache/tools/zip/ZipEncodingHelper.java
index b32f902..4d3dab9 100644
--- a/src/main/org/apache/tools/zip/ZipEncodingHelper.java
+++ b/src/main/org/apache/tools/zip/ZipEncodingHelper.java
@@ -26,7 +26,7 @@ import java.util.HashMap;
import java.util.Map;
/**
- * Static helper functions for robustly encoding filenames in zip files.
+ * Static helper functions for robustly encoding filenames in zip files.
*/
public abstract class ZipEncodingHelper {
@@ -42,12 +42,12 @@ public abstract class ZipEncodingHelper {
/**
* Instantiate a simple encoding holder.
- *
+ *
* @param highChars The characters for byte codes 128 to 255.
- *
+ *
* @see Simple8BitZipEncoding#Simple8BitZipEncoding(char[])
*/
- SimpleEncodingHolder(char [] highChars) {
+ SimpleEncodingHolder(final char [] highChars) {
this.highChars = highChars;
}
@@ -66,34 +66,34 @@ public abstract class ZipEncodingHelper {
private static final Map<String, SimpleEncodingHolder> simpleEncodings;
static {
- Map<String, SimpleEncodingHolder> se =
+ final Map<String, SimpleEncodingHolder> se =
new HashMap<String, SimpleEncodingHolder>();
- char[] cp437_high_chars =
- new char[] { 0x00c7, 0x00fc, 0x00e9, 0x00e2, 0x00e4, 0x00e0,
- 0x00e5, 0x00e7, 0x00ea, 0x00eb, 0x00e8, 0x00ef,
- 0x00ee, 0x00ec, 0x00c4, 0x00c5, 0x00c9, 0x00e6,
- 0x00c6, 0x00f4, 0x00f6, 0x00f2, 0x00fb, 0x00f9,
- 0x00ff, 0x00d6, 0x00dc, 0x00a2, 0x00a3, 0x00a5,
- 0x20a7, 0x0192, 0x00e1, 0x00ed, 0x00f3, 0x00fa,
- 0x00f1, 0x00d1, 0x00aa, 0x00ba, 0x00bf, 0x2310,
- 0x00ac, 0x00bd, 0x00bc, 0x00a1, 0x00ab, 0x00bb,
- 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561,
- 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557,
- 0x255d, 0x255c, 0x255b, 0x2510, 0x2514, 0x2534,
- 0x252c, 0x251c, 0x2500, 0x253c, 0x255e, 0x255f,
- 0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550,
- 0x256c, 0x2567, 0x2568, 0x2564, 0x2565, 0x2559,
- 0x2558, 0x2552, 0x2553, 0x256b, 0x256a, 0x2518,
- 0x250c, 0x2588, 0x2584, 0x258c, 0x2590, 0x2580,
- 0x03b1, 0x00df, 0x0393, 0x03c0, 0x03a3, 0x03c3,
- 0x00b5, 0x03c4, 0x03a6, 0x0398, 0x03a9, 0x03b4,
- 0x221e, 0x03c6, 0x03b5, 0x2229, 0x2261, 0x00b1,
- 0x2265, 0x2264, 0x2320, 0x2321, 0x00f7, 0x2248,
- 0x00b0, 0x2219, 0x00b7, 0x221a, 0x207f, 0x00b2,
- 0x25a0, 0x00a0 };
-
- SimpleEncodingHolder cp437 = new SimpleEncodingHolder(cp437_high_chars);
+ final char[] cp437_high_chars =
+ new char[] {0x00c7, 0x00fc, 0x00e9, 0x00e2, 0x00e4, 0x00e0,
+ 0x00e5, 0x00e7, 0x00ea, 0x00eb, 0x00e8, 0x00ef,
+ 0x00ee, 0x00ec, 0x00c4, 0x00c5, 0x00c9, 0x00e6,
+ 0x00c6, 0x00f4, 0x00f6, 0x00f2, 0x00fb, 0x00f9,
+ 0x00ff, 0x00d6, 0x00dc, 0x00a2, 0x00a3, 0x00a5,
+ 0x20a7, 0x0192, 0x00e1, 0x00ed, 0x00f3, 0x00fa,
+ 0x00f1, 0x00d1, 0x00aa, 0x00ba, 0x00bf, 0x2310,
+ 0x00ac, 0x00bd, 0x00bc, 0x00a1, 0x00ab, 0x00bb,
+ 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561,
+ 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557,
+ 0x255d, 0x255c, 0x255b, 0x2510, 0x2514, 0x2534,
+ 0x252c, 0x251c, 0x2500, 0x253c, 0x255e, 0x255f,
+ 0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550,
+ 0x256c, 0x2567, 0x2568, 0x2564, 0x2565, 0x2559,
+ 0x2558, 0x2552, 0x2553, 0x256b, 0x256a, 0x2518,
+ 0x250c, 0x2588, 0x2584, 0x258c, 0x2590, 0x2580,
+ 0x03b1, 0x00df, 0x0393, 0x03c0, 0x03a3, 0x03c3,
+ 0x00b5, 0x03c4, 0x03a6, 0x0398, 0x03a9, 0x03b4,
+ 0x221e, 0x03c6, 0x03b5, 0x2229, 0x2261, 0x00b1,
+ 0x2265, 0x2264, 0x2320, 0x2321, 0x00f7, 0x2248,
+ 0x00b0, 0x2219, 0x00b7, 0x221a, 0x207f, 0x00b2,
+ 0x25a0, 0x00a0};
+
+ final SimpleEncodingHolder cp437 = new SimpleEncodingHolder(cp437_high_chars);
se.put("CP437", cp437);
se.put("Cp437", cp437);
@@ -101,31 +101,31 @@ public abstract class ZipEncodingHelper {
se.put("IBM437", cp437);
se.put("ibm437", cp437);
- char[] cp850_high_chars =
- new char[] { 0x00c7, 0x00fc, 0x00e9, 0x00e2, 0x00e4, 0x00e0,
- 0x00e5, 0x00e7, 0x00ea, 0x00eb, 0x00e8, 0x00ef,
- 0x00ee, 0x00ec, 0x00c4, 0x00c5, 0x00c9, 0x00e6,
- 0x00c6, 0x00f4, 0x00f6, 0x00f2, 0x00fb, 0x00f9,
- 0x00ff, 0x00d6, 0x00dc, 0x00f8, 0x00a3, 0x00d8,
- 0x00d7, 0x0192, 0x00e1, 0x00ed, 0x00f3, 0x00fa,
- 0x00f1, 0x00d1, 0x00aa, 0x00ba, 0x00bf, 0x00ae,
- 0x00ac, 0x00bd, 0x00bc, 0x00a1, 0x00ab, 0x00bb,
- 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00c1,
- 0x00c2, 0x00c0, 0x00a9, 0x2563, 0x2551, 0x2557,
- 0x255d, 0x00a2, 0x00a5, 0x2510, 0x2514, 0x2534,
- 0x252c, 0x251c, 0x2500, 0x253c, 0x00e3, 0x00c3,
- 0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550,
- 0x256c, 0x00a4, 0x00f0, 0x00d0, 0x00ca, 0x00cb,
- 0x00c8, 0x0131, 0x00cd, 0x00ce, 0x00cf, 0x2518,
- 0x250c, 0x2588, 0x2584, 0x00a6, 0x00cc, 0x2580,
- 0x00d3, 0x00df, 0x00d4, 0x00d2, 0x00f5, 0x00d5,
- 0x00b5, 0x00fe, 0x00de, 0x00da, 0x00db, 0x00d9,
- 0x00fd, 0x00dd, 0x00af, 0x00b4, 0x00ad, 0x00b1,
- 0x2017, 0x00be, 0x00b6, 0x00a7, 0x00f7, 0x00b8,
- 0x00b0, 0x00a8, 0x00b7, 0x00b9, 0x00b3, 0x00b2,
- 0x25a0, 0x00a0 };
-
- SimpleEncodingHolder cp850 = new SimpleEncodingHolder(cp850_high_chars);
+ final char[] cp850_high_chars =
+ new char[] {0x00c7, 0x00fc, 0x00e9, 0x00e2, 0x00e4, 0x00e0,
+ 0x00e5, 0x00e7, 0x00ea, 0x00eb, 0x00e8, 0x00ef,
+ 0x00ee, 0x00ec, 0x00c4, 0x00c5, 0x00c9, 0x00e6,
+ 0x00c6, 0x00f4, 0x00f6, 0x00f2, 0x00fb, 0x00f9,
+ 0x00ff, 0x00d6, 0x00dc, 0x00f8, 0x00a3, 0x00d8,
+ 0x00d7, 0x0192, 0x00e1, 0x00ed, 0x00f3, 0x00fa,
+ 0x00f1, 0x00d1, 0x00aa, 0x00ba, 0x00bf, 0x00ae,
+ 0x00ac, 0x00bd, 0x00bc, 0x00a1, 0x00ab, 0x00bb,
+ 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00c1,
+ 0x00c2, 0x00c0, 0x00a9, 0x2563, 0x2551, 0x2557,
+ 0x255d, 0x00a2, 0x00a5, 0x2510, 0x2514, 0x2534,
+ 0x252c, 0x251c, 0x2500, 0x253c, 0x00e3, 0x00c3,
+ 0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550,
+ 0x256c, 0x00a4, 0x00f0, 0x00d0, 0x00ca, 0x00cb,
+ 0x00c8, 0x0131, 0x00cd, 0x00ce, 0x00cf, 0x2518,
+ 0x250c, 0x2588, 0x2584, 0x00a6, 0x00cc, 0x2580,
+ 0x00d3, 0x00df, 0x00d4, 0x00d2, 0x00f5, 0x00d5,
+ 0x00b5, 0x00fe, 0x00de, 0x00da, 0x00db, 0x00d9,
+ 0x00fd, 0x00dd, 0x00af, 0x00b4, 0x00ad, 0x00b1,
+ 0x2017, 0x00be, 0x00b6, 0x00a7, 0x00f7, 0x00b8,
+ 0x00b0, 0x00a8, 0x00b7, 0x00b9, 0x00b3, 0x00b2,
+ 0x25a0, 0x00a0};
+
+ final SimpleEncodingHolder cp850 = new SimpleEncodingHolder(cp850_high_chars);
se.put("CP850", cp850);
se.put("Cp850", cp850);
@@ -137,8 +137,8 @@ public abstract class ZipEncodingHelper {
/**
* Grow a byte buffer, so it has a minimal capacity or at least
- * the double capacity of the original buffer
- *
+ * the double capacity of the original buffer
+ *
* @param b The original buffer.
* @param newCapacity The minimal requested new capacity.
* @return A byte buffer <code>r</code> with
@@ -147,18 +147,18 @@ public abstract class ZipEncodingHelper {
* of <code>r</code>.
*
*/
- static ByteBuffer growBuffer(ByteBuffer b, int newCapacity) {
+ static ByteBuffer growBuffer(final ByteBuffer b, final int newCapacity) {
b.limit(b.position());
b.rewind();
- int c2 = b.capacity() * 2;
- ByteBuffer on = ByteBuffer.allocate(c2 < newCapacity ? newCapacity : c2);
+ final int c2 = b.capacity() * 2;
+ final ByteBuffer on = ByteBuffer.allocate(c2 < newCapacity ? newCapacity : c2);
on.put(b);
return on;
}
-
+
/**
* The hexadecimal digits <code>0,...,9,A,...,F</code> encoded as
* ASCII bytes.
@@ -172,11 +172,11 @@ public abstract class ZipEncodingHelper {
/**
* Append <code>%Uxxxx</code> to the given byte buffer.
* The caller must assure, that <code>bb.remaining()>=6</code>.
- *
+ *
* @param bb The byte buffer to write to.
* @param c The character to write.
*/
- static void appendSurrogate(ByteBuffer bb, char c) {
+ static void appendSurrogate(final ByteBuffer bb, final char c) {
bb.put((byte) '%');
bb.put((byte) 'U');
@@ -205,13 +205,13 @@ public abstract class ZipEncodingHelper {
/**
* Instantiates a zip encoding.
- *
+ *
* @param name The name of the zip encoding. Specify {@code null} for
* the platform's default encoding.
* @return A zip encoding for the given encoding name.
*/
- public static ZipEncoding getZipEncoding(String name) {
-
+ public static ZipEncoding getZipEncoding(final String name) {
+
// fallback encoding is good enough for utf-8.
if (isUTF8(name)) {
return UTF8_ZIP_ENCODING;
@@ -221,7 +221,7 @@ public abstract class ZipEncodingHelper {
return new FallbackZipEncoding();
}
- SimpleEncodingHolder h = simpleEncodings.get(name);
+ final SimpleEncodingHolder h = simpleEncodings.get(name);
if (h!=null) {
return h.getEncoding();
@@ -229,10 +229,10 @@ public abstract class ZipEncodingHelper {
try {
- Charset cs = Charset.forName(name);
+ final Charset cs = Charset.forName(name);
return new NioZipEncoding(cs);
- } catch (UnsupportedCharsetException e) {
+ } catch (final UnsupportedCharsetException e) {
return new FallbackZipEncoding(name);
}
}
http://git-wip-us.apache.org/repos/asf/ant/blob/1b76f1b6/src/main/org/apache/tools/zip/ZipEntry.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/zip/ZipEntry.java b/src/main/org/apache/tools/zip/ZipEntry.java
index 7d52a96..bbcf1ae 100644
--- a/src/main/org/apache/tools/zip/ZipEntry.java
+++ b/src/main/org/apache/tools/zip/ZipEntry.java
@@ -90,7 +90,7 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable {
* @param name the name of the entry
* @since 1.1
*/
- public ZipEntry(String name) {
+ public ZipEntry(final String name) {
super(name);
setName(name);
}
@@ -105,10 +105,10 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable {
* @since 1.1
* @throws ZipException on error
*/
- public ZipEntry(java.util.zip.ZipEntry entry) throws ZipException {
+ public ZipEntry(final java.util.zip.ZipEntry entry) throws ZipException {
super(entry);
setName(entry.getName());
- byte[] extra = entry.getExtra();
+ final byte[] extra = entry.getExtra();
if (extra != null) {
setExtraFields(ExtraFieldUtils.parse(extra, true,
ExtraFieldUtils
@@ -131,7 +131,7 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable {
* @throws ZipException on error
* @since 1.1
*/
- public ZipEntry(ZipEntry entry) throws ZipException {
+ public ZipEntry(final ZipEntry entry) throws ZipException {
this((java.util.zip.ZipEntry) entry);
setInternalAttributes(entry.getInternalAttributes());
setExternalAttributes(entry.getExternalAttributes());
@@ -154,8 +154,8 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable {
* potential trailing forward slash will be stripped from the
* entry name.</p>
*/
- public ZipEntry(File inputFile, String entryName) {
- this(inputFile.isDirectory() && !entryName.endsWith("/") ?
+ public ZipEntry(final File inputFile, final String entryName) {
+ this(inputFile.isDirectory() && !entryName.endsWith("/") ?
entryName + "/" : entryName);
if (inputFile.isFile()){
setSize(inputFile.length());
@@ -171,7 +171,7 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable {
*/
@Override
public Object clone() {
- ZipEntry e = (ZipEntry) super.clone();
+ final ZipEntry e = (ZipEntry) super.clone();
e.setInternalAttributes(getInternalAttributes());
e.setExternalAttributes(getExternalAttributes());
@@ -196,7 +196,7 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable {
* @param method compression method
*/
@Override
- public void setMethod(int method) {
+ public void setMethod(final int method) {
if (method < 0) {
throw new IllegalArgumentException(
"ZIP compression method can not be negative: " + method);
@@ -219,7 +219,7 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable {
* @param value an <code>int</code> value
* @since 1.1
*/
- public void setInternalAttributes(int value) {
+ public void setInternalAttributes(final int value) {
internalAttributes = value;
}
@@ -237,7 +237,7 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable {
* @param value an <code>long</code> value
* @since 1.1
*/
- public void setExternalAttributes(long value) {
+ public void setExternalAttributes(final long value) {
externalAttributes = value;
}
@@ -247,7 +247,7 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable {
* @param mode an <code>int</code> value
* @since Ant 1.5.2
*/
- public void setUnixMode(int mode) {
+ public void setUnixMode(final int mode) {
// CheckStyle:MagicNumberCheck OFF - no point
setExternalAttributes((mode << SHORT_SHIFT)
// MS-DOS read-only attribute
@@ -286,7 +286,7 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable {
* @param platform an <code>int</code> value - 0 is FAT, 3 is UNIX
* @since 1.9
*/
- protected void setPlatform(int platform) {
+ protected void setPlatform(final int platform) {
this.platform = platform;
}
@@ -295,9 +295,9 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable {
* @param fields an array of extra fields
* @since 1.1
*/
- public void setExtraFields(ZipExtraField[] fields) {
+ public void setExtraFields(final ZipExtraField[] fields) {
extraFields = new LinkedHashMap<ZipShort, ZipExtraField>();
- for (ZipExtraField field : fields) {
+ for (final ZipExtraField field : fields) {
if (field instanceof UnparseableExtraFieldData) {
unparseableExtra = (UnparseableExtraFieldData) field;
} else {
@@ -323,13 +323,13 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable {
* @return an array of the extra fields
* @since 1.1
*/
- public ZipExtraField[] getExtraFields(boolean includeUnparseable) {
+ public ZipExtraField[] getExtraFields(final boolean includeUnparseable) {
if (extraFields == null) {
return !includeUnparseable || unparseableExtra == null
? new ZipExtraField[0]
- : new ZipExtraField[] { unparseableExtra };
+ : new ZipExtraField[] {unparseableExtra};
}
- List<ZipExtraField> result =
+ final List<ZipExtraField> result =
new ArrayList<ZipExtraField>(extraFields.values());
if (includeUnparseable && unparseableExtra != null) {
result.add(unparseableExtra);
@@ -346,7 +346,7 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable {
* @param ze an extra field
* @since 1.1
*/
- public void addExtraField(ZipExtraField ze) {
+ public void addExtraField(final ZipExtraField ze) {
if (ze instanceof UnparseableExtraFieldData) {
unparseableExtra = (UnparseableExtraFieldData) ze;
} else {
@@ -366,11 +366,11 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable {
* @param ze an extra field
* @since 1.1
*/
- public void addAsFirstExtraField(ZipExtraField ze) {
+ public void addAsFirstExtraField(final ZipExtraField ze) {
if (ze instanceof UnparseableExtraFieldData) {
unparseableExtra = (UnparseableExtraFieldData) ze;
} else {
- LinkedHashMap<ZipShort, ZipExtraField> copy = extraFields;
+ final LinkedHashMap<ZipShort, ZipExtraField> copy = extraFields;
extraFields = new LinkedHashMap<ZipShort, ZipExtraField>();
extraFields.put(ze.getHeaderId(), ze);
if (copy != null) {
@@ -386,7 +386,7 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable {
* @param type the type of extra field to remove
* @since 1.1
*/
- public void removeExtraField(ZipShort type) {
+ public void removeExtraField(final ZipShort type) {
if (extraFields == null) {
throw new java.util.NoSuchElementException();
}
@@ -412,7 +412,7 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable {
*
* @return null if no such field exists.
*/
- public ZipExtraField getExtraField(ZipShort type) {
+ public ZipExtraField getExtraField(final ZipShort type) {
if (extraFields != null) {
return extraFields.get(type);
}
@@ -438,13 +438,13 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable {
* @throws RuntimeException on error
*/
@Override
- public void setExtra(byte[] extra) throws RuntimeException {
+ public void setExtra(final byte[] extra) throws RuntimeException {
try {
- ZipExtraField[] local =
+ final ZipExtraField[] local =
ExtraFieldUtils.parse(extra, true,
ExtraFieldUtils.UnparseableExtraField.READ);
mergeExtraFields(local, true);
- } catch (ZipException e) {
+ } catch (final ZipException e) {
// actually this is not be possible as of Ant 1.8.1
throw new RuntimeException("Error parsing extra fields for entry: "
+ getName() + " - " + e.getMessage(), e);
@@ -466,13 +466,13 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable {
/**
* Sets the central directory part of extra fields.
*/
- public void setCentralDirectoryExtra(byte[] b) {
+ public void setCentralDirectoryExtra(final byte[] b) {
try {
- ZipExtraField[] central =
+ final ZipExtraField[] central =
ExtraFieldUtils.parse(b, false,
ExtraFieldUtils.UnparseableExtraField.READ);
mergeExtraFields(central, false);
- } catch (ZipException e) {
+ } catch (final ZipException e) {
throw new RuntimeException(e.getMessage(), e);
}
}
@@ -483,7 +483,7 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable {
* @since 1.1
*/
public byte[] getLocalFileDataExtra() {
- byte[] extra = getExtra();
+ final byte[] extra = getExtra();
return extra != null ? extra : EMPTY;
}
@@ -506,7 +506,8 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable {
* Use setCompressedSize directly.
* @since 1.2
*/
- public void setComprSize(long size) {
+ @Deprecated
+ public void setComprSize(final long size) {
setCompressedSize(size);
}
@@ -558,7 +559,7 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable {
* than 0
*/
@Override
- public void setSize(long size) {
+ public void setSize(final long size) {
if (size < 0) {
throw new IllegalArgumentException("invalid entry size");
}
@@ -573,7 +574,7 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable {
* @param rawName the bytes originally read as name from the
* archive
*/
- protected void setName(String name, byte[] rawName) {
+ protected void setName(final String name, final byte[] rawName) {
setName(name);
this.rawName = rawName;
}
@@ -587,7 +588,7 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable {
*/
public byte[] getRawName() {
if (rawName != null) {
- byte[] b = new byte[rawName.length];
+ final byte[] b = new byte[rawName.length];
System.arraycopy(rawName, 0, b, 0, rawName.length);
return b;
}
@@ -619,7 +620,7 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable {
/**
* The "general purpose bit" field.
*/
- public void setGeneralPurposeBit(GeneralPurposeBit b) {
+ public void setGeneralPurposeBit(final GeneralPurposeBit b) {
gpb = b;
}
@@ -631,12 +632,12 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable {
* @param f the extra fields to merge
* @param local whether the new fields originate from local data
*/
- private void mergeExtraFields(ZipExtraField[] f, boolean local)
+ private void mergeExtraFields(final ZipExtraField[] f, final boolean local)
throws ZipException {
if (extraFields == null) {
setExtraFields(f);
} else {
- for (ZipExtraField element : f) {
+ for (final ZipExtraField element : f) {
ZipExtraField existing;
if (element instanceof UnparseableExtraFieldData) {
existing = unparseableExtra;
@@ -649,10 +650,10 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable {
if (local
|| !(existing
instanceof CentralDirectoryParsingZipExtraField)) {
- byte[] b = element.getLocalFileDataData();
+ final byte[] b = element.getLocalFileDataData();
existing.parseFromLocalFileData(b, 0, b.length);
} else {
- byte[] b = element.getCentralDirectoryData();
+ final byte[] b = element.getCentralDirectoryData();
((CentralDirectoryParsingZipExtraField) existing)
.parseFromCentralDirectoryData(b, 0, b.length);
}
@@ -671,16 +672,16 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable {
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
- ZipEntry other = (ZipEntry) obj;
- String myName = getName();
- String otherName = other.getName();
+ final ZipEntry other = (ZipEntry) obj;
+ final String myName = getName();
+ final String otherName = other.getName();
if (myName == null) {
if (otherName != null) {
return false;
http://git-wip-us.apache.org/repos/asf/ant/blob/1b76f1b6/src/main/org/apache/tools/zip/ZipFile.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/zip/ZipFile.java b/src/main/org/apache/tools/zip/ZipFile.java
index 560314d..05efb33 100644
--- a/src/main/org/apache/tools/zip/ZipFile.java
+++ b/src/main/org/apache/tools/zip/ZipFile.java
@@ -815,7 +815,7 @@ public class ZipFile {
/**
* Skips the given number of bytes or throws an EOFException if
* skipping failed.
- */
+ */
private void skipBytes(final int count) throws IOException {
int totalSkipped = 0;
while (totalSkipped < count) {
@@ -852,7 +852,7 @@ public class ZipFile {
private void resolveLocalFileHeaderData(Map<ZipEntry, NameAndComment>
entriesWithoutUTF8Flag)
throws IOException {
- for (Iterator<ZipEntry> it = entries.iterator(); it.hasNext(); ) {
+ for (Iterator<ZipEntry> it = entries.iterator(); it.hasNext();) {
// entries is filled in populateFromCentralDirectory and
// never modified
Entry ze = (Entry) it.next();
@@ -992,7 +992,8 @@ public class ZipFile {
*/
private final Comparator<ZipEntry> OFFSET_COMPARATOR =
new Comparator<ZipEntry>() {
- public int compare(ZipEntry e1, ZipEntry e2) {
+ @Override
+ public int compare(ZipEntry e1, ZipEntry e2) {
if (e1 == e2) {
return 0;
}