You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2012/11/30 21:52:08 UTC
svn commit: r1415850 [1/15] - in /commons/proper/io/trunk/src:
main/java/org/apache/commons/io/ main/java/org/apache/commons/io/comparator/
main/java/org/apache/commons/io/filefilter/
main/java/org/apache/commons/io/input/ main/java/org/apache/commons/...
Author: ggregory
Date: Fri Nov 30 20:51:39 2012
New Revision: 1415850
URL: http://svn.apache.org/viewvc?rev=1415850&view=rev
Log:
Use final where possible.
Modified:
commons/proper/io/trunk/src/main/java/org/apache/commons/io/ByteOrderMark.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/Charsets.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/CopyUtils.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/DirectoryWalker.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/EndianUtils.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileCleaner.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileCleaningTracker.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileDeleteStrategy.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileExistsException.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileSystemUtils.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileUtils.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/FilenameUtils.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/HexDump.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/IOCase.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/IOExceptionWithCause.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/IOUtils.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/LineIterator.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/TaggedIOException.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/ThreadMonitor.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/comparator/AbstractFileComparator.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/comparator/CompositeFileComparator.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/comparator/DefaultFileComparator.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/comparator/DirectoryFileComparator.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/comparator/ExtensionFileComparator.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/comparator/LastModifiedFileComparator.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/comparator/NameFileComparator.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/comparator/PathFileComparator.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/comparator/ReverseComparator.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/comparator/SizeFileComparator.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/filefilter/AbstractFileFilter.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/filefilter/AgeFileFilter.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/filefilter/AndFileFilter.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/filefilter/CanReadFileFilter.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/filefilter/CanWriteFileFilter.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/filefilter/DelegateFileFilter.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/filefilter/DirectoryFileFilter.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/filefilter/EmptyFileFilter.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/filefilter/FalseFileFilter.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/filefilter/FileFileFilter.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/filefilter/FileFilterUtils.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/filefilter/HiddenFileFilter.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/filefilter/MagicNumberFileFilter.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/filefilter/NameFileFilter.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/filefilter/NotFileFilter.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/filefilter/OrFileFilter.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/filefilter/PrefixFileFilter.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/filefilter/RegexFileFilter.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/filefilter/SizeFileFilter.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/filefilter/SuffixFileFilter.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/filefilter/TrueFileFilter.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/filefilter/WildcardFileFilter.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/filefilter/WildcardFilter.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/AutoCloseInputStream.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/BOMInputStream.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/BoundedInputStream.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/BrokenInputStream.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/CharSequenceInputStream.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/CharSequenceReader.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/ClassLoaderObjectInputStream.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/CloseShieldInputStream.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/CountingInputStream.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/DemuxInputStream.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/NullInputStream.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/NullReader.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/ProxyInputStream.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/ProxyReader.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/ReaderInputStream.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/ReversedLinesFileReader.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/SwappedDataInputStream.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/TaggedInputStream.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/Tailer.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/TailerListenerAdapter.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/TeeInputStream.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/XmlStreamReader.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/XmlStreamReaderException.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/monitor/FileAlterationMonitor.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/monitor/FileAlterationObserver.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/monitor/FileEntry.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/BrokenOutputStream.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/ByteArrayOutputStream.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/CloseShieldOutputStream.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/ClosedOutputStream.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/CountingOutputStream.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/DeferredFileOutputStream.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/DemuxOutputStream.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/FileWriterWithEncoding.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/LockableFileWriter.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/NullOutputStream.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/NullWriter.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/ProxyOutputStream.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/ProxyWriter.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/StringBuilderWriter.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/TaggedOutputStream.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/TeeOutputStream.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/ThresholdingOutputStream.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/WriterOutputStream.java
commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/XmlStreamWriter.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/ByteOrderMarkTestCase.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/CopyUtilsTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/DemuxTestCase.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/DirectoryWalkerTestCase.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/DirectoryWalkerTestCaseJava4.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/EndianUtilsTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileCleanerTestCase.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileCleaningTrackerTestCase.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileDeleteStrategyTestCase.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileSystemUtilsTestCase.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileUtilsCleanDirectoryTestCase.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileUtilsCleanSymlinksTestCase.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileUtilsDirectoryContainsTestCase.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileUtilsFileNewerTestCase.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileUtilsListFilesTestCase.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileUtilsTestCase.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/FileUtilsWaitForTestCase.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/FilenameUtilsTestCase.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/FilenameUtilsWildcardTestCase.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/HexDumpTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOCaseTestCase.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOExceptionWithCauseTestCase.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOUtilsCopyTestCase.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOUtilsTestCase.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOUtilsWriteTestCase.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/LineIteratorTestCase.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/SelectorAdapter.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/TaggedIOExceptionTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/ThreadMonitorTestCase.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/comparator/ComparatorAbstractTestCase.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/comparator/CompositeFileComparatorTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/comparator/DefaultFileComparatorTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/comparator/DirectoryFileComparatorTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/comparator/ExtensionFileComparatorTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/comparator/LastModifiedFileComparatorTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/comparator/NameFileComparatorTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/comparator/PathFileComparatorTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/comparator/SizeFileComparatorTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/filefilter/AndFileFilterTestCase.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/filefilter/ConditionalFileFilterAbstractTestCase.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/filefilter/FileFilterTestCase.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/filefilter/IOFileFilterAbstractTestCase.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/filefilter/OrFileFilterTestCase.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/filefilter/RegexFileFilterTestCase.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/AutoCloseInputStreamTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/BOMInputStreamTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/BoundedInputStreamTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/BrokenInputStreamTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/CharSequenceInputStreamTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/CharSequenceReaderTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/ClassLoaderObjectInputStreamTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/CountingInputStreamTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/NullInputStreamTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/NullReaderTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/ProxyReaderTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/ReaderInputStreamTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/ReversedLinesFileReaderTestParamBlockSize.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/ReversedLinesFileReaderTestParamFile.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/ReversedLinesFileReaderTestSimple.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/SwappedDataInputStreamTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/TaggedInputStreamTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/TailerTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/TeeInputStreamTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/XmlStreamReaderTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/XmlStreamReaderUtilitiesTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/compatibility/XmlStreamReader.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/compatibility/XmlStreamReaderException.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/compatibility/XmlStreamReaderUtilitiesCompatibilityTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/monitor/AbstractMonitorTestCase.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/monitor/CollectionFileListener.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/monitor/FileAlterationMonitorTestCase.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/monitor/FileAlterationObserverTestCase.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/output/BrokenOutputStreamTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/output/ByteArrayOutputStreamTestCase.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/output/CloseShieldOutputStreamTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/output/ClosedOutputStreamTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/output/CountingOutputStreamTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/output/DeferredFileOutputStreamTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/output/FileWriterWithEncodingTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/output/LockableFileWriterTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/output/NullOutputStreamTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/output/NullWriterTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/output/ProxyOutputStreamTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/output/ProxyWriterTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/output/StringBuilderWriterTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/output/TaggedOutputStreamTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/output/TeeOutputStreamTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/output/WriterOutputStreamTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/output/XmlStreamWriterTest.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/testtools/FileBasedTestCase.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/testtools/YellOnCloseInputStream.java
commons/proper/io/trunk/src/test/java/org/apache/commons/io/testtools/YellOnFlushAndCloseOutputStream.java
Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/ByteOrderMark.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/ByteOrderMark.java?rev=1415850&r1=1415849&r2=1415850&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/ByteOrderMark.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/ByteOrderMark.java Fri Nov 30 20:51:39 2012
@@ -66,7 +66,7 @@ public class ByteOrderMark implements Se
* @throws IllegalArgumentException if the bytes are null or zero
* length
*/
- public ByteOrderMark(String charsetName, int... bytes) {
+ public ByteOrderMark(final String charsetName, final int... bytes) {
if (charsetName == null || charsetName.length() == 0) {
throw new IllegalArgumentException("No charsetName specified");
}
@@ -102,7 +102,7 @@ public class ByteOrderMark implements Se
* @param pos The position
* @return The specified byte
*/
- public int get(int pos) {
+ public int get(final int pos) {
return bytes[pos];
}
@@ -112,7 +112,7 @@ public class ByteOrderMark implements Se
* @return a copy of the BOM's bytes
*/
public byte[] getBytes() {
- byte[] copy = new byte[bytes.length];
+ final byte[] copy = new byte[bytes.length];
for (int i = 0; i < bytes.length; i++) {
copy[i] = (byte)bytes[i];
}
@@ -127,11 +127,11 @@ public class ByteOrderMark implements Se
* false
*/
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (!(obj instanceof ByteOrderMark)) {
return false;
}
- ByteOrderMark bom = (ByteOrderMark)obj;
+ final ByteOrderMark bom = (ByteOrderMark)obj;
if (bytes.length != bom.length()) {
return false;
}
@@ -152,7 +152,7 @@ public class ByteOrderMark implements Se
@Override
public int hashCode() {
int hashCode = getClass().hashCode();
- for (int b : bytes) {
+ for (final int b : bytes) {
hashCode += b;
}
return hashCode;
@@ -165,7 +165,7 @@ public class ByteOrderMark implements Se
*/
@Override
public String toString() {
- StringBuilder builder = new StringBuilder();
+ final StringBuilder builder = new StringBuilder();
builder.append(getClass().getSimpleName());
builder.append('[');
builder.append(charsetName);
Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/Charsets.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/Charsets.java?rev=1415850&r1=1415849&r2=1415850&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/Charsets.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/Charsets.java Fri Nov 30 20:51:39 2012
@@ -73,7 +73,7 @@ public class Charsets {
*/
public static SortedMap<String, Charset> requiredCharsets() {
// maybe cache?
- TreeMap<String, Charset> m = new TreeMap<String, Charset>(String.CASE_INSENSITIVE_ORDER);
+ final TreeMap<String, Charset> m = new TreeMap<String, Charset>(String.CASE_INSENSITIVE_ORDER);
m.put(ISO_8859_1.name(), ISO_8859_1);
m.put(US_ASCII.name(), US_ASCII);
m.put(UTF_16.name(), UTF_16);
@@ -90,7 +90,7 @@ public class Charsets {
* A charset or null.
* @return the given Charset or the default Charset if the given Charset is null
*/
- public static Charset toCharset(Charset charset) {
+ public static Charset toCharset(final Charset charset) {
return charset == null ? Charset.defaultCharset() : charset;
}
@@ -103,7 +103,7 @@ public class Charsets {
* @throws UnsupportedCharsetException
* If the named charset is unavailable
*/
- public static Charset toCharset(String charset) {
+ public static Charset toCharset(final String charset) {
return charset == null ? Charset.defaultCharset() : Charset.forName(charset);
}
Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/CopyUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/CopyUtils.java?rev=1415850&r1=1415849&r2=1415850&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/CopyUtils.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/CopyUtils.java Fri Nov 30 20:51:39 2012
@@ -131,7 +131,7 @@ public class CopyUtils {
* @param output the <code>OutputStream</code> to write to
* @throws IOException In case of an I/O problem
*/
- public static void copy(byte[] input, OutputStream output)
+ public static void copy(final byte[] input, final OutputStream output)
throws IOException {
output.write(input);
}
@@ -148,9 +148,9 @@ public class CopyUtils {
* @param output the <code>Writer</code> to write to
* @throws IOException In case of an I/O problem
*/
- public static void copy(byte[] input, Writer output)
+ public static void copy(final byte[] input, final Writer output)
throws IOException {
- ByteArrayInputStream in = new ByteArrayInputStream(input);
+ final ByteArrayInputStream in = new ByteArrayInputStream(input);
copy(in, output);
}
@@ -166,11 +166,11 @@ public class CopyUtils {
* @throws IOException In case of an I/O problem
*/
public static void copy(
- byte[] input,
- Writer output,
- String encoding)
+ final byte[] input,
+ final Writer output,
+ final String encoding)
throws IOException {
- ByteArrayInputStream in = new ByteArrayInputStream(input);
+ final ByteArrayInputStream in = new ByteArrayInputStream(input);
copy(in, output, encoding);
}
@@ -188,10 +188,10 @@ public class CopyUtils {
* @throws IOException In case of an I/O problem
*/
public static int copy(
- InputStream input,
- OutputStream output)
+ final InputStream input,
+ final OutputStream output)
throws IOException {
- byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
+ final byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
int count = 0;
int n = 0;
while (-1 != (n = input.read(buffer))) {
@@ -213,10 +213,10 @@ public class CopyUtils {
* @throws IOException In case of an I/O problem
*/
public static int copy(
- Reader input,
- Writer output)
+ final Reader input,
+ final Writer output)
throws IOException {
- char[] buffer = new char[DEFAULT_BUFFER_SIZE];
+ final char[] buffer = new char[DEFAULT_BUFFER_SIZE];
int count = 0;
int n = 0;
while (-1 != (n = input.read(buffer))) {
@@ -239,10 +239,10 @@ public class CopyUtils {
* @throws IOException In case of an I/O problem
*/
public static void copy(
- InputStream input,
- Writer output)
+ final InputStream input,
+ final Writer output)
throws IOException {
- InputStreamReader in = new InputStreamReader(input);
+ final InputStreamReader in = new InputStreamReader(input);
copy(in, output);
}
@@ -257,11 +257,11 @@ public class CopyUtils {
* @throws IOException In case of an I/O problem
*/
public static void copy(
- InputStream input,
- Writer output,
- String encoding)
+ final InputStream input,
+ final Writer output,
+ final String encoding)
throws IOException {
- InputStreamReader in = new InputStreamReader(input, encoding);
+ final InputStreamReader in = new InputStreamReader(input, encoding);
copy(in, output);
}
@@ -278,10 +278,10 @@ public class CopyUtils {
* @throws IOException In case of an I/O problem
*/
public static void copy(
- Reader input,
- OutputStream output)
+ final Reader input,
+ final OutputStream output)
throws IOException {
- OutputStreamWriter out = new OutputStreamWriter(output);
+ final OutputStreamWriter out = new OutputStreamWriter(output);
copy(input, out);
// XXX Unless anyone is planning on rewriting OutputStreamWriter, we
// have to flush here.
@@ -301,11 +301,11 @@ public class CopyUtils {
* @throws IOException In case of an I/O problem
*/
public static void copy(
- String input,
- OutputStream output)
+ final String input,
+ final OutputStream output)
throws IOException {
- StringReader in = new StringReader(input);
- OutputStreamWriter out = new OutputStreamWriter(output);
+ final StringReader in = new StringReader(input);
+ final OutputStreamWriter out = new OutputStreamWriter(output);
copy(in, out);
// XXX Unless anyone is planning on rewriting OutputStreamWriter, we
// have to flush here.
@@ -322,7 +322,7 @@ public class CopyUtils {
* @param output the <code>Writer</code> to write to
* @throws IOException In case of an I/O problem
*/
- public static void copy(String input, Writer output)
+ public static void copy(final String input, final Writer output)
throws IOException {
output.write(input);
}
Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/DirectoryWalker.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/DirectoryWalker.java?rev=1415850&r1=1415849&r2=1415850&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/DirectoryWalker.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/DirectoryWalker.java Fri Nov 30 20:51:39 2012
@@ -278,7 +278,7 @@ public abstract class DirectoryWalker<T>
* @param depthLimit controls how <i>deep</i> the hierarchy is
* navigated to (less than 0 means unlimited)
*/
- protected DirectoryWalker(FileFilter filter, int depthLimit) {
+ protected DirectoryWalker(final FileFilter filter, final int depthLimit) {
this.filter = filter;
this.depthLimit = depthLimit;
}
@@ -297,7 +297,7 @@ public abstract class DirectoryWalker<T>
* @param depthLimit controls how <i>deep</i> the hierarchy is
* navigated to (less than 0 means unlimited)
*/
- protected DirectoryWalker(IOFileFilter directoryFilter, IOFileFilter fileFilter, int depthLimit) {
+ protected DirectoryWalker(IOFileFilter directoryFilter, IOFileFilter fileFilter, final int depthLimit) {
if (directoryFilter == null && fileFilter == null) {
this.filter = null;
} else {
@@ -326,7 +326,7 @@ public abstract class DirectoryWalker<T>
* @throws NullPointerException if the start directory is null
* @throws IOException if an I/O Error occurs
*/
- protected final void walk(File startDirectory, Collection<T> results) throws IOException {
+ protected final void walk(final File startDirectory, final Collection<T> results) throws IOException {
if (startDirectory == null) {
throw new NullPointerException("Start Directory is null");
}
@@ -334,7 +334,7 @@ public abstract class DirectoryWalker<T>
handleStart(startDirectory, results);
walk(startDirectory, 0, results);
handleEnd(results);
- } catch(CancelException cancel) {
+ } catch(final CancelException cancel) {
handleCancelled(startDirectory, results, cancel);
}
}
@@ -347,11 +347,11 @@ public abstract class DirectoryWalker<T>
* @param results the collection of result objects, may be updated
* @throws IOException if an I/O Error occurs
*/
- private void walk(File directory, int depth, Collection<T> results) throws IOException {
+ private void walk(final File directory, final int depth, final Collection<T> results) throws IOException {
checkIfCancelled(directory, depth, results);
if (handleDirectory(directory, depth, results)) {
handleDirectoryStart(directory, depth, results);
- int childDepth = depth + 1;
+ final int childDepth = depth + 1;
if (depthLimit < 0 || childDepth <= depthLimit) {
checkIfCancelled(directory, depth, results);
File[] childFiles = filter == null ? directory.listFiles() : directory.listFiles(filter);
@@ -359,7 +359,7 @@ public abstract class DirectoryWalker<T>
if (childFiles == null) {
handleRestricted(directory, childDepth, results);
} else {
- for (File childFile : childFiles) {
+ for (final File childFile : childFiles) {
if (childFile.isDirectory()) {
walk(childFile, childDepth, results);
} else {
@@ -390,7 +390,7 @@ public abstract class DirectoryWalker<T>
* @param results the collection of result objects, may be updated
* @throws IOException if an I/O Error occurs
*/
- protected final void checkIfCancelled(File file, int depth, Collection<T> results) throws IOException {
+ protected final void checkIfCancelled(final File file, final int depth, final Collection<T> results) throws IOException {
if (handleIsCancelled(file, depth, results)) {
throw new CancelException(file, depth);
}
@@ -432,7 +432,7 @@ public abstract class DirectoryWalker<T>
* @throws IOException if an I/O Error occurs
*/
protected boolean handleIsCancelled(
- File file, int depth, Collection<T> results) throws IOException {
+ final File file, final int depth, final Collection<T> results) throws IOException {
// do nothing - overridable by subclass
return false; // not cancelled
}
@@ -450,8 +450,8 @@ public abstract class DirectoryWalker<T>
* containing details at the point of cancellation.
* @throws IOException if an I/O Error occurs
*/
- protected void handleCancelled(File startDirectory, Collection<T> results,
- CancelException cancel) throws IOException {
+ protected void handleCancelled(final File startDirectory, final Collection<T> results,
+ final CancelException cancel) throws IOException {
// re-throw exception - overridable by subclass
throw cancel;
}
@@ -466,7 +466,7 @@ public abstract class DirectoryWalker<T>
* @param results the collection of result objects, may be updated
* @throws IOException if an I/O Error occurs
*/
- protected void handleStart(File startDirectory, Collection<T> results) throws IOException {
+ protected void handleStart(final File startDirectory, final Collection<T> results) throws IOException {
// do nothing - overridable by subclass
}
@@ -485,7 +485,7 @@ public abstract class DirectoryWalker<T>
* @return true to process this directory, false to skip this directory
* @throws IOException if an I/O Error occurs
*/
- protected boolean handleDirectory(File directory, int depth, Collection<T> results) throws IOException {
+ protected boolean handleDirectory(final File directory, final int depth, final Collection<T> results) throws IOException {
// do nothing - overridable by subclass
return true; // process directory
}
@@ -500,7 +500,7 @@ public abstract class DirectoryWalker<T>
* @param results the collection of result objects, may be updated
* @throws IOException if an I/O Error occurs
*/
- protected void handleDirectoryStart(File directory, int depth, Collection<T> results) throws IOException {
+ protected void handleDirectoryStart(final File directory, final int depth, final Collection<T> results) throws IOException {
// do nothing - overridable by subclass
}
@@ -516,7 +516,7 @@ public abstract class DirectoryWalker<T>
* @throws IOException if an I/O Error occurs
* @since 2.0
*/
- protected File[] filterDirectoryContents(File directory, int depth, File[] files) throws IOException {
+ protected File[] filterDirectoryContents(final File directory, final int depth, final File[] files) throws IOException {
return files;
}
@@ -530,7 +530,7 @@ public abstract class DirectoryWalker<T>
* @param results the collection of result objects, may be updated
* @throws IOException if an I/O Error occurs
*/
- protected void handleFile(File file, int depth, Collection<T> results) throws IOException {
+ protected void handleFile(final File file, final int depth, final Collection<T> results) throws IOException {
// do nothing - overridable by subclass
}
@@ -544,7 +544,7 @@ public abstract class DirectoryWalker<T>
* @param results the collection of result objects, may be updated
* @throws IOException if an I/O Error occurs
*/
- protected void handleRestricted(File directory, int depth, Collection<T> results) throws IOException {
+ protected void handleRestricted(final File directory, final int depth, final Collection<T> results) throws IOException {
// do nothing - overridable by subclass
}
@@ -558,7 +558,7 @@ public abstract class DirectoryWalker<T>
* @param results the collection of result objects, may be updated
* @throws IOException if an I/O Error occurs
*/
- protected void handleDirectoryEnd(File directory, int depth, Collection<T> results) throws IOException {
+ protected void handleDirectoryEnd(final File directory, final int depth, final Collection<T> results) throws IOException {
// do nothing - overridable by subclass
}
@@ -570,7 +570,7 @@ public abstract class DirectoryWalker<T>
* @param results the collection of result objects, may be updated
* @throws IOException if an I/O Error occurs
*/
- protected void handleEnd(Collection<T> results) throws IOException {
+ protected void handleEnd(final Collection<T> results) throws IOException {
// do nothing - overridable by subclass
}
@@ -596,7 +596,7 @@ public abstract class DirectoryWalker<T>
* @param file the file when the operation was cancelled, may be null
* @param depth the depth when the operation was cancelled, may be null
*/
- public CancelException(File file, int depth) {
+ public CancelException(final File file, final int depth) {
this("Operation Cancelled", file, depth);
}
@@ -609,7 +609,7 @@ public abstract class DirectoryWalker<T>
* @param file the file when the operation was cancelled
* @param depth the depth when the operation was cancelled
*/
- public CancelException(String message, File file, int depth) {
+ public CancelException(final String message, final File file, final int depth) {
super(message);
this.file = file;
this.depth = depth;
Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/EndianUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/EndianUtils.java?rev=1415850&r1=1415849&r2=1415850&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/EndianUtils.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/EndianUtils.java Fri Nov 30 20:51:39 2012
@@ -52,7 +52,7 @@ public class EndianUtils {
* @param value value to convert
* @return the converted value
*/
- public static short swapShort(short value) {
+ public static short swapShort(final short value) {
return (short) ( ( ( ( value >> 0 ) & 0xff ) << 8 ) +
( ( ( value >> 8 ) & 0xff ) << 0 ) );
}
@@ -62,7 +62,7 @@ public class EndianUtils {
* @param value value to convert
* @return the converted value
*/
- public static int swapInteger(int value) {
+ public static int swapInteger(final int value) {
return
( ( ( value >> 0 ) & 0xff ) << 24 ) +
( ( ( value >> 8 ) & 0xff ) << 16 ) +
@@ -75,7 +75,7 @@ public class EndianUtils {
* @param value value to convert
* @return the converted value
*/
- public static long swapLong(long value) {
+ public static long swapLong(final long value) {
return
( ( ( value >> 0 ) & 0xff ) << 56 ) +
( ( ( value >> 8 ) & 0xff ) << 48 ) +
@@ -92,7 +92,7 @@ public class EndianUtils {
* @param value value to convert
* @return the converted value
*/
- public static float swapFloat(float value) {
+ public static float swapFloat(final float value) {
return Float.intBitsToFloat( swapInteger( Float.floatToIntBits( value ) ) );
}
@@ -101,7 +101,7 @@ public class EndianUtils {
* @param value value to convert
* @return the converted value
*/
- public static double swapDouble(double value) {
+ public static double swapDouble(final double value) {
return Double.longBitsToDouble( swapLong( Double.doubleToLongBits( value ) ) );
}
@@ -114,7 +114,7 @@ public class EndianUtils {
* @param offset starting offset in the byte array
* @param value value to write
*/
- public static void writeSwappedShort(byte[] data, int offset, short value) {
+ public static void writeSwappedShort(final byte[] data, final int offset, final short value) {
data[ offset + 0 ] = (byte)( ( value >> 0 ) & 0xff );
data[ offset + 1 ] = (byte)( ( value >> 8 ) & 0xff );
}
@@ -126,7 +126,7 @@ public class EndianUtils {
* @param offset starting offset in the byte array
* @return the value read
*/
- public static short readSwappedShort(byte[] data, int offset) {
+ public static short readSwappedShort(final byte[] data, final int offset) {
return (short)( ( ( data[ offset + 0 ] & 0xff ) << 0 ) +
( ( data[ offset + 1 ] & 0xff ) << 8 ) );
}
@@ -139,7 +139,7 @@ public class EndianUtils {
* @param offset starting offset in the byte array
* @return the value read
*/
- public static int readSwappedUnsignedShort(byte[] data, int offset) {
+ public static int readSwappedUnsignedShort(final byte[] data, final int offset) {
return ( ( ( data[ offset + 0 ] & 0xff ) << 0 ) +
( ( data[ offset + 1 ] & 0xff ) << 8 ) );
}
@@ -151,7 +151,7 @@ public class EndianUtils {
* @param offset starting offset in the byte array
* @param value value to write
*/
- public static void writeSwappedInteger(byte[] data, int offset, int value) {
+ public static void writeSwappedInteger(final byte[] data, final int offset, final int value) {
data[ offset + 0 ] = (byte)( ( value >> 0 ) & 0xff );
data[ offset + 1 ] = (byte)( ( value >> 8 ) & 0xff );
data[ offset + 2 ] = (byte)( ( value >> 16 ) & 0xff );
@@ -165,7 +165,7 @@ public class EndianUtils {
* @param offset starting offset in the byte array
* @return the value read
*/
- public static int readSwappedInteger(byte[] data, int offset) {
+ public static int readSwappedInteger(final byte[] data, final int offset) {
return ( ( ( data[ offset + 0 ] & 0xff ) << 0 ) +
( ( data[ offset + 1 ] & 0xff ) << 8 ) +
( ( data[ offset + 2 ] & 0xff ) << 16 ) +
@@ -180,12 +180,12 @@ public class EndianUtils {
* @param offset starting offset in the byte array
* @return the value read
*/
- public static long readSwappedUnsignedInteger(byte[] data, int offset) {
- long low = ( ( ( data[ offset + 0 ] & 0xff ) << 0 ) +
+ public static long readSwappedUnsignedInteger(final byte[] data, final int offset) {
+ final long low = ( ( ( data[ offset + 0 ] & 0xff ) << 0 ) +
( ( data[ offset + 1 ] & 0xff ) << 8 ) +
( ( data[ offset + 2 ] & 0xff ) << 16 ) );
- long high = data[ offset + 3 ] & 0xff;
+ final long high = data[ offset + 3 ] & 0xff;
return (high << 24) + (0xffffffffL & low);
}
@@ -197,7 +197,7 @@ public class EndianUtils {
* @param offset starting offset in the byte array
* @param value value to write
*/
- public static void writeSwappedLong(byte[] data, int offset, long value) {
+ public static void writeSwappedLong(final byte[] data, final int offset, final long value) {
data[ offset + 0 ] = (byte)( ( value >> 0 ) & 0xff );
data[ offset + 1 ] = (byte)( ( value >> 8 ) & 0xff );
data[ offset + 2 ] = (byte)( ( value >> 16 ) & 0xff );
@@ -215,13 +215,13 @@ public class EndianUtils {
* @param offset starting offset in the byte array
* @return the value read
*/
- public static long readSwappedLong(byte[] data, int offset) {
- long low =
+ public static long readSwappedLong(final byte[] data, final int offset) {
+ final long low =
( ( data[ offset + 0 ] & 0xff ) << 0 ) +
( ( data[ offset + 1 ] & 0xff ) << 8 ) +
( ( data[ offset + 2 ] & 0xff ) << 16 ) +
( ( data[ offset + 3 ] & 0xff ) << 24 );
- long high =
+ final long high =
( ( data[ offset + 4 ] & 0xff ) << 0 ) +
( ( data[ offset + 5 ] & 0xff ) << 8 ) +
( ( data[ offset + 6 ] & 0xff ) << 16 ) +
@@ -236,7 +236,7 @@ public class EndianUtils {
* @param offset starting offset in the byte array
* @param value value to write
*/
- public static void writeSwappedFloat(byte[] data, int offset, float value) {
+ public static void writeSwappedFloat(final byte[] data, final int offset, final float value) {
writeSwappedInteger( data, offset, Float.floatToIntBits( value ) );
}
@@ -247,7 +247,7 @@ public class EndianUtils {
* @param offset starting offset in the byte array
* @return the value read
*/
- public static float readSwappedFloat(byte[] data, int offset) {
+ public static float readSwappedFloat(final byte[] data, final int offset) {
return Float.intBitsToFloat( readSwappedInteger( data, offset ) );
}
@@ -258,7 +258,7 @@ public class EndianUtils {
* @param offset starting offset in the byte array
* @param value value to write
*/
- public static void writeSwappedDouble(byte[] data, int offset, double value) {
+ public static void writeSwappedDouble(final byte[] data, final int offset, final double value) {
writeSwappedLong( data, offset, Double.doubleToLongBits( value ) );
}
@@ -269,7 +269,7 @@ public class EndianUtils {
* @param offset starting offset in the byte array
* @return the value read
*/
- public static double readSwappedDouble(byte[] data, int offset) {
+ public static double readSwappedDouble(final byte[] data, final int offset) {
return Double.longBitsToDouble( readSwappedLong( data, offset ) );
}
@@ -280,7 +280,7 @@ public class EndianUtils {
* @param value value to write
* @throws IOException in case of an I/O problem
*/
- public static void writeSwappedShort(OutputStream output, short value)
+ public static void writeSwappedShort(final OutputStream output, final short value)
throws IOException
{
output.write( (byte)( ( value >> 0 ) & 0xff ) );
@@ -294,7 +294,7 @@ public class EndianUtils {
* @return the value just read
* @throws IOException in case of an I/O problem
*/
- public static short readSwappedShort(InputStream input)
+ public static short readSwappedShort(final InputStream input)
throws IOException
{
return (short)( ( ( read( input ) & 0xff ) << 0 ) +
@@ -308,11 +308,11 @@ public class EndianUtils {
* @return the value just read
* @throws IOException in case of an I/O problem
*/
- public static int readSwappedUnsignedShort(InputStream input)
+ public static int readSwappedUnsignedShort(final InputStream input)
throws IOException
{
- int value1 = read( input );
- int value2 = read( input );
+ final int value1 = read( input );
+ final int value2 = read( input );
return ( ( ( value1 & 0xff ) << 0 ) +
( ( value2 & 0xff ) << 8 ) );
@@ -325,7 +325,7 @@ public class EndianUtils {
* @param value value to write
* @throws IOException in case of an I/O problem
*/
- public static void writeSwappedInteger(OutputStream output, int value)
+ public static void writeSwappedInteger(final OutputStream output, final int value)
throws IOException
{
output.write( (byte)( ( value >> 0 ) & 0xff ) );
@@ -341,13 +341,13 @@ public class EndianUtils {
* @return the value just read
* @throws IOException in case of an I/O problem
*/
- public static int readSwappedInteger(InputStream input)
+ public static int readSwappedInteger(final InputStream input)
throws IOException
{
- int value1 = read( input );
- int value2 = read( input );
- int value3 = read( input );
- int value4 = read( input );
+ final int value1 = read( input );
+ final int value2 = read( input );
+ final int value3 = read( input );
+ final int value4 = read( input );
return ( ( value1 & 0xff ) << 0 ) +
( ( value2 & 0xff ) << 8 ) +
@@ -362,19 +362,19 @@ public class EndianUtils {
* @return the value just read
* @throws IOException in case of an I/O problem
*/
- public static long readSwappedUnsignedInteger(InputStream input)
+ public static long readSwappedUnsignedInteger(final InputStream input)
throws IOException
{
- int value1 = read( input );
- int value2 = read( input );
- int value3 = read( input );
- int value4 = read( input );
+ final int value1 = read( input );
+ final int value2 = read( input );
+ final int value3 = read( input );
+ final int value4 = read( input );
- long low = ( ( ( value1 & 0xff ) << 0 ) +
+ final long low = ( ( ( value1 & 0xff ) << 0 ) +
( ( value2 & 0xff ) << 8 ) +
( ( value3 & 0xff ) << 16 ) );
- long high = value4 & 0xff;
+ final long high = value4 & 0xff;
return (high << 24) + (0xffffffffL & low);
}
@@ -386,7 +386,7 @@ public class EndianUtils {
* @param value value to write
* @throws IOException in case of an I/O problem
*/
- public static void writeSwappedLong(OutputStream output, long value)
+ public static void writeSwappedLong(final OutputStream output, final long value)
throws IOException
{
output.write( (byte)( ( value >> 0 ) & 0xff ) );
@@ -406,10 +406,10 @@ public class EndianUtils {
* @return the value just read
* @throws IOException in case of an I/O problem
*/
- public static long readSwappedLong(InputStream input)
+ public static long readSwappedLong(final InputStream input)
throws IOException
{
- byte[] bytes = new byte[8];
+ final byte[] bytes = new byte[8];
for ( int i=0; i<8; i++ ) {
bytes[i] = (byte) read( input );
}
@@ -423,7 +423,7 @@ public class EndianUtils {
* @param value value to write
* @throws IOException in case of an I/O problem
*/
- public static void writeSwappedFloat(OutputStream output, float value)
+ public static void writeSwappedFloat(final OutputStream output, final float value)
throws IOException
{
writeSwappedInteger( output, Float.floatToIntBits( value ) );
@@ -436,7 +436,7 @@ public class EndianUtils {
* @return the value just read
* @throws IOException in case of an I/O problem
*/
- public static float readSwappedFloat(InputStream input)
+ public static float readSwappedFloat(final InputStream input)
throws IOException
{
return Float.intBitsToFloat( readSwappedInteger( input ) );
@@ -449,7 +449,7 @@ public class EndianUtils {
* @param value value to write
* @throws IOException in case of an I/O problem
*/
- public static void writeSwappedDouble(OutputStream output, double value)
+ public static void writeSwappedDouble(final OutputStream output, final double value)
throws IOException
{
writeSwappedLong( output, Double.doubleToLongBits( value ) );
@@ -462,7 +462,7 @@ public class EndianUtils {
* @return the value just read
* @throws IOException in case of an I/O problem
*/
- public static double readSwappedDouble(InputStream input)
+ public static double readSwappedDouble(final InputStream input)
throws IOException
{
return Double.longBitsToDouble( readSwappedLong( input ) );
@@ -474,10 +474,10 @@ public class EndianUtils {
* @return the byte
* @throws IOException if the end of file is reached
*/
- private static int read(InputStream input)
+ private static int read(final InputStream input)
throws IOException
{
- int value = input.read();
+ final int value = input.read();
if( -1 == value ) {
throw new EOFException( "Unexpected EOF reached" );
Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileCleaner.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileCleaner.java?rev=1415850&r1=1415849&r2=1415850&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileCleaner.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileCleaner.java Fri Nov 30 20:51:39 2012
@@ -54,7 +54,7 @@ public class FileCleaner {
* @deprecated Use {@link FileCleaningTracker#track(File, Object)}.
*/
@Deprecated
- public static void track(File file, Object marker) {
+ public static void track(final File file, final Object marker) {
theInstance.track(file, marker);
}
@@ -70,7 +70,7 @@ public class FileCleaner {
* @deprecated Use {@link FileCleaningTracker#track(File, Object, FileDeleteStrategy)}.
*/
@Deprecated
- public static void track(File file, Object marker, FileDeleteStrategy deleteStrategy) {
+ public static void track(final File file, final Object marker, final FileDeleteStrategy deleteStrategy) {
theInstance.track(file, marker, deleteStrategy);
}
@@ -85,7 +85,7 @@ public class FileCleaner {
* @deprecated Use {@link FileCleaningTracker#track(String, Object)}.
*/
@Deprecated
- public static void track(String path, Object marker) {
+ public static void track(final String path, final Object marker) {
theInstance.track(path, marker);
}
@@ -101,7 +101,7 @@ public class FileCleaner {
* @deprecated Use {@link FileCleaningTracker#track(String, Object, FileDeleteStrategy)}.
*/
@Deprecated
- public static void track(String path, Object marker, FileDeleteStrategy deleteStrategy) {
+ public static void track(final String path, final Object marker, final FileDeleteStrategy deleteStrategy) {
theInstance.track(path, marker, deleteStrategy);
}
Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileCleaningTracker.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileCleaningTracker.java?rev=1415850&r1=1415849&r2=1415850&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileCleaningTracker.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileCleaningTracker.java Fri Nov 30 20:51:39 2012
@@ -73,7 +73,7 @@ public class FileCleaningTracker {
* @param marker the marker object used to track the file, not null
* @throws NullPointerException if the file is null
*/
- public void track(File file, Object marker) {
+ public void track(final File file, final Object marker) {
track(file, marker, (FileDeleteStrategy) null);
}
@@ -87,7 +87,7 @@ public class FileCleaningTracker {
* @param deleteStrategy the strategy to delete the file, null means normal
* @throws NullPointerException if the file is null
*/
- public void track(File file, Object marker, FileDeleteStrategy deleteStrategy) {
+ public void track(final File file, final Object marker, final FileDeleteStrategy deleteStrategy) {
if (file == null) {
throw new NullPointerException("The file must not be null");
}
@@ -103,7 +103,7 @@ public class FileCleaningTracker {
* @param marker the marker object used to track the file, not null
* @throws NullPointerException if the path is null
*/
- public void track(String path, Object marker) {
+ public void track(final String path, final Object marker) {
track(path, marker, (FileDeleteStrategy) null);
}
@@ -117,7 +117,7 @@ public class FileCleaningTracker {
* @param deleteStrategy the strategy to delete the file, null means normal
* @throws NullPointerException if the path is null
*/
- public void track(String path, Object marker, FileDeleteStrategy deleteStrategy) {
+ public void track(final String path, final Object marker, final FileDeleteStrategy deleteStrategy) {
if (path == null) {
throw new NullPointerException("The path must not be null");
}
@@ -131,7 +131,7 @@ public class FileCleaningTracker {
* @param marker the marker object used to track the file, not null
* @param deleteStrategy the strategy to delete the file, null means normal
*/
- private synchronized void addTracker(String path, Object marker, FileDeleteStrategy deleteStrategy) {
+ private synchronized void addTracker(final String path, final Object marker, final FileDeleteStrategy deleteStrategy) {
// synchronized block protects reaper
if (exitWhenFinished) {
throw new IllegalStateException("No new trackers can be added once exitWhenFinished() is called");
@@ -217,13 +217,13 @@ public class FileCleaningTracker {
while (exitWhenFinished == false || trackers.size() > 0) {
try {
// Wait for a tracker to remove.
- Tracker tracker = (Tracker) q.remove(); // cannot return null
+ final Tracker tracker = (Tracker) q.remove(); // cannot return null
trackers.remove(tracker);
if (!tracker.delete()) {
deleteFailures.add(tracker.getPath());
}
tracker.clear();
- } catch (InterruptedException e) {
+ } catch (final InterruptedException e) {
continue;
}
}
@@ -253,7 +253,7 @@ public class FileCleaningTracker {
* @param marker the marker object used to track the file, not null
* @param queue the queue on to which the tracker will be pushed, not null
*/
- Tracker(String path, FileDeleteStrategy deleteStrategy, Object marker, ReferenceQueue<? super Object> queue) {
+ Tracker(final String path, final FileDeleteStrategy deleteStrategy, final Object marker, final ReferenceQueue<? super Object> queue) {
super(marker, queue);
this.path = path;
this.deleteStrategy = deleteStrategy == null ? FileDeleteStrategy.NORMAL : deleteStrategy;
Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileDeleteStrategy.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileDeleteStrategy.java?rev=1415850&r1=1415849&r2=1415850&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileDeleteStrategy.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileDeleteStrategy.java Fri Nov 30 20:51:39 2012
@@ -53,7 +53,7 @@ public class FileDeleteStrategy {
*
* @param name the name by which the strategy is known
*/
- protected FileDeleteStrategy(String name) {
+ protected FileDeleteStrategy(final String name) {
this.name = name;
}
@@ -68,13 +68,13 @@ public class FileDeleteStrategy {
* @param fileToDelete the file to delete, null returns true
* @return true if the file was deleted, or there was no such file
*/
- public boolean deleteQuietly(File fileToDelete) {
+ public boolean deleteQuietly(final File fileToDelete) {
if (fileToDelete == null || fileToDelete.exists() == false) {
return true;
}
try {
return doDelete(fileToDelete);
- } catch (IOException ex) {
+ } catch (final IOException ex) {
return false;
}
}
@@ -89,7 +89,7 @@ public class FileDeleteStrategy {
* @throws NullPointerException if the file is null
* @throws IOException if an error occurs during file deletion
*/
- public void delete(File fileToDelete) throws IOException {
+ public void delete(final File fileToDelete) throws IOException {
if (fileToDelete.exists() && doDelete(fileToDelete) == false) {
throw new IOException("Deletion failed: " + fileToDelete);
}
@@ -111,7 +111,7 @@ public class FileDeleteStrategy {
* @throws NullPointerException if the file is null
* @throws IOException if an error occurs during file deletion
*/
- protected boolean doDelete(File fileToDelete) throws IOException {
+ protected boolean doDelete(final File fileToDelete) throws IOException {
return fileToDelete.delete();
}
@@ -148,7 +148,7 @@ public class FileDeleteStrategy {
* @throws IOException if an error occurs during file deletion
*/
@Override
- protected boolean doDelete(File fileToDelete) throws IOException {
+ protected boolean doDelete(final File fileToDelete) throws IOException {
FileUtils.forceDelete(fileToDelete);
return true;
}
Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileExistsException.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileExistsException.java?rev=1415850&r1=1415849&r2=1415850&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileExistsException.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileExistsException.java Fri Nov 30 20:51:39 2012
@@ -44,7 +44,7 @@ public class FileExistsException extends
*
* @param message The error message
*/
- public FileExistsException(String message) {
+ public FileExistsException(final String message) {
super(message);
}
@@ -53,7 +53,7 @@ public class FileExistsException extends
*
* @param file The file that exists
*/
- public FileExistsException(File file) {
+ public FileExistsException(final File file) {
super("File " + file + " exists");
}
Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileSystemUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileSystemUtils.java?rev=1415850&r1=1415849&r2=1415850&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileSystemUtils.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileSystemUtils.java Fri Nov 30 20:51:39 2012
@@ -96,7 +96,7 @@ public class FileSystemUtils {
os = OTHER;
}
- } catch (Exception ex) {
+ } catch (final Exception ex) {
os = INIT_PROBLEM;
}
OS = os;
@@ -138,7 +138,7 @@ public class FileSystemUtils {
* Deprecated from 1.3, may be removed in 2.0
*/
@Deprecated
- public static long freeSpace(String path) throws IOException {
+ public static long freeSpace(final String path) throws IOException {
return INSTANCE.freeSpaceOS(path, OS, false, -1);
}
@@ -167,7 +167,7 @@ public class FileSystemUtils {
* @throws IOException if an error occurs when finding the free space
* @since 1.2, enhanced OS support in 1.3
*/
- public static long freeSpaceKb(String path) throws IOException {
+ public static long freeSpaceKb(final String path) throws IOException {
return freeSpaceKb(path, -1);
}
/**
@@ -196,7 +196,7 @@ public class FileSystemUtils {
* @throws IOException if an error occurs when finding the free space
* @since 2.0
*/
- public static long freeSpaceKb(String path, long timeout) throws IOException {
+ public static long freeSpaceKb(final String path, final long timeout) throws IOException {
return INSTANCE.freeSpaceOS(path, OS, true, timeout);
}
@@ -230,7 +230,7 @@ public class FileSystemUtils {
* @throws IOException if an error occurs when finding the free space
* @since 2.0
*/
- public static long freeSpaceKb(long timeout) throws IOException {
+ public static long freeSpaceKb(final long timeout) throws IOException {
return freeSpaceKb(new File(".").getAbsolutePath(), timeout);
}
@@ -255,7 +255,7 @@ public class FileSystemUtils {
* @throws IllegalStateException if an error occurred in initialisation
* @throws IOException if an error occurs when finding the free space
*/
- long freeSpaceOS(String path, int os, boolean kb, long timeout) throws IOException {
+ long freeSpaceOS(final String path, final int os, final boolean kb, final long timeout) throws IOException {
if (path == null) {
throw new IllegalArgumentException("Path must not be empty");
}
@@ -284,24 +284,24 @@ public class FileSystemUtils {
* @return the amount of free drive space on the drive
* @throws IOException if an error occurs
*/
- long freeSpaceWindows(String path, long timeout) throws IOException {
+ long freeSpaceWindows(String path, final long timeout) throws IOException {
path = FilenameUtils.normalize(path, false);
if (path.length() > 0 && path.charAt(0) != '"') {
path = "\"" + path + "\"";
}
// build and run the 'dir' command
- String[] cmdAttribs = new String[] {"cmd.exe", "/C", "dir /a /-c " + path};
+ final String[] cmdAttribs = new String[] {"cmd.exe", "/C", "dir /a /-c " + path};
// read in the output of the command to an ArrayList
- List<String> lines = performCommand(cmdAttribs, Integer.MAX_VALUE, timeout);
+ final List<String> lines = performCommand(cmdAttribs, Integer.MAX_VALUE, timeout);
// now iterate over the lines we just read and find the LAST
// non-empty line (the free space bytes should be in the last element
// of the ArrayList anyway, but this will ensure it works even if it's
// not, still assuming it is on the last non-blank line)
for (int i = lines.size() - 1; i >= 0; i--) {
- String line = lines.get(i);
+ final String line = lines.get(i);
if (line.length() > 0) {
return parseDir(line, path);
}
@@ -320,7 +320,7 @@ public class FileSystemUtils {
* @return the number of bytes
* @throws IOException if an error occurs
*/
- long parseDir(String line, String path) throws IOException {
+ long parseDir(final String line, final String path) throws IOException {
// read from the end of the line to find the last numeric
// character on the line, then continue until we find the first
// non-numeric character, and everything between that and the last
@@ -329,7 +329,7 @@ public class FileSystemUtils {
int bytesEnd = 0;
int j = line.length() - 1;
innerLoop1: while (j >= 0) {
- char c = line.charAt(j);
+ final char c = line.charAt(j);
if (Character.isDigit(c)) {
// found the last numeric character, this is the end of
// the free space bytes count
@@ -339,7 +339,7 @@ public class FileSystemUtils {
j--;
}
innerLoop2: while (j >= 0) {
- char c = line.charAt(j);
+ final char c = line.charAt(j);
if (!Character.isDigit(c) && c != ',' && c != '.') {
// found the next non-numeric character, this is the
// beginning of the free space bytes count
@@ -355,7 +355,7 @@ public class FileSystemUtils {
}
// remove commas and dots in the bytes count
- StringBuilder buf = new StringBuilder(line.substring(bytesStart, bytesEnd));
+ final StringBuilder buf = new StringBuilder(line.substring(bytesStart, bytesEnd));
for (int k = 0; k < buf.length(); k++) {
if (buf.charAt(k) == ',' || buf.charAt(k) == '.') {
buf.deleteCharAt(k--);
@@ -376,7 +376,7 @@ public class FileSystemUtils {
* @return the amount of free drive space on the volume
* @throws IOException if an error occurs
*/
- long freeSpaceUnix(String path, boolean kb, boolean posix, long timeout) throws IOException {
+ long freeSpaceUnix(final String path, final boolean kb, final boolean posix, final long timeout) throws IOException {
if (path.length() == 0) {
throw new IllegalArgumentException("Path must not be empty");
}
@@ -389,25 +389,25 @@ public class FileSystemUtils {
if (posix) {
flags += "P";
}
- String[] cmdAttribs =
+ final String[] cmdAttribs =
flags.length() > 1 ? new String[] {DF, flags, path} : new String[] {DF, path};
// perform the command, asking for up to 3 lines (header, interesting, overflow)
- List<String> lines = performCommand(cmdAttribs, 3, timeout);
+ final List<String> lines = performCommand(cmdAttribs, 3, timeout);
if (lines.size() < 2) {
// unknown problem, throw exception
throw new IOException(
"Command line '" + DF + "' did not return info as expected " +
"for path '" + path + "'- response was " + lines);
}
- String line2 = lines.get(1); // the line we're interested in
+ final String line2 = lines.get(1); // the line we're interested in
// Now, we tokenize the string. The fourth element is what we want.
StringTokenizer tok = new StringTokenizer(line2, " ");
if (tok.countTokens() < 4) {
// could be long Filesystem, thus data on third line
if (tok.countTokens() == 1 && lines.size() >= 3) {
- String line3 = lines.get(2); // the line may be interested in
+ final String line3 = lines.get(2); // the line may be interested in
tok = new StringTokenizer(line3, " ");
} else {
throw new IOException(
@@ -419,7 +419,7 @@ public class FileSystemUtils {
}
tok.nextToken(); // Ignore 1K-blocks
tok.nextToken(); // Ignore Used
- String freeSpace = tok.nextToken();
+ final String freeSpace = tok.nextToken();
return parseBytes(freeSpace, path);
}
@@ -432,9 +432,9 @@ public class FileSystemUtils {
* @return the number of bytes
* @throws IOException if an error occurs
*/
- long parseBytes(String freeSpace, String path) throws IOException {
+ long parseBytes(final String freeSpace, final String path) throws IOException {
try {
- long bytes = Long.parseLong(freeSpace);
+ final long bytes = Long.parseLong(freeSpace);
if (bytes < 0) {
throw new IOException(
"Command line '" + DF + "' did not find free space in response " +
@@ -442,7 +442,7 @@ public class FileSystemUtils {
}
return bytes;
- } catch (NumberFormatException ex) {
+ } catch (final NumberFormatException ex) {
throw new IOExceptionWithCause(
"Command line '" + DF + "' did not return numeric data as expected " +
"for path '" + path + "'- check path is valid", ex);
@@ -460,7 +460,7 @@ public class FileSystemUtils {
* @return the parsed data
* @throws IOException if an error occurs
*/
- List<String> performCommand(String[] cmdAttribs, int max, long timeout) throws IOException {
+ List<String> performCommand(final String[] cmdAttribs, final int max, final long timeout) throws IOException {
// this method does what it can to avoid the 'Too many open files' error
// based on trial and error and these links:
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4784692
@@ -469,7 +469,7 @@ public class FileSystemUtils {
// however, its still not perfect as the JDK support is so poor
// (see commond-exec or ant for a better multi-threaded multi-os solution)
- List<String> lines = new ArrayList<String>(20);
+ final List<String> lines = new ArrayList<String>(20);
Process proc = null;
InputStream in = null;
OutputStream out = null;
@@ -477,7 +477,7 @@ public class FileSystemUtils {
BufferedReader inr = null;
try {
- Thread monitor = ThreadMonitor.start(timeout);
+ final Thread monitor = ThreadMonitor.start(timeout);
proc = openProcess(cmdAttribs);
in = proc.getInputStream();
@@ -509,7 +509,7 @@ public class FileSystemUtils {
}
return lines;
- } catch (InterruptedException ex) {
+ } catch (final InterruptedException ex) {
throw new IOExceptionWithCause(
"Command line threw an InterruptedException " +
"for command " + Arrays.asList(cmdAttribs) + " timeout=" + timeout, ex);
@@ -531,7 +531,7 @@ public class FileSystemUtils {
* @return the process
* @throws IOException if an error occurs
*/
- Process openProcess(String[] cmdAttribs) throws IOException {
+ Process openProcess(final String[] cmdAttribs) throws IOException {
return Runtime.getRuntime().exec(cmdAttribs);
}