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 [5/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/...
Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/ProxyInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/ProxyInputStream.java?rev=1415850&r1=1415849&r2=1415850&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/ProxyInputStream.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/ProxyInputStream.java Fri Nov 30 20:51:39 2012
@@ -41,7 +41,7 @@ public abstract class ProxyInputStream e
*
* @param proxy the InputStream to delegate to
*/
- public ProxyInputStream(InputStream proxy) {
+ public ProxyInputStream(final InputStream proxy) {
super(proxy);
// the proxy is stored in a protected superclass variable named 'in'
}
@@ -55,10 +55,10 @@ public abstract class ProxyInputStream e
public int read() throws IOException {
try {
beforeRead(1);
- int b = in.read();
+ final int b = in.read();
afterRead(b != -1 ? 1 : -1);
return b;
- } catch (IOException e) {
+ } catch (final IOException e) {
handleIOException(e);
return -1;
}
@@ -71,13 +71,13 @@ public abstract class ProxyInputStream e
* @throws IOException if an I/O error occurs
*/
@Override
- public int read(byte[] bts) throws IOException {
+ public int read(final byte[] bts) throws IOException {
try {
beforeRead(bts != null ? bts.length : 0);
- int n = in.read(bts);
+ final int n = in.read(bts);
afterRead(n);
return n;
- } catch (IOException e) {
+ } catch (final IOException e) {
handleIOException(e);
return -1;
}
@@ -92,13 +92,13 @@ public abstract class ProxyInputStream e
* @throws IOException if an I/O error occurs
*/
@Override
- public int read(byte[] bts, int off, int len) throws IOException {
+ public int read(final byte[] bts, final int off, final int len) throws IOException {
try {
beforeRead(len);
- int n = in.read(bts, off, len);
+ final int n = in.read(bts, off, len);
afterRead(n);
return n;
- } catch (IOException e) {
+ } catch (final IOException e) {
handleIOException(e);
return -1;
}
@@ -111,10 +111,10 @@ public abstract class ProxyInputStream e
* @throws IOException if an I/O error occurs
*/
@Override
- public long skip(long ln) throws IOException {
+ public long skip(final long ln) throws IOException {
try {
return in.skip(ln);
- } catch (IOException e) {
+ } catch (final IOException e) {
handleIOException(e);
return 0;
}
@@ -129,7 +129,7 @@ public abstract class ProxyInputStream e
public int available() throws IOException {
try {
return super.available();
- } catch (IOException e) {
+ } catch (final IOException e) {
handleIOException(e);
return 0;
}
@@ -143,7 +143,7 @@ public abstract class ProxyInputStream e
public void close() throws IOException {
try {
in.close();
- } catch (IOException e) {
+ } catch (final IOException e) {
handleIOException(e);
}
}
@@ -153,7 +153,7 @@ public abstract class ProxyInputStream e
* @param readlimit read ahead limit
*/
@Override
- public synchronized void mark(int readlimit) {
+ public synchronized void mark(final int readlimit) {
in.mark(readlimit);
}
@@ -165,7 +165,7 @@ public abstract class ProxyInputStream e
public synchronized void reset() throws IOException {
try {
in.reset();
- } catch (IOException e) {
+ } catch (final IOException e) {
handleIOException(e);
}
}
@@ -197,7 +197,7 @@ public abstract class ProxyInputStream e
* @param n number of bytes that the caller asked to be read
* @throws IOException if the pre-processing fails
*/
- protected void beforeRead(int n) throws IOException {
+ protected void beforeRead(final int n) throws IOException {
}
/**
@@ -217,7 +217,7 @@ public abstract class ProxyInputStream e
* @param n number of bytes read, or -1 if the end of stream was reached
* @throws IOException if the post-processing fails
*/
- protected void afterRead(int n) throws IOException {
+ protected void afterRead(final int n) throws IOException {
}
/**
@@ -229,7 +229,7 @@ public abstract class ProxyInputStream e
* @throws IOException if an I/O error occurs
* @since 2.0
*/
- protected void handleIOException(IOException e) throws IOException {
+ protected void handleIOException(final IOException e) throws IOException {
throw e;
}
Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/ProxyReader.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/ProxyReader.java?rev=1415850&r1=1415849&r2=1415850&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/ProxyReader.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/ProxyReader.java Fri Nov 30 20:51:39 2012
@@ -39,7 +39,7 @@ public abstract class ProxyReader extend
*
* @param proxy the Reader to delegate to
*/
- public ProxyReader(Reader proxy) {
+ public ProxyReader(final Reader proxy) {
super(proxy);
// the proxy is stored in a protected superclass variable named 'in'
}
@@ -53,10 +53,10 @@ public abstract class ProxyReader extend
public int read() throws IOException {
try {
beforeRead(1);
- int c = in.read();
+ final int c = in.read();
afterRead(c != -1 ? 1 : -1);
return c;
- } catch (IOException e) {
+ } catch (final IOException e) {
handleIOException(e);
return -1;
}
@@ -69,13 +69,13 @@ public abstract class ProxyReader extend
* @throws IOException if an I/O error occurs
*/
@Override
- public int read(char[] chr) throws IOException {
+ public int read(final char[] chr) throws IOException {
try {
beforeRead(chr != null ? chr.length : 0);
- int n = in.read(chr);
+ final int n = in.read(chr);
afterRead(n);
return n;
- } catch (IOException e) {
+ } catch (final IOException e) {
handleIOException(e);
return -1;
}
@@ -90,13 +90,13 @@ public abstract class ProxyReader extend
* @throws IOException if an I/O error occurs
*/
@Override
- public int read(char[] chr, int st, int len) throws IOException {
+ public int read(final char[] chr, final int st, final int len) throws IOException {
try {
beforeRead(len);
- int n = in.read(chr, st, len);
+ final int n = in.read(chr, st, len);
afterRead(n);
return n;
- } catch (IOException e) {
+ } catch (final IOException e) {
handleIOException(e);
return -1;
}
@@ -110,13 +110,13 @@ public abstract class ProxyReader extend
* @since 2.0
*/
@Override
- public int read(CharBuffer target) throws IOException {
+ public int read(final CharBuffer target) throws IOException {
try {
beforeRead(target != null ? target.length() : 0);
- int n = in.read(target);
+ final int n = in.read(target);
afterRead(n);
return n;
- } catch (IOException e) {
+ } catch (final IOException e) {
handleIOException(e);
return -1;
}
@@ -129,10 +129,10 @@ public abstract class ProxyReader extend
* @throws IOException if an I/O error occurs
*/
@Override
- public long skip(long ln) throws IOException {
+ public long skip(final long ln) throws IOException {
try {
return in.skip(ln);
- } catch (IOException e) {
+ } catch (final IOException e) {
handleIOException(e);
return 0;
}
@@ -147,7 +147,7 @@ public abstract class ProxyReader extend
public boolean ready() throws IOException {
try {
return in.ready();
- } catch (IOException e) {
+ } catch (final IOException e) {
handleIOException(e);
return false;
}
@@ -161,7 +161,7 @@ public abstract class ProxyReader extend
public void close() throws IOException {
try {
in.close();
- } catch (IOException e) {
+ } catch (final IOException e) {
handleIOException(e);
}
}
@@ -172,10 +172,10 @@ public abstract class ProxyReader extend
* @throws IOException if an I/O error occurs
*/
@Override
- public synchronized void mark(int idx) throws IOException {
+ public synchronized void mark(final int idx) throws IOException {
try {
in.mark(idx);
- } catch (IOException e) {
+ } catch (final IOException e) {
handleIOException(e);
}
}
@@ -188,7 +188,7 @@ public abstract class ProxyReader extend
public synchronized void reset() throws IOException {
try {
in.reset();
- } catch (IOException e) {
+ } catch (final IOException e) {
handleIOException(e);
}
}
@@ -220,7 +220,7 @@ public abstract class ProxyReader extend
* @param n number of chars that the caller asked to be read
* @throws IOException if the pre-processing fails
*/
- protected void beforeRead(int n) throws IOException {
+ protected void beforeRead(final int n) throws IOException {
}
/**
@@ -240,7 +240,7 @@ public abstract class ProxyReader extend
* @param n number of chars read, or -1 if the end of stream was reached
* @throws IOException if the post-processing fails
*/
- protected void afterRead(int n) throws IOException {
+ protected void afterRead(final int n) throws IOException {
}
/**
@@ -252,7 +252,7 @@ public abstract class ProxyReader extend
* @throws IOException if an I/O error occurs
* @since 2.0
*/
- protected void handleIOException(IOException e) throws IOException {
+ protected void handleIOException(final IOException e) throws IOException {
throw e;
}
Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/ReaderInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/ReaderInputStream.java?rev=1415850&r1=1415849&r2=1415850&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/ReaderInputStream.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/ReaderInputStream.java Fri Nov 30 20:51:39 2012
@@ -103,7 +103,7 @@ public class ReaderInputStream extends I
* @param encoder the charset encoder
* @since 2.1
*/
- public ReaderInputStream(Reader reader, CharsetEncoder encoder) {
+ public ReaderInputStream(final Reader reader, final CharsetEncoder encoder) {
this(reader, encoder, DEFAULT_BUFFER_SIZE);
}
@@ -115,7 +115,7 @@ public class ReaderInputStream extends I
* @param bufferSize the size of the input buffer in number of characters
* @since 2.1
*/
- public ReaderInputStream(Reader reader, CharsetEncoder encoder, int bufferSize) {
+ public ReaderInputStream(final Reader reader, final CharsetEncoder encoder, final int bufferSize) {
this.reader = reader;
this.encoder = encoder;
this.encoderIn = CharBuffer.allocate(bufferSize);
@@ -131,7 +131,7 @@ public class ReaderInputStream extends I
* @param charset the charset encoding
* @param bufferSize the size of the input buffer in number of characters
*/
- public ReaderInputStream(Reader reader, Charset charset, int bufferSize) {
+ public ReaderInputStream(final Reader reader, final Charset charset, final int bufferSize) {
this(reader,
charset.newEncoder()
.onMalformedInput(CodingErrorAction.REPLACE)
@@ -146,7 +146,7 @@ public class ReaderInputStream extends I
* @param reader the target {@link Reader}
* @param charset the charset encoding
*/
- public ReaderInputStream(Reader reader, Charset charset) {
+ public ReaderInputStream(final Reader reader, final Charset charset) {
this(reader, charset, DEFAULT_BUFFER_SIZE);
}
@@ -157,7 +157,7 @@ public class ReaderInputStream extends I
* @param charsetName the name of the charset encoding
* @param bufferSize the size of the input buffer in number of characters
*/
- public ReaderInputStream(Reader reader, String charsetName, int bufferSize) {
+ public ReaderInputStream(final Reader reader, final String charsetName, final int bufferSize) {
this(reader, Charset.forName(charsetName), bufferSize);
}
@@ -168,7 +168,7 @@ public class ReaderInputStream extends I
* @param reader the target {@link Reader}
* @param charsetName the name of the charset encoding
*/
- public ReaderInputStream(Reader reader, String charsetName) {
+ public ReaderInputStream(final Reader reader, final String charsetName) {
this(reader, charsetName, DEFAULT_BUFFER_SIZE);
}
@@ -178,7 +178,7 @@ public class ReaderInputStream extends I
*
* @param reader the target {@link Reader}
*/
- public ReaderInputStream(Reader reader) {
+ public ReaderInputStream(final Reader reader) {
this(reader, Charset.defaultCharset());
}
@@ -191,11 +191,11 @@ public class ReaderInputStream extends I
private void fillBuffer() throws IOException {
if (!endOfInput && (lastCoderResult == null || lastCoderResult.isUnderflow())) {
encoderIn.compact();
- int position = encoderIn.position();
+ final int position = encoderIn.position();
// We don't use Reader#read(CharBuffer) here because it is more efficient
// to write directly to the underlying char array (the default implementation
// copies data to a temporary char array).
- int c = reader.read(encoderIn.array(), position, encoderIn.remaining());
+ final int c = reader.read(encoderIn.array(), position, encoderIn.remaining());
if (c == -1) {
endOfInput = true;
} else {
@@ -219,7 +219,7 @@ public class ReaderInputStream extends I
* @throws IOException if an I/O error occurs
*/
@Override
- public int read(byte[] b, int off, int len) throws IOException {
+ public int read(final byte[] b, int off, int len) throws IOException {
if (b == null) {
throw new NullPointerException("Byte array must not be null");
}
@@ -233,7 +233,7 @@ public class ReaderInputStream extends I
}
while (len > 0) {
if (encoderOut.hasRemaining()) {
- int c = Math.min(encoderOut.remaining(), len);
+ final int c = Math.min(encoderOut.remaining(), len);
encoderOut.get(b, off, c);
off += c;
len -= c;
@@ -257,7 +257,7 @@ public class ReaderInputStream extends I
* @throws IOException if an I/O error occurs
*/
@Override
- public int read(byte[] b) throws IOException {
+ public int read(final byte[] b) throws IOException {
return read(b, 0, b.length);
}
Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/ReversedLinesFileReader.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/ReversedLinesFileReader.java?rev=1415850&r1=1415849&r2=1415850&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/ReversedLinesFileReader.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/ReversedLinesFileReader.java Fri Nov 30 20:51:39 2012
@@ -94,9 +94,9 @@ public class ReversedLinesFileReader imp
currentFilePart = new FilePart(totalBlockCount, lastBlockLength, null);
// --- check & prepare encoding ---
- Charset charset = Charsets.toCharset(encoding);
- CharsetEncoder charsetEncoder = charset.newEncoder();
- float maxBytesPerChar = charsetEncoder.maxBytesPerChar();
+ final Charset charset = Charsets.toCharset(encoding);
+ final CharsetEncoder charsetEncoder = charset.newEncoder();
+ final float maxBytesPerChar = charsetEncoder.maxBytesPerChar();
if(maxBytesPerChar==1f) {
// all one byte encodings are no problem
byteDecrement = 1;
@@ -199,7 +199,7 @@ public class ReversedLinesFileReader imp
*/
private FilePart(final long no, final int length, final byte[] leftOverOfLastFilePart) throws IOException {
this.no = no;
- int dataLength = length + (leftOverOfLastFilePart != null ? leftOverOfLastFilePart.length : 0);
+ final int dataLength = length + (leftOverOfLastFilePart != null ? leftOverOfLastFilePart.length : 0);
this.data = new byte[dataLength];
final long off = (no - 1) * blockSize;
@@ -255,7 +255,7 @@ public class ReversedLinesFileReader imp
String line = null;
int newLineMatchByteCount;
- boolean isLastFilePart = no == 1;
+ final boolean isLastFilePart = no == 1;
int i = currentLastBytePos;
while (i > -1) {
@@ -270,12 +270,12 @@ public class ReversedLinesFileReader imp
// --- check for newline ---
if ((newLineMatchByteCount = getNewLineMatchByteCount(data, i)) > 0 /* found newline */) {
final int lineStart = i + 1;
- int lineLengthBytes = currentLastBytePos - lineStart + 1;
+ final int lineLengthBytes = currentLastBytePos - lineStart + 1;
if (lineLengthBytes < 0) {
throw new IllegalStateException("Unexpected negative line length="+lineLengthBytes);
}
- byte[] lineData = new byte[lineLengthBytes];
+ final byte[] lineData = new byte[lineLengthBytes];
System.arraycopy(data, lineStart, lineData, 0, lineLengthBytes);
line = new String(lineData, encoding);
@@ -308,7 +308,7 @@ public class ReversedLinesFileReader imp
* Creates the buffer containing any left over bytes.
*/
private void createLeftOver() {
- int lineLengthBytes = currentLastBytePos + 1;
+ final int lineLengthBytes = currentLastBytePos + 1;
if (lineLengthBytes > 0) {
// create left over for next block
leftOver = new byte[lineLengthBytes];
@@ -326,11 +326,11 @@ public class ReversedLinesFileReader imp
* @param i start offset in buffer
* @return length of newline sequence or 0 if none found
*/
- private int getNewLineMatchByteCount(byte[] data, int i) {
- for (byte[] newLineSequence : newLineSequences) {
+ private int getNewLineMatchByteCount(final byte[] data, final int i) {
+ for (final byte[] newLineSequence : newLineSequences) {
boolean match = true;
for (int j = newLineSequence.length - 1; j >= 0; j--) {
- int k = i + j - (newLineSequence.length - 1);
+ final int k = i + j - (newLineSequence.length - 1);
match &= k >= 0 && data[k] == newLineSequence[j];
}
if (match) {
Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/SwappedDataInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/SwappedDataInputStream.java?rev=1415850&r1=1415849&r2=1415850&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/SwappedDataInputStream.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/SwappedDataInputStream.java Fri Nov 30 20:51:39 2012
@@ -41,7 +41,7 @@ public class SwappedDataInputStream exte
*
* @param input InputStream to read from
*/
- public SwappedDataInputStream( InputStream input )
+ public SwappedDataInputStream( final InputStream input )
{
super( input );
}
@@ -113,7 +113,7 @@ public class SwappedDataInputStream exte
* @throws EOFException if an end of file is reached unexpectedly
* @throws IOException if an I/O error occurs
*/
- public void readFully( byte[] data )
+ public void readFully( final byte[] data )
throws IOException, EOFException
{
readFully( data, 0, data.length );
@@ -129,15 +129,15 @@ public class SwappedDataInputStream exte
* @throws EOFException if an end of file is reached unexpectedly
* @throws IOException if an I/O error occurs
*/
- public void readFully( byte[] data, int offset, int length )
+ public void readFully( final byte[] data, final int offset, final int length )
throws IOException, EOFException
{
int remaining = length;
while( remaining > 0 )
{
- int location = offset + length - remaining;
- int count = read( data, location, remaining );
+ final int location = offset + length - remaining;
+ final int count = read( data, location, remaining );
if( -1 == count )
{
@@ -241,7 +241,7 @@ public class SwappedDataInputStream exte
* @throws EOFException if an end of file is reached unexpectedly
* @throws IOException if an I/O error occurs
*/
- public int skipBytes( int count )
+ public int skipBytes( final int count )
throws IOException, EOFException
{
return (int)in.skip( count );
Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/TaggedInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/TaggedInputStream.java?rev=1415850&r1=1415849&r2=1415850&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/TaggedInputStream.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/TaggedInputStream.java Fri Nov 30 20:51:39 2012
@@ -73,7 +73,7 @@ public class TaggedInputStream extends P
*
* @param proxy input stream to be decorated
*/
- public TaggedInputStream(InputStream proxy) {
+ public TaggedInputStream(final InputStream proxy) {
super(proxy);
}
@@ -84,7 +84,7 @@ public class TaggedInputStream extends P
* @return {@code true} if the exception was thrown by this stream,
* {@code false} otherwise
*/
- public boolean isCauseOf(Throwable exception) {
+ public boolean isCauseOf(final Throwable exception) {
return TaggedIOException.isTaggedWith(exception, tag);
}
@@ -98,7 +98,7 @@ public class TaggedInputStream extends P
* @param throwable an exception
* @throws IOException original exception, if any, thrown by this stream
*/
- public void throwIfCauseOf(Throwable throwable) throws IOException {
+ public void throwIfCauseOf(final Throwable throwable) throws IOException {
TaggedIOException.throwCauseIfTaggedWith(throwable, tag);
}
@@ -109,7 +109,7 @@ public class TaggedInputStream extends P
* @throws IOException if an I/O error occurs
*/
@Override
- protected void handleIOException(IOException e) throws IOException {
+ protected void handleIOException(final IOException e) throws IOException {
throw new TaggedIOException(e, tag);
}
Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/Tailer.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/Tailer.java?rev=1415850&r1=1415849&r2=1415850&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/Tailer.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/Tailer.java Fri Nov 30 20:51:39 2012
@@ -157,7 +157,7 @@ public class Tailer implements Runnable
* @param file The file to follow.
* @param listener the TailerListener to use.
*/
- public Tailer(File file, TailerListener listener) {
+ public Tailer(final File file, final TailerListener listener) {
this(file, listener, DEFAULT_DELAY_MILLIS);
}
@@ -167,7 +167,7 @@ public class Tailer implements Runnable
* @param listener the TailerListener to use.
* @param delayMillis the delay between checks of the file for new content in milliseconds.
*/
- public Tailer(File file, TailerListener listener, long delayMillis) {
+ public Tailer(final File file, final TailerListener listener, final long delayMillis) {
this(file, listener, delayMillis, false);
}
@@ -178,7 +178,7 @@ public class Tailer implements Runnable
* @param delayMillis the delay between checks of the file for new content in milliseconds.
* @param end Set to true to tail from the end of the file, false to tail from the beginning of the file.
*/
- public Tailer(File file, TailerListener listener, long delayMillis, boolean end) {
+ public Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end) {
this(file, listener, delayMillis, end, DEFAULT_BUFSIZE);
}
@@ -190,7 +190,7 @@ public class Tailer implements Runnable
* @param end Set to true to tail from the end of the file, false to tail from the beginning of the file.
* @param reOpen if true, close and reopen the file between reading chunks
*/
- public Tailer(File file, TailerListener listener, long delayMillis, boolean end, boolean reOpen) {
+ public Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen) {
this(file, listener, delayMillis, end, reOpen, DEFAULT_BUFSIZE);
}
@@ -202,7 +202,7 @@ public class Tailer implements Runnable
* @param end Set to true to tail from the end of the file, false to tail from the beginning of the file.
* @param bufSize Buffer size
*/
- public Tailer(File file, TailerListener listener, long delayMillis, boolean end, int bufSize) {
+ public Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end, final int bufSize) {
this(file, listener, delayMillis, end, false, bufSize);
}
@@ -215,7 +215,7 @@ public class Tailer implements Runnable
* @param reOpen if true, close and reopen the file between reading chunks
* @param bufSize Buffer size
*/
- public Tailer(File file, TailerListener listener, long delayMillis, boolean end, boolean reOpen, int bufSize) {
+ public Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen, final int bufSize) {
this.file = file;
this.delayMillis = delayMillis;
this.end = end;
@@ -238,9 +238,9 @@ public class Tailer implements Runnable
* @param bufSize buffer size.
* @return The new tailer
*/
- public static Tailer create(File file, TailerListener listener, long delayMillis, boolean end, int bufSize) {
- Tailer tailer = new Tailer(file, listener, delayMillis, end, bufSize);
- Thread thread = new Thread(tailer);
+ public static Tailer create(final File file, final TailerListener listener, final long delayMillis, final boolean end, final int bufSize) {
+ final Tailer tailer = new Tailer(file, listener, delayMillis, end, bufSize);
+ final Thread thread = new Thread(tailer);
thread.setDaemon(true);
thread.start();
return tailer;
@@ -257,10 +257,10 @@ public class Tailer implements Runnable
* @param bufSize buffer size.
* @return The new tailer
*/
- public static Tailer create(File file, TailerListener listener, long delayMillis, boolean end, boolean reOpen,
- int bufSize) {
- Tailer tailer = new Tailer(file, listener, delayMillis, end, reOpen, bufSize);
- Thread thread = new Thread(tailer);
+ public static Tailer create(final File file, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen,
+ final int bufSize) {
+ final Tailer tailer = new Tailer(file, listener, delayMillis, end, reOpen, bufSize);
+ final Thread thread = new Thread(tailer);
thread.setDaemon(true);
thread.start();
return tailer;
@@ -275,7 +275,7 @@ public class Tailer implements Runnable
* @param end Set to true to tail from the end of the file, false to tail from the beginning of the file.
* @return The new tailer
*/
- public static Tailer create(File file, TailerListener listener, long delayMillis, boolean end) {
+ public static Tailer create(final File file, final TailerListener listener, final long delayMillis, final boolean end) {
return create(file, listener, delayMillis, end, DEFAULT_BUFSIZE);
}
@@ -289,7 +289,7 @@ public class Tailer implements Runnable
* @param reOpen whether to close/reopen the file between chunks
* @return The new tailer
*/
- public static Tailer create(File file, TailerListener listener, long delayMillis, boolean end, boolean reOpen) {
+ public static Tailer create(final File file, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen) {
return create(file, listener, delayMillis, end, reOpen, DEFAULT_BUFSIZE);
}
@@ -301,7 +301,7 @@ public class Tailer implements Runnable
* @param delayMillis the delay between checks of the file for new content in milliseconds.
* @return The new tailer
*/
- public static Tailer create(File file, TailerListener listener, long delayMillis) {
+ public static Tailer create(final File file, final TailerListener listener, final long delayMillis) {
return create(file, listener, delayMillis, false);
}
@@ -313,7 +313,7 @@ public class Tailer implements Runnable
* @param listener the TailerListener to use.
* @return The new tailer
*/
- public static Tailer create(File file, TailerListener listener) {
+ public static Tailer create(final File file, final TailerListener listener) {
return create(file, listener, DEFAULT_DELAY_MILLIS, false);
}
@@ -357,7 +357,7 @@ public class Tailer implements Runnable
while (getRun() && reader == null) {
try {
reader = new RandomAccessFile(file, RAF_MODE);
- } catch (FileNotFoundException e) {
+ } catch (final FileNotFoundException e) {
listener.fileNotFound();
}
if (reader == null) {
@@ -370,21 +370,21 @@ public class Tailer implements Runnable
}
}
while (getRun()) {
- boolean newer = FileUtils.isFileNewer(file, last); // IO-279, must be done first
+ final boolean newer = FileUtils.isFileNewer(file, last); // IO-279, must be done first
// Check the file length to see if it was rotated
- long length = file.length();
+ final long length = file.length();
if (length < position) {
// File was rotated
listener.fileRotated();
// Reopen the reader after rotation
try {
// Ensure that the old file is closed iff we re-open it successfully
- RandomAccessFile save = reader;
+ final RandomAccessFile save = reader;
reader = new RandomAccessFile(file, RAF_MODE);
position = 0;
// close old file explicitly rather than relying on GC picking up previous RAF
IOUtils.closeQuietly(save);
- } catch (FileNotFoundException e) {
+ } catch (final FileNotFoundException e) {
// in this case we continue to use the previous reader and position values
listener.fileNotFound();
}
@@ -418,17 +418,17 @@ public class Tailer implements Runnable
reader.seek(position);
}
}
- } catch (InterruptedException e) {
+ } catch (final InterruptedException e) {
Thread.currentThread().interrupt();
stop(e);
- } catch (Exception e) {
+ } catch (final Exception e) {
stop(e);
} finally {
IOUtils.closeQuietly(reader);
}
}
- private void stop(Exception e) {
+ private void stop(final Exception e) {
listener.handle(e);
stop();
}
@@ -447,8 +447,8 @@ public class Tailer implements Runnable
* @return The new position after the lines have been read
* @throws java.io.IOException if an I/O error occurs.
*/
- private long readLines(RandomAccessFile reader) throws IOException {
- StringBuilder sb = new StringBuilder();
+ private long readLines(final RandomAccessFile reader) throws IOException {
+ final StringBuilder sb = new StringBuilder();
long pos = reader.getFilePointer();
long rePos = pos; // position to re-read
@@ -457,7 +457,7 @@ public class Tailer implements Runnable
boolean seenCR = false;
while (getRun() && ((num = reader.read(inbuf)) != -1)) {
for (int i = 0; i < num; i++) {
- byte ch = inbuf[i];
+ final byte ch = inbuf[i];
switch (ch) {
case '\n':
seenCR = false; // swallow CR before LF
Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/TailerListenerAdapter.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/TailerListenerAdapter.java?rev=1415850&r1=1415849&r2=1415850&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/TailerListenerAdapter.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/TailerListenerAdapter.java Fri Nov 30 20:51:39 2012
@@ -29,7 +29,7 @@ public class TailerListenerAdapter imple
* giving the listener a method of stopping the tailer.
* @param tailer the tailer.
*/
- public void init(Tailer tailer) {
+ public void init(final Tailer tailer) {
}
/**
@@ -51,14 +51,14 @@ public class TailerListenerAdapter imple
* Handles a line from a Tailer.
* @param line the line.
*/
- public void handle(String line) {
+ public void handle(final String line) {
}
/**
* Handles an Exception .
* @param ex the exception.
*/
- public void handle(Exception ex) {
+ public void handle(final Exception ex) {
}
}
Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/TeeInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/TeeInputStream.java?rev=1415850&r1=1415849&r2=1415850&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/TeeInputStream.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/TeeInputStream.java Fri Nov 30 20:51:39 2012
@@ -56,7 +56,7 @@ public class TeeInputStream extends Prox
* @param input input stream to be proxied
* @param branch output stream that will receive a copy of all bytes read
*/
- public TeeInputStream(InputStream input, OutputStream branch) {
+ public TeeInputStream(final InputStream input, final OutputStream branch) {
this(input, branch, false);
}
@@ -72,7 +72,7 @@ public class TeeInputStream extends Prox
* stream is closed
*/
public TeeInputStream(
- InputStream input, OutputStream branch, boolean closeBranch) {
+ final InputStream input, final OutputStream branch, final boolean closeBranch) {
super(input);
this.branch = branch;
this.closeBranch = closeBranch;
@@ -105,7 +105,7 @@ public class TeeInputStream extends Prox
*/
@Override
public int read() throws IOException {
- int ch = super.read();
+ final int ch = super.read();
if (ch != -1) {
branch.write(ch);
}
@@ -123,8 +123,8 @@ public class TeeInputStream extends Prox
* @throws IOException if the stream could not be read (or written)
*/
@Override
- public int read(byte[] bts, int st, int end) throws IOException {
- int n = super.read(bts, st, end);
+ public int read(final byte[] bts, final int st, final int end) throws IOException {
+ final int n = super.read(bts, st, end);
if (n != -1) {
branch.write(bts, st, n);
}
@@ -140,8 +140,8 @@ public class TeeInputStream extends Prox
* @throws IOException if the stream could not be read (or written)
*/
@Override
- public int read(byte[] bts) throws IOException {
- int n = super.read(bts);
+ public int read(final byte[] bts) throws IOException {
+ final int n = super.read(bts);
if (n != -1) {
branch.write(bts, 0, n);
}
Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/XmlStreamReader.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/XmlStreamReader.java?rev=1415850&r1=1415849&r2=1415850&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/XmlStreamReader.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/XmlStreamReader.java Fri Nov 30 20:51:39 2012
@@ -134,7 +134,7 @@ public class XmlStreamReader extends Rea
* @param file File to create a Reader from.
* @throws IOException thrown if there is a problem reading the file.
*/
- public XmlStreamReader(File file) throws IOException {
+ public XmlStreamReader(final File file) throws IOException {
this(new FileInputStream(file));
}
@@ -149,7 +149,7 @@ public class XmlStreamReader extends Rea
* @param is InputStream to create a Reader from.
* @throws IOException thrown if there is a problem reading the stream.
*/
- public XmlStreamReader(InputStream is) throws IOException {
+ public XmlStreamReader(final InputStream is) throws IOException {
this(is, true);
}
@@ -180,7 +180,7 @@ public class XmlStreamReader extends Rea
* @throws XmlStreamReaderException thrown if the charset encoding could not
* be determined according to the specs.
*/
- public XmlStreamReader(InputStream is, boolean lenient) throws IOException {
+ public XmlStreamReader(final InputStream is, final boolean lenient) throws IOException {
this(is, lenient, null);
}
@@ -212,10 +212,10 @@ public class XmlStreamReader extends Rea
* @throws XmlStreamReaderException thrown if the charset encoding could not
* be determined according to the specs.
*/
- public XmlStreamReader(InputStream is, boolean lenient, String defaultEncoding) throws IOException {
+ public XmlStreamReader(final InputStream is, final boolean lenient, final String defaultEncoding) throws IOException {
this.defaultEncoding = defaultEncoding;
- BOMInputStream bom = new BOMInputStream(new BufferedInputStream(is, BUFFER_SIZE), false, BOMS);
- BOMInputStream pis = new BOMInputStream(bom, true, XML_GUESS_BYTES);
+ final BOMInputStream bom = new BOMInputStream(new BufferedInputStream(is, BUFFER_SIZE), false, BOMS);
+ final BOMInputStream pis = new BOMInputStream(bom, true, XML_GUESS_BYTES);
this.encoding = doRawStream(bom, pis, lenient);
this.reader = new InputStreamReader(pis, encoding);
}
@@ -237,7 +237,7 @@ public class XmlStreamReader extends Rea
* @throws IOException thrown if there is a problem reading the stream of
* the URL.
*/
- public XmlStreamReader(URL url) throws IOException {
+ public XmlStreamReader(final URL url) throws IOException {
this(url.openConnection(), null);
}
@@ -260,13 +260,13 @@ public class XmlStreamReader extends Rea
* @throws IOException thrown if there is a problem reading the stream of
* the URLConnection.
*/
- public XmlStreamReader(URLConnection conn, String defaultEncoding) throws IOException {
+ public XmlStreamReader(final URLConnection conn, final String defaultEncoding) throws IOException {
this.defaultEncoding = defaultEncoding;
- boolean lenient = true;
- String contentType = conn.getContentType();
- InputStream is = conn.getInputStream();
- BOMInputStream bom = new BOMInputStream(new BufferedInputStream(is, BUFFER_SIZE), false, BOMS);
- BOMInputStream pis = new BOMInputStream(bom, true, XML_GUESS_BYTES);
+ final boolean lenient = true;
+ final String contentType = conn.getContentType();
+ final InputStream is = conn.getInputStream();
+ final BOMInputStream bom = new BOMInputStream(new BufferedInputStream(is, BUFFER_SIZE), false, BOMS);
+ final BOMInputStream pis = new BOMInputStream(bom, true, XML_GUESS_BYTES);
if (conn instanceof HttpURLConnection || contentType != null) {
this.encoding = doHttpStream(bom, pis, contentType, lenient);
} else {
@@ -292,7 +292,7 @@ public class XmlStreamReader extends Rea
* the charset encoding.
* @throws IOException thrown if there is a problem reading the file.
*/
- public XmlStreamReader(InputStream is, String httpContentType)
+ public XmlStreamReader(final InputStream is, final String httpContentType)
throws IOException {
this(is, httpContentType, true);
}
@@ -331,11 +331,11 @@ public class XmlStreamReader extends Rea
* @throws XmlStreamReaderException thrown if the charset encoding could not
* be determined according to the specs.
*/
- public XmlStreamReader(InputStream is, String httpContentType,
- boolean lenient, String defaultEncoding) throws IOException {
+ public XmlStreamReader(final InputStream is, final String httpContentType,
+ final boolean lenient, final String defaultEncoding) throws IOException {
this.defaultEncoding = defaultEncoding;
- BOMInputStream bom = new BOMInputStream(new BufferedInputStream(is, BUFFER_SIZE), false, BOMS);
- BOMInputStream pis = new BOMInputStream(bom, true, XML_GUESS_BYTES);
+ final BOMInputStream bom = new BOMInputStream(new BufferedInputStream(is, BUFFER_SIZE), false, BOMS);
+ final BOMInputStream pis = new BOMInputStream(bom, true, XML_GUESS_BYTES);
this.encoding = doHttpStream(bom, pis, httpContentType, lenient);
this.reader = new InputStreamReader(pis, encoding);
}
@@ -373,8 +373,8 @@ public class XmlStreamReader extends Rea
* @throws XmlStreamReaderException thrown if the charset encoding could not
* be determined according to the specs.
*/
- public XmlStreamReader(InputStream is, String httpContentType,
- boolean lenient) throws IOException {
+ public XmlStreamReader(final InputStream is, final String httpContentType,
+ final boolean lenient) throws IOException {
this(is, httpContentType, lenient, null);
}
@@ -396,7 +396,7 @@ public class XmlStreamReader extends Rea
* @throws IOException if an I/O error occurs
*/
@Override
- public int read(char[] buf, int offset, int len) throws IOException {
+ public int read(final char[] buf, final int offset, final int len) throws IOException {
return reader.read(buf, offset, len);
}
@@ -420,14 +420,14 @@ public class XmlStreamReader extends Rea
* @return the encoding to be used
* @throws IOException thrown if there is a problem reading the stream.
*/
- private String doRawStream(BOMInputStream bom, BOMInputStream pis, boolean lenient)
+ private String doRawStream(final BOMInputStream bom, final BOMInputStream pis, final boolean lenient)
throws IOException {
- String bomEnc = bom.getBOMCharsetName();
- String xmlGuessEnc = pis.getBOMCharsetName();
- String xmlEnc = getXmlProlog(pis, xmlGuessEnc);
+ final String bomEnc = bom.getBOMCharsetName();
+ final String xmlGuessEnc = pis.getBOMCharsetName();
+ final String xmlEnc = getXmlProlog(pis, xmlGuessEnc);
try {
return calculateRawEncoding(bomEnc, xmlGuessEnc, xmlEnc);
- } catch (XmlStreamReaderException ex) {
+ } catch (final XmlStreamReaderException ex) {
if (lenient) {
return doLenientDetection(null, ex);
} else {
@@ -447,15 +447,15 @@ public class XmlStreamReader extends Rea
* @return the encoding to be used
* @throws IOException thrown if there is a problem reading the stream.
*/
- private String doHttpStream(BOMInputStream bom, BOMInputStream pis, String httpContentType,
- boolean lenient) throws IOException {
- String bomEnc = bom.getBOMCharsetName();
- String xmlGuessEnc = pis.getBOMCharsetName();
- String xmlEnc = getXmlProlog(pis, xmlGuessEnc);
+ private String doHttpStream(final BOMInputStream bom, final BOMInputStream pis, final String httpContentType,
+ final boolean lenient) throws IOException {
+ final String bomEnc = bom.getBOMCharsetName();
+ final String xmlGuessEnc = pis.getBOMCharsetName();
+ final String xmlEnc = getXmlProlog(pis, xmlGuessEnc);
try {
return calculateHttpEncoding(httpContentType, bomEnc,
xmlGuessEnc, xmlEnc, lenient);
- } catch (XmlStreamReaderException ex) {
+ } catch (final XmlStreamReaderException ex) {
if (lenient) {
return doLenientDetection(httpContentType, ex);
} else {
@@ -481,7 +481,7 @@ public class XmlStreamReader extends Rea
try {
return calculateHttpEncoding(httpContentType, ex.getBomEncoding(),
ex.getXmlGuessEncoding(), ex.getXmlEncoding(), true);
- } catch (XmlStreamReaderException ex2) {
+ } catch (final XmlStreamReaderException ex2) {
ex = ex2;
}
}
@@ -504,8 +504,8 @@ public class XmlStreamReader extends Rea
* @return the raw encoding
* @throws IOException thrown if there is a problem reading the stream.
*/
- String calculateRawEncoding(String bomEnc, String xmlGuessEnc,
- String xmlEnc) throws IOException {
+ String calculateRawEncoding(final String bomEnc, final String xmlGuessEnc,
+ final String xmlEnc) throws IOException {
// BOM is Null
if (bomEnc == null) {
@@ -522,11 +522,11 @@ public class XmlStreamReader extends Rea
// BOM is UTF-8
if (bomEnc.equals(UTF_8)) {
if (xmlGuessEnc != null && !xmlGuessEnc.equals(UTF_8)) {
- String msg = MessageFormat.format(RAW_EX_1, new Object[] { bomEnc, xmlGuessEnc, xmlEnc });
+ final String msg = MessageFormat.format(RAW_EX_1, new Object[] { bomEnc, xmlGuessEnc, xmlEnc });
throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc);
}
if (xmlEnc != null && !xmlEnc.equals(UTF_8)) {
- String msg = MessageFormat.format(RAW_EX_1, new Object[] { bomEnc, xmlGuessEnc, xmlEnc });
+ final String msg = MessageFormat.format(RAW_EX_1, new Object[] { bomEnc, xmlGuessEnc, xmlEnc });
throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc);
}
return bomEnc;
@@ -535,11 +535,11 @@ public class XmlStreamReader extends Rea
// BOM is UTF-16BE or UTF-16LE
if (bomEnc.equals(UTF_16BE) || bomEnc.equals(UTF_16LE)) {
if (xmlGuessEnc != null && !xmlGuessEnc.equals(bomEnc)) {
- String msg = MessageFormat.format(RAW_EX_1, new Object[] { bomEnc, xmlGuessEnc, xmlEnc });
+ final String msg = MessageFormat.format(RAW_EX_1, new Object[] { bomEnc, xmlGuessEnc, xmlEnc });
throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc);
}
if (xmlEnc != null && !xmlEnc.equals(UTF_16) && !xmlEnc.equals(bomEnc)) {
- String msg = MessageFormat.format(RAW_EX_1, new Object[] { bomEnc, xmlGuessEnc, xmlEnc });
+ final String msg = MessageFormat.format(RAW_EX_1, new Object[] { bomEnc, xmlGuessEnc, xmlEnc });
throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc);
}
return bomEnc;
@@ -548,18 +548,18 @@ public class XmlStreamReader extends Rea
// BOM is UTF-32BE or UTF-32LE
if (bomEnc.equals(UTF_32BE) || bomEnc.equals(UTF_32LE)) {
if (xmlGuessEnc != null && !xmlGuessEnc.equals(bomEnc)) {
- String msg = MessageFormat.format(RAW_EX_1, new Object[] { bomEnc, xmlGuessEnc, xmlEnc });
+ final String msg = MessageFormat.format(RAW_EX_1, new Object[] { bomEnc, xmlGuessEnc, xmlEnc });
throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc);
}
if (xmlEnc != null && !xmlEnc.equals(UTF_32) && !xmlEnc.equals(bomEnc)) {
- String msg = MessageFormat.format(RAW_EX_1, new Object[] { bomEnc, xmlGuessEnc, xmlEnc });
+ final String msg = MessageFormat.format(RAW_EX_1, new Object[] { bomEnc, xmlGuessEnc, xmlEnc });
throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc);
}
return bomEnc;
}
// BOM is something else
- String msg = MessageFormat.format(RAW_EX_2, new Object[] { bomEnc, xmlGuessEnc, xmlEnc });
+ final String msg = MessageFormat.format(RAW_EX_2, new Object[] { bomEnc, xmlGuessEnc, xmlEnc });
throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc);
}
@@ -576,9 +576,9 @@ public class XmlStreamReader extends Rea
* @return the HTTP encoding
* @throws IOException thrown if there is a problem reading the stream.
*/
- String calculateHttpEncoding(String httpContentType,
- String bomEnc, String xmlGuessEnc, String xmlEnc,
- boolean lenient) throws IOException {
+ String calculateHttpEncoding(final String httpContentType,
+ final String bomEnc, final String xmlGuessEnc, final String xmlEnc,
+ final boolean lenient) throws IOException {
// Lenient and has XML encoding
if (lenient && xmlEnc != null) {
@@ -586,14 +586,14 @@ public class XmlStreamReader extends Rea
}
// Determine mime/encoding content types from HTTP Content Type
- String cTMime = getContentTypeMime(httpContentType);
- String cTEnc = getContentTypeEncoding(httpContentType);
- boolean appXml = isAppXml(cTMime);
- boolean textXml = isTextXml(cTMime);
+ final String cTMime = getContentTypeMime(httpContentType);
+ final String cTEnc = getContentTypeEncoding(httpContentType);
+ final boolean appXml = isAppXml(cTMime);
+ final boolean textXml = isTextXml(cTMime);
// Mime type NOT "application/xml" or "text/xml"
if (!appXml && !textXml) {
- String msg = MessageFormat.format(HTTP_EX_3, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
+ final String msg = MessageFormat.format(HTTP_EX_3, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
throw new XmlStreamReaderException(msg, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
}
@@ -609,7 +609,7 @@ public class XmlStreamReader extends Rea
// UTF-16BE or UTF-16LE content type encoding
if (cTEnc.equals(UTF_16BE) || cTEnc.equals(UTF_16LE)) {
if (bomEnc != null) {
- String msg = MessageFormat.format(HTTP_EX_1, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
+ final String msg = MessageFormat.format(HTTP_EX_1, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
throw new XmlStreamReaderException(msg, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
}
return cTEnc;
@@ -620,14 +620,14 @@ public class XmlStreamReader extends Rea
if (bomEnc != null && bomEnc.startsWith(UTF_16)) {
return bomEnc;
}
- String msg = MessageFormat.format(HTTP_EX_2, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
+ final String msg = MessageFormat.format(HTTP_EX_2, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
throw new XmlStreamReaderException(msg, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
}
// UTF-32BE or UTF-132E content type encoding
if (cTEnc.equals(UTF_32BE) || cTEnc.equals(UTF_32LE)) {
if (bomEnc != null) {
- String msg = MessageFormat.format(HTTP_EX_1, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
+ final String msg = MessageFormat.format(HTTP_EX_1, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
throw new XmlStreamReaderException(msg, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
}
return cTEnc;
@@ -638,7 +638,7 @@ public class XmlStreamReader extends Rea
if (bomEnc != null && bomEnc.startsWith(UTF_32)) {
return bomEnc;
}
- String msg = MessageFormat.format(HTTP_EX_2, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
+ final String msg = MessageFormat.format(HTTP_EX_2, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
throw new XmlStreamReaderException(msg, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc);
}
@@ -651,10 +651,10 @@ public class XmlStreamReader extends Rea
* @param httpContentType the HTTP content type
* @return The mime content type
*/
- static String getContentTypeMime(String httpContentType) {
+ static String getContentTypeMime(final String httpContentType) {
String mime = null;
if (httpContentType != null) {
- int i = httpContentType.indexOf(";");
+ final int i = httpContentType.indexOf(";");
if (i >= 0) {
mime = httpContentType.substring(0, i);
} else {
@@ -675,13 +675,13 @@ public class XmlStreamReader extends Rea
* @param httpContentType the HTTP content type
* @return The content type encoding (upcased)
*/
- static String getContentTypeEncoding(String httpContentType) {
+ static String getContentTypeEncoding(final String httpContentType) {
String encoding = null;
if (httpContentType != null) {
- int i = httpContentType.indexOf(";");
+ final int i = httpContentType.indexOf(";");
if (i > -1) {
- String postMime = httpContentType.substring(i + 1);
- Matcher m = CHARSET_PATTERN.matcher(postMime);
+ final String postMime = httpContentType.substring(i + 1);
+ final Matcher m = CHARSET_PATTERN.matcher(postMime);
encoding = m.find() ? m.group(1) : null;
encoding = encoding != null ? encoding.toUpperCase(Locale.US) : null;
}
@@ -701,11 +701,11 @@ public class XmlStreamReader extends Rea
* @return the encoding declared in the <?xml encoding=...?>
* @throws IOException thrown if there is a problem reading the stream.
*/
- private static String getXmlProlog(InputStream is, String guessedEnc)
+ private static String getXmlProlog(final InputStream is, final String guessedEnc)
throws IOException {
String encoding = null;
if (guessedEnc != null) {
- byte[] bytes = new byte[BUFFER_SIZE];
+ final byte[] bytes = new byte[BUFFER_SIZE];
is.mark(BUFFER_SIZE);
int offset = 0;
int max = BUFFER_SIZE;
@@ -728,18 +728,18 @@ public class XmlStreamReader extends Rea
+ offset + " bytes");
}
}
- int bytesRead = offset;
+ final int bytesRead = offset;
if (bytesRead > 0) {
is.reset();
- BufferedReader bReader = new BufferedReader(new StringReader(
+ final BufferedReader bReader = new BufferedReader(new StringReader(
xmlProlog.substring(0, firstGT + 1)));
- StringBuffer prolog = new StringBuffer();
+ final StringBuffer prolog = new StringBuffer();
String line = bReader.readLine();
while (line != null) {
prolog.append(line);
line = bReader.readLine();
}
- Matcher m = ENCODING_PATTERN.matcher(prolog);
+ final Matcher m = ENCODING_PATTERN.matcher(prolog);
if (m.find()) {
encoding = m.group(1).toUpperCase();
encoding = encoding.substring(1, encoding.length() - 1);
@@ -756,7 +756,7 @@ public class XmlStreamReader extends Rea
* @return true if the mime type belongs to the APPLICATION XML family,
* otherwise false
*/
- static boolean isAppXml(String mime) {
+ static boolean isAppXml(final String mime) {
return mime != null &&
(mime.equals("application/xml") ||
mime.equals("application/xml-dtd") ||
@@ -771,7 +771,7 @@ public class XmlStreamReader extends Rea
* @return true if the mime type belongs to the TEXT XML family,
* otherwise false
*/
- static boolean isTextXml(String mime) {
+ static boolean isTextXml(final String mime) {
return mime != null &&
(mime.equals("text/xml") ||
mime.equals("text/xml-external-parsed-entity") ||
Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/XmlStreamReaderException.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/XmlStreamReaderException.java?rev=1415850&r1=1415849&r2=1415850&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/XmlStreamReaderException.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/XmlStreamReaderException.java Fri Nov 30 20:51:39 2012
@@ -56,8 +56,8 @@ public class XmlStreamReaderException ex
* @param xmlGuessEnc XML guess encoding.
* @param xmlEnc XML prolog encoding.
*/
- public XmlStreamReaderException(String msg, String bomEnc,
- String xmlGuessEnc, String xmlEnc) {
+ public XmlStreamReaderException(final String msg, final String bomEnc,
+ final String xmlGuessEnc, final String xmlEnc) {
this(msg, null, null, bomEnc, xmlGuessEnc, xmlEnc);
}
@@ -74,8 +74,8 @@ public class XmlStreamReaderException ex
* @param xmlGuessEnc XML guess encoding.
* @param xmlEnc XML prolog encoding.
*/
- public XmlStreamReaderException(String msg, String ctMime, String ctEnc,
- String bomEnc, String xmlGuessEnc, String xmlEnc) {
+ public XmlStreamReaderException(final String msg, final String ctMime, final String ctEnc,
+ final String bomEnc, final String xmlGuessEnc, final String xmlEnc) {
super(msg);
contentTypeMime = ctMime;
contentTypeEncoding = ctEnc;
Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/monitor/FileAlterationMonitor.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/monitor/FileAlterationMonitor.java?rev=1415850&r1=1415849&r2=1415850&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/monitor/FileAlterationMonitor.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/monitor/FileAlterationMonitor.java Fri Nov 30 20:51:39 2012
@@ -49,7 +49,7 @@ public final class FileAlterationMonitor
* @param interval The amount of time in miliseconds to wait between
* checks of the file system
*/
- public FileAlterationMonitor(long interval) {
+ public FileAlterationMonitor(final long interval) {
this.interval = interval;
}
@@ -60,10 +60,10 @@ public final class FileAlterationMonitor
* checks of the file system
* @param observers The set of observers to add to the monitor.
*/
- public FileAlterationMonitor(long interval, FileAlterationObserver... observers) {
+ public FileAlterationMonitor(final long interval, final FileAlterationObserver... observers) {
this(interval);
if (observers != null) {
- for (FileAlterationObserver observer : observers) {
+ for (final FileAlterationObserver observer : observers) {
addObserver(observer);
}
}
@@ -83,7 +83,7 @@ public final class FileAlterationMonitor
*
* @param threadFactory the thread factory
*/
- public synchronized void setThreadFactory(ThreadFactory threadFactory) {
+ public synchronized void setThreadFactory(final ThreadFactory threadFactory) {
this.threadFactory = threadFactory;
}
@@ -129,7 +129,7 @@ public final class FileAlterationMonitor
if (running) {
throw new IllegalStateException("Monitor is already running");
}
- for (FileAlterationObserver observer : observers) {
+ for (final FileAlterationObserver observer : observers) {
observer.initialize();
}
running = true;
@@ -158,17 +158,17 @@ public final class FileAlterationMonitor
* @throws Exception if an error occurs initializing the observer
* @since 2.1
*/
- public synchronized void stop(long stopInterval) throws Exception {
+ public synchronized void stop(final long stopInterval) throws Exception {
if (running == false) {
throw new IllegalStateException("Monitor is not running");
}
running = false;
try {
thread.join(stopInterval);
- } catch (InterruptedException e) {
+ } catch (final InterruptedException e) {
Thread.currentThread().interrupt();
}
- for (FileAlterationObserver observer : observers) {
+ for (final FileAlterationObserver observer : observers) {
observer.destroy();
}
}
@@ -178,7 +178,7 @@ public final class FileAlterationMonitor
*/
public void run() {
while (running) {
- for (FileAlterationObserver observer : observers) {
+ for (final FileAlterationObserver observer : observers) {
observer.checkAndNotify();
}
if (!running) {
Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/monitor/FileAlterationObserver.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/monitor/FileAlterationObserver.java?rev=1415850&r1=1415849&r2=1415850&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/monitor/FileAlterationObserver.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/monitor/FileAlterationObserver.java Fri Nov 30 20:51:39 2012
@@ -131,7 +131,7 @@ public class FileAlterationObserver impl
*
* @param directoryName the name of the directory to observe
*/
- public FileAlterationObserver(String directoryName) {
+ public FileAlterationObserver(final String directoryName) {
this(new File(directoryName));
}
@@ -141,7 +141,7 @@ public class FileAlterationObserver impl
* @param directoryName the name of the directory to observe
* @param fileFilter The file filter or null if none
*/
- public FileAlterationObserver(String directoryName, FileFilter fileFilter) {
+ public FileAlterationObserver(final String directoryName, final FileFilter fileFilter) {
this(new File(directoryName), fileFilter);
}
@@ -153,7 +153,7 @@ public class FileAlterationObserver impl
* @param fileFilter The file filter or null if none
* @param caseSensitivity what case sensitivity to use comparing file names, null means system sensitive
*/
- public FileAlterationObserver(String directoryName, FileFilter fileFilter, IOCase caseSensitivity) {
+ public FileAlterationObserver(final String directoryName, final FileFilter fileFilter, final IOCase caseSensitivity) {
this(new File(directoryName), fileFilter, caseSensitivity);
}
@@ -162,7 +162,7 @@ public class FileAlterationObserver impl
*
* @param directory the directory to observe
*/
- public FileAlterationObserver(File directory) {
+ public FileAlterationObserver(final File directory) {
this(directory, (FileFilter)null);
}
@@ -172,7 +172,7 @@ public class FileAlterationObserver impl
* @param directory the directory to observe
* @param fileFilter The file filter or null if none
*/
- public FileAlterationObserver(File directory, FileFilter fileFilter) {
+ public FileAlterationObserver(final File directory, final FileFilter fileFilter) {
this(directory, fileFilter, (IOCase)null);
}
@@ -184,7 +184,7 @@ public class FileAlterationObserver impl
* @param fileFilter The file filter or null if none
* @param caseSensitivity what case sensitivity to use comparing file names, null means system sensitive
*/
- public FileAlterationObserver(File directory, FileFilter fileFilter, IOCase caseSensitivity) {
+ public FileAlterationObserver(final File directory, final FileFilter fileFilter, final IOCase caseSensitivity) {
this(new FileEntry(directory), fileFilter, caseSensitivity);
}
@@ -196,7 +196,7 @@ public class FileAlterationObserver impl
* @param fileFilter The file filter or null if none
* @param caseSensitivity what case sensitivity to use comparing file names, null means system sensitive
*/
- protected FileAlterationObserver(FileEntry rootEntry, FileFilter fileFilter, IOCase caseSensitivity) {
+ protected FileAlterationObserver(final FileEntry rootEntry, final FileFilter fileFilter, final IOCase caseSensitivity) {
if (rootEntry == null) {
throw new IllegalArgumentException("Root entry is missing");
}
@@ -272,8 +272,8 @@ public class FileAlterationObserver impl
*/
public void initialize() throws Exception {
rootEntry.refresh(rootEntry.getFile());
- File[] files = listFiles(rootEntry.getFile());
- FileEntry[] children = files.length > 0 ? new FileEntry[files.length] : FileEntry.EMPTY_ENTRIES;
+ final File[] files = listFiles(rootEntry.getFile());
+ final FileEntry[] children = files.length > 0 ? new FileEntry[files.length] : FileEntry.EMPTY_ENTRIES;
for (int i = 0; i < files.length; i++) {
children[i] = createFileEntry(rootEntry, files[i]);
}
@@ -294,12 +294,12 @@ public class FileAlterationObserver impl
public void checkAndNotify() {
/* fire onStart() */
- for (FileAlterationListener listener : listeners) {
+ for (final FileAlterationListener listener : listeners) {
listener.onStart(this);
}
/* fire directory/file events */
- File rootFile = rootEntry.getFile();
+ final File rootFile = rootEntry.getFile();
if (rootFile.exists()) {
checkAndNotify(rootEntry, rootEntry.getChildren(), listFiles(rootFile));
} else if (rootEntry.isExists()) {
@@ -309,7 +309,7 @@ public class FileAlterationObserver impl
}
/* fire onStop() */
- for (FileAlterationListener listener : listeners) {
+ for (final FileAlterationListener listener : listeners) {
listener.onStop(this);
}
}
@@ -321,10 +321,10 @@ public class FileAlterationObserver impl
* @param previous The original list of files
* @param files The current list of files
*/
- private void checkAndNotify(FileEntry parent, FileEntry[] previous, File[] files) {
+ private void checkAndNotify(final FileEntry parent, final FileEntry[] previous, final File[] files) {
int c = 0;
- FileEntry[] current = files.length > 0 ? new FileEntry[files.length] : FileEntry.EMPTY_ENTRIES;
- for (FileEntry entry : previous) {
+ final FileEntry[] current = files.length > 0 ? new FileEntry[files.length] : FileEntry.EMPTY_ENTRIES;
+ for (final FileEntry entry : previous) {
while (c < files.length && comparator.compare(entry.getFile(), files[c]) > 0) {
current[c] = createFileEntry(parent, files[c]);
doCreate(current[c]);
@@ -354,11 +354,11 @@ public class FileAlterationObserver impl
* @param file The file to create an entry for
* @return A new file entry
*/
- private FileEntry createFileEntry(FileEntry parent, File file) {
- FileEntry entry = parent.newChildInstance(file);
+ private FileEntry createFileEntry(final FileEntry parent, final File file) {
+ final FileEntry entry = parent.newChildInstance(file);
entry.refresh(file);
- File[] files = listFiles(file);
- FileEntry[] children = files.length > 0 ? new FileEntry[files.length] : FileEntry.EMPTY_ENTRIES;
+ final File[] files = listFiles(file);
+ final FileEntry[] children = files.length > 0 ? new FileEntry[files.length] : FileEntry.EMPTY_ENTRIES;
for (int i = 0; i < files.length; i++) {
children[i] = createFileEntry(entry, files[i]);
}
@@ -371,16 +371,16 @@ public class FileAlterationObserver impl
*
* @param entry The file entry
*/
- private void doCreate(FileEntry entry) {
- for (FileAlterationListener listener : listeners) {
+ private void doCreate(final FileEntry entry) {
+ for (final FileAlterationListener listener : listeners) {
if (entry.isDirectory()) {
listener.onDirectoryCreate(entry.getFile());
} else {
listener.onFileCreate(entry.getFile());
}
}
- FileEntry[] children = entry.getChildren();
- for (FileEntry aChildren : children) {
+ final FileEntry[] children = entry.getChildren();
+ for (final FileEntry aChildren : children) {
doCreate(aChildren);
}
}
@@ -391,9 +391,9 @@ public class FileAlterationObserver impl
* @param entry The previous file system entry
* @param file The current file
*/
- private void doMatch(FileEntry entry, File file) {
+ private void doMatch(final FileEntry entry, final File file) {
if (entry.refresh(file)) {
- for (FileAlterationListener listener : listeners) {
+ for (final FileAlterationListener listener : listeners) {
if (entry.isDirectory()) {
listener.onDirectoryChange(file);
} else {
@@ -408,8 +408,8 @@ public class FileAlterationObserver impl
*
* @param entry The file entry
*/
- private void doDelete(FileEntry entry) {
- for (FileAlterationListener listener : listeners) {
+ private void doDelete(final FileEntry entry) {
+ for (final FileAlterationListener listener : listeners) {
if (entry.isDirectory()) {
listener.onDirectoryDelete(entry.getFile());
} else {
@@ -425,7 +425,7 @@ public class FileAlterationObserver impl
* @return the directory contents or a zero length array if
* the empty or the file is not a directory
*/
- private File[] listFiles(File file) {
+ private File[] listFiles(final File file) {
File[] children = null;
if (file.isDirectory()) {
children = fileFilter == null ? file.listFiles() : file.listFiles(fileFilter);
@@ -446,7 +446,7 @@ public class FileAlterationObserver impl
*/
@Override
public String toString() {
- StringBuilder builder = new StringBuilder();
+ final StringBuilder builder = new StringBuilder();
builder.append(getClass().getSimpleName());
builder.append("[file='");
builder.append(getDirectory().getPath());
Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/monitor/FileEntry.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/monitor/FileEntry.java?rev=1415850&r1=1415849&r2=1415850&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/monitor/FileEntry.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/monitor/FileEntry.java Fri Nov 30 20:51:39 2012
@@ -57,7 +57,7 @@ public class FileEntry implements Serial
*
* @param file The file being monitored
*/
- public FileEntry(File file) {
+ public FileEntry(final File file) {
this((FileEntry)null, file);
}
@@ -67,7 +67,7 @@ public class FileEntry implements Serial
* @param parent The parent
* @param file The file being monitored
*/
- public FileEntry(FileEntry parent, File file) {
+ public FileEntry(final FileEntry parent, final File file) {
if (file == null) {
throw new IllegalArgumentException("File is missing");
}
@@ -90,13 +90,13 @@ public class FileEntry implements Serial
* @param file the file instance to compare to
* @return {@code true} if the file has changed, otherwise {@code false}
*/
- public boolean refresh(File file) {
+ public boolean refresh(final File file) {
// cache original values
- boolean origExists = exists;
- long origLastModified = lastModified;
- boolean origDirectory = directory;
- long origLength = length;
+ final boolean origExists = exists;
+ final long origLastModified = lastModified;
+ final boolean origDirectory = directory;
+ final long origLength = length;
// refresh the values
name = file.getName();
@@ -121,7 +121,7 @@ public class FileEntry implements Serial
* @param file The child file
* @return a new child instance
*/
- public FileEntry newChildInstance(File file) {
+ public FileEntry newChildInstance(final File file) {
return new FileEntry(this, file);
}
@@ -159,7 +159,7 @@ public class FileEntry implements Serial
*
* @param children This directory's files, may be null
*/
- public void setChildren(FileEntry[] children) {
+ public void setChildren(final FileEntry[] children) {
this.children = children;
}
@@ -186,7 +186,7 @@ public class FileEntry implements Serial
*
* @param name the file name
*/
- public void setName(String name) {
+ public void setName(final String name) {
this.name = name;
}
@@ -206,7 +206,7 @@ public class FileEntry implements Serial
*
* @param lastModified The last modified time
*/
- public void setLastModified(long lastModified) {
+ public void setLastModified(final long lastModified) {
this.lastModified = lastModified;
}
@@ -224,7 +224,7 @@ public class FileEntry implements Serial
*
* @param length the length
*/
- public void setLength(long length) {
+ public void setLength(final long length) {
this.length = length;
}
@@ -244,7 +244,7 @@ public class FileEntry implements Serial
*
* @param exists whether the file exists or not
*/
- public void setExists(boolean exists) {
+ public void setExists(final boolean exists) {
this.exists = exists;
}
@@ -262,7 +262,7 @@ public class FileEntry implements Serial
*
* @param directory whether the file is a directory or not
*/
- public void setDirectory(boolean directory) {
+ public void setDirectory(final boolean directory) {
this.directory = directory;
}
}
Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/BrokenOutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/BrokenOutputStream.java?rev=1415850&r1=1415849&r2=1415850&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/BrokenOutputStream.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/BrokenOutputStream.java Fri Nov 30 20:51:39 2012
@@ -40,7 +40,7 @@ public class BrokenOutputStream extends
*
* @param exception the exception to be thrown
*/
- public BrokenOutputStream(IOException exception) {
+ public BrokenOutputStream(final IOException exception) {
this.exception = exception;
}
@@ -58,7 +58,7 @@ public class BrokenOutputStream extends
* @throws IOException always thrown
*/
@Override
- public void write(int b) throws IOException {
+ public void write(final int b) throws IOException {
throw exception;
}
Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/ByteArrayOutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/ByteArrayOutputStream.java?rev=1415850&r1=1415849&r2=1415850&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/ByteArrayOutputStream.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/ByteArrayOutputStream.java Fri Nov 30 20:51:39 2012
@@ -82,7 +82,7 @@ public class ByteArrayOutputStream exten
* @param size the initial size
* @throws IllegalArgumentException if size is negative
*/
- public ByteArrayOutputStream(int size) {
+ public ByteArrayOutputStream(final int size) {
if (size < 0) {
throw new IllegalArgumentException(
"Negative initial size: " + size);
@@ -98,7 +98,7 @@ public class ByteArrayOutputStream exten
*
* @param newcount the size of the buffer if one is created
*/
- private void needNewBuffer(int newcount) {
+ private void needNewBuffer(final int newcount) {
if (currentBufferIndex < buffers.size() - 1) {
//Recycling old buffer
filledBufferSum += currentBuffer.length;
@@ -131,7 +131,7 @@ public class ByteArrayOutputStream exten
* @param len The number of bytes to write
*/
@Override
- public void write(byte[] b, int off, int len) {
+ public void write(final byte[] b, final int off, final int len) {
if ((off < 0)
|| (off > b.length)
|| (len < 0)
@@ -142,11 +142,11 @@ public class ByteArrayOutputStream exten
return;
}
synchronized (this) {
- int newcount = count + len;
+ final int newcount = count + len;
int remaining = len;
int inBufferPos = count - filledBufferSum;
while (remaining > 0) {
- int part = Math.min(remaining, currentBuffer.length - inBufferPos);
+ final int part = Math.min(remaining, currentBuffer.length - inBufferPos);
System.arraycopy(b, off + len - remaining, currentBuffer, inBufferPos, part);
remaining -= part;
if (remaining > 0) {
@@ -163,7 +163,7 @@ public class ByteArrayOutputStream exten
* @param b the byte to write
*/
@Override
- public synchronized void write(int b) {
+ public synchronized void write(final int b) {
int inBufferPos = count - filledBufferSum;
if (inBufferPos == currentBuffer.length) {
needNewBuffer(count + 1);
@@ -184,7 +184,7 @@ public class ByteArrayOutputStream exten
* @throws IOException if an I/O error occurs while reading the input stream
* @since 1.4
*/
- public synchronized int write(InputStream in) throws IOException {
+ public synchronized int write(final InputStream in) throws IOException {
int readCount = 0;
int inBufferPos = count - filledBufferSum;
int n = in.read(currentBuffer, inBufferPos, currentBuffer.length - inBufferPos);
@@ -240,10 +240,10 @@ public class ByteArrayOutputStream exten
* @throws IOException if an I/O error occurs, such as if the stream is closed
* @see java.io.ByteArrayOutputStream#writeTo(OutputStream)
*/
- public synchronized void writeTo(OutputStream out) throws IOException {
+ public synchronized void writeTo(final OutputStream out) throws IOException {
int remaining = count;
- for (byte[] buf : buffers) {
- int c = Math.min(buf.length, remaining);
+ for (final byte[] buf : buffers) {
+ final int c = Math.min(buf.length, remaining);
out.write(buf, 0, c);
remaining -= c;
if (remaining == 0) {
@@ -273,9 +273,9 @@ public class ByteArrayOutputStream exten
* @throws IOException if an I/O error occurs
* @since 2.0
*/
- public static InputStream toBufferedInputStream(InputStream input)
+ public static InputStream toBufferedInputStream(final InputStream input)
throws IOException {
- ByteArrayOutputStream output = new ByteArrayOutputStream();
+ final ByteArrayOutputStream output = new ByteArrayOutputStream();
output.write(input);
return output.toBufferedInputStream();
}
@@ -295,9 +295,9 @@ public class ByteArrayOutputStream exten
if (remaining == 0) {
return new ClosedInputStream();
}
- List<ByteArrayInputStream> list = new ArrayList<ByteArrayInputStream>(buffers.size());
- for (byte[] buf : buffers) {
- int c = Math.min(buf.length, remaining);
+ final List<ByteArrayInputStream> list = new ArrayList<ByteArrayInputStream>(buffers.size());
+ for (final byte[] buf : buffers) {
+ final int c = Math.min(buf.length, remaining);
list.add(new ByteArrayInputStream(buf, 0, c));
remaining -= c;
if (remaining == 0) {
@@ -319,10 +319,10 @@ public class ByteArrayOutputStream exten
if (remaining == 0) {
return EMPTY_BYTE_ARRAY;
}
- byte newbuf[] = new byte[remaining];
+ final byte newbuf[] = new byte[remaining];
int pos = 0;
- for (byte[] buf : buffers) {
- int c = Math.min(buf.length, remaining);
+ for (final byte[] buf : buffers) {
+ final int c = Math.min(buf.length, remaining);
System.arraycopy(buf, 0, newbuf, pos, c);
pos += c;
remaining -= c;
@@ -352,7 +352,7 @@ public class ByteArrayOutputStream exten
* @throws UnsupportedEncodingException if the encoding is not supported
* @see java.io.ByteArrayOutputStream#toString(String)
*/
- public String toString(String enc) throws UnsupportedEncodingException {
+ public String toString(final String enc) throws UnsupportedEncodingException {
return new String(toByteArray(), enc);
}
Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/CloseShieldOutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/CloseShieldOutputStream.java?rev=1415850&r1=1415849&r2=1415850&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/CloseShieldOutputStream.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/CloseShieldOutputStream.java Fri Nov 30 20:51:39 2012
@@ -36,7 +36,7 @@ public class CloseShieldOutputStream ext
*
* @param out underlying output stream
*/
- public CloseShieldOutputStream(OutputStream out) {
+ public CloseShieldOutputStream(final OutputStream out) {
super(out);
}
Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/ClosedOutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/ClosedOutputStream.java?rev=1415850&r1=1415849&r2=1415850&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/ClosedOutputStream.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/ClosedOutputStream.java Fri Nov 30 20:51:39 2012
@@ -44,7 +44,7 @@ public class ClosedOutputStream extends
* @throws IOException always thrown
*/
@Override
- public void write(int b) throws IOException {
+ public void write(final int b) throws IOException {
throw new IOException("write(" + b + ") failed: stream is closed");
}