This commit is contained in:
joewitt 2015-04-28 00:32:13 -04:00
parent e1160f5932
commit 525ce7fb2d
29 changed files with 203 additions and 449 deletions

View File

@ -19,18 +19,15 @@ package org.apache.nifi.flowfile.attributes;
public enum CoreAttributes implements FlowFileAttributeKey {
/**
* The flowfile's path indicates the relative directory to which a FlowFile
* belongs and does not contain the filename
* The flowfile's path indicates the relative directory to which a FlowFile belongs and does not contain the filename
*/
PATH("path"),
/**
* The flowfile's absolute path indicates the absolute directory to which a
* FlowFile belongs and does not contain the filename
* The flowfile's absolute path indicates the absolute directory to which a FlowFile belongs and does not contain the filename
*/
ABSOLUTE_PATH("absolute.path"),
/**
* The filename of the FlowFile. The filename should not contain any
* directory structure.
* The filename of the FlowFile. The filename should not contain any directory structure.
*/
FILENAME("filename"),
/**
@ -50,8 +47,7 @@ public enum CoreAttributes implements FlowFileAttributeKey {
*/
DISCARD_REASON("discard.reason"),
/**
* Indicates an identifier other than the FlowFile's UUID that is known to
* refer to this FlowFile.
* Indicates an identifier other than the FlowFile's UUID that is known to refer to this FlowFile.
*/
ALTERNATE_IDENTIFIER("alternate.identifier");

View File

@ -26,13 +26,10 @@ public interface VersionNegotiator {
int getVersion();
/**
* Sets the version of this resource to the specified version. Only the
* lower byte of the version is relevant.
* Sets the version of this resource to the specified version. Only the lower byte of the version is relevant.
*
* @param version the version to set
* @throws IllegalArgumentException if the given Version is not supported by
* this resource, as is indicated by the {@link #isVersionSupported(int)}
* method
* @throws IllegalArgumentException if the given Version is not supported by this resource, as is indicated by the {@link #isVersionSupported(int)} method
*/
void setVersion(int version) throws IllegalArgumentException;
@ -43,9 +40,8 @@ public interface VersionNegotiator {
int getPreferredVersion();
/**
* Gets the preferred version of this resource that is no greater than the
* given maxVersion. If no acceptable version exists that is less than
* <code>maxVersion</code>, then <code>null</code> is returned
* Gets the preferred version of this resource that is no greater than the given maxVersion. If no acceptable version exists that is less than <code>maxVersion</code>, then <code>null</code> is
* returned
*
* @param maxVersion the maximum version desired
* @return the preferred version if found; null otherwise
@ -53,8 +49,7 @@ public interface VersionNegotiator {
Integer getPreferredVersion(int maxVersion);
/**
* Indicates whether or not the specified version is supported by this
* resource
* Indicates whether or not the specified version is supported by this resource
*
* @param version the version to test
* @return true if supported; false otherwise

View File

@ -17,8 +17,7 @@
package org.apache.nifi.remote.exception;
/**
* Indicates that the user disabled transmission while communications were
* taking place with a peer
* Indicates that the user disabled transmission while communications were taking place with a peer
*/
public class TransmissionDisabledException extends RuntimeException {

View File

@ -58,8 +58,7 @@ public class CompressionOutputStream extends OutputStream {
}
/**
* Compresses the currently buffered chunk of data and sends it to the
* output stream
* Compresses the currently buffered chunk of data and sends it to the output stream
*
* @throws IOException if issues occur writing to stream
*/

View File

@ -38,9 +38,7 @@ public class BufferStateManager {
}
/**
* Ensures that the buffer is at least as big as the size specified,
* resizing the buffer if necessary. This operation MAY change the direction
* of the buffer.
* Ensures that the buffer is at least as big as the size specified, resizing the buffer if necessary. This operation MAY change the direction of the buffer.
*
* @param requiredSize the desired size of the buffer
*/

View File

@ -47,8 +47,7 @@ public class SSLSocketChannelInputStream extends InputStream {
}
/**
* Closes the underlying SSLSocketChannel, which will also close the
* OutputStream and connection
* Closes the underlying SSLSocketChannel, which will also close the OutputStream and connection
*/
@Override
public void close() throws IOException {

View File

@ -43,8 +43,7 @@ public class SSLSocketChannelOutputStream extends OutputStream {
}
/**
* Closes the underlying SSLSocketChannel, which also will close the
* InputStream and the connection
* Closes the underlying SSLSocketChannel, which also will close the InputStream and the connection
*/
@Override
public void close() throws IOException {

View File

@ -19,11 +19,8 @@ package org.apache.nifi.stream.io;
import java.io.InputStream;
/**
* This class is a slight modification of the BufferedInputStream in the java.io
* package. The modification is that this implementation does not provide
* synchronization on method calls, which means that this class is not suitable
* for use by multiple threads. However, the absence of these synchronized
* blocks results in potentially much better performance.
* This class is a slight modification of the BufferedInputStream in the java.io package. The modification is that this implementation does not provide synchronization on method calls, which means
* that this class is not suitable for use by multiple threads. However, the absence of these synchronized blocks results in potentially much better performance.
*/
public class BufferedInputStream extends java.io.BufferedInputStream {

View File

@ -21,11 +21,8 @@ import java.io.IOException;
import java.io.OutputStream;
/**
* This class is a slight modification of the
* {@link java.io.BufferedOutputStream} class. This implementation differs in
* that it does not mark methods as synchronized. This means that this class is
* not suitable for writing by multiple concurrent threads. However, the removal
* of the synchronized keyword results in potentially much better performance.
* This class is a slight modification of the {@link java.io.BufferedOutputStream} class. This implementation differs in that it does not mark methods as synchronized. This means that this class is
* not suitable for writing by multiple concurrent threads. However, the removal of the synchronized keyword results in potentially much better performance.
*/
public class BufferedOutputStream extends FilterOutputStream {
@ -35,15 +32,13 @@ public class BufferedOutputStream extends FilterOutputStream {
protected byte buf[];
/**
* The number of valid bytes in the buffer. This value is always in the
* range <tt>0</tt> through <tt>buf.length</tt>; elements
* The number of valid bytes in the buffer. This value is always in the range <tt>0</tt> through <tt>buf.length</tt>; elements
* <tt>buf[0]</tt> through <tt>buf[count-1]</tt> contain valid byte data.
*/
protected int count;
/**
* Creates a new buffered output stream to write data to the specified
* underlying output stream.
* Creates a new buffered output stream to write data to the specified underlying output stream.
*
* @param out the underlying output stream.
*/
@ -52,8 +47,7 @@ public class BufferedOutputStream extends FilterOutputStream {
}
/**
* Creates a new buffered output stream to write data to the specified
* underlying output stream with the specified buffer size.
* Creates a new buffered output stream to write data to the specified underlying output stream with the specified buffer size.
*
* @param out the underlying output stream.
* @param size the buffer size.
@ -92,16 +86,12 @@ public class BufferedOutputStream extends FilterOutputStream {
}
/**
* Writes <code>len</code> bytes from the specified byte array starting at
* offset <code>off</code> to this buffered output stream.
* Writes <code>len</code> bytes from the specified byte array starting at offset <code>off</code> to this buffered output stream.
*
* <p>
* Ordinarily this method stores bytes from the given array into this
* stream's buffer, flushing the buffer to the underlying output stream as
* needed. If the requested length is at least as large as this stream's
* buffer, however, then this method will flush the buffer and write the
* bytes directly to the underlying output stream. Thus redundant
* <code>BufferedOutputStream</code>s will not copy data unnecessarily.
* Ordinarily this method stores bytes from the given array into this stream's buffer, flushing the buffer to the underlying output stream as needed. If the requested length is at least as large
* as this stream's buffer, however, then this method will flush the buffer and write the bytes directly to the underlying output stream. Thus redundant <code>BufferedOutputStream</code>s will not
* copy data unnecessarily.
*
* @param b the data.
* @param off the start offset in the data.
@ -126,8 +116,7 @@ public class BufferedOutputStream extends FilterOutputStream {
}
/**
* Flushes this buffered output stream. This forces any buffered output
* bytes to be written out to the underlying output stream.
* Flushes this buffered output stream. This forces any buffered output bytes to be written out to the underlying output stream.
*
* @exception IOException if an I/O error occurs.
* @see java.io.FilterOutputStream#out

View File

@ -19,55 +19,41 @@ package org.apache.nifi.stream.io;
import java.io.InputStream;
/**
* This class performs the same function as java.io.ByteArrayInputStream but
* does not mark its methods as synchronized
* This class performs the same function as java.io.ByteArrayInputStream but does not mark its methods as synchronized
*/
public class ByteArrayInputStream extends InputStream {
/**
* An array of bytes that was provided by the creator of the stream.
* Elements <code>buf[0]</code> through <code>buf[count-1]</code> are the
* only bytes that can ever be read from the stream; element
* <code>buf[pos]</code> is the next byte to be read.
* An array of bytes that was provided by the creator of the stream. Elements <code>buf[0]</code> through <code>buf[count-1]</code> are the only bytes that can ever be read from the stream;
* element <code>buf[pos]</code> is the next byte to be read.
*/
protected byte buf[];
/**
* The index of the next character to read from the input stream buffer.
* This value should always be nonnegative and not larger than the value of
* <code>count</code>. The next byte to be read from the input stream buffer
* will be <code>buf[pos]</code>.
* The index of the next character to read from the input stream buffer. This value should always be nonnegative and not larger than the value of <code>count</code>. The next byte to be read from
* the input stream buffer will be <code>buf[pos]</code>.
*/
protected int pos;
/**
* The currently marked position in the stream. ByteArrayInputStream objects
* are marked at position zero by default when constructed. They may be
* marked at another position within the buffer by the <code>mark()</code>
* method. The current buffer position is set to this point by the
* <code>reset()</code> method.
* The currently marked position in the stream. ByteArrayInputStream objects are marked at position zero by default when constructed. They may be marked at another position within the buffer by
* the <code>mark()</code> method. The current buffer position is set to this point by the <code>reset()</code> method.
* <p>
* If no mark has been set, then the value of mark is the offset passed to
* the constructor (or 0 if the offset was not supplied).
* If no mark has been set, then the value of mark is the offset passed to the constructor (or 0 if the offset was not supplied).
*
* @since JDK1.1
*/
protected int mark = 0;
/**
* The index one greater than the last valid character in the input stream
* buffer. This value should always be nonnegative and not larger than the
* length of <code>buf</code>. It is one greater than the position of the
* last byte within <code>buf</code> that can ever be read from the input
* stream buffer.
* The index one greater than the last valid character in the input stream buffer. This value should always be nonnegative and not larger than the length of <code>buf</code>. It is one greater
* than the position of the last byte within <code>buf</code> that can ever be read from the input stream buffer.
*/
protected int count;
/**
* Creates a <code>ByteArrayInputStream</code> so that it uses
* <code>buf</code> as its buffer array. The buffer array is not copied. The
* initial value of <code>pos</code> is <code>0</code> and the initial value
* of <code>count</code> is the length of <code>buf</code>.
* Creates a <code>ByteArrayInputStream</code> so that it uses <code>buf</code> as its buffer array. The buffer array is not copied. The initial value of <code>pos</code> is <code>0</code> and the
* initial value of <code>count</code> is the length of <code>buf</code>.
*
* @param buf the input buffer.
*/
@ -78,12 +64,8 @@ public class ByteArrayInputStream extends InputStream {
}
/**
* Creates <code>ByteArrayInputStream</code> that uses <code>buf</code> as
* its buffer array. The initial value of <code>pos</code> is
* <code>offset</code> and the initial value of <code>count</code> is the
* minimum of <code>offset+length</code> and <code>buf.length</code>. The
* buffer array is not copied. The buffer's mark is set to the specified
* offset.
* Creates <code>ByteArrayInputStream</code> that uses <code>buf</code> as its buffer array. The initial value of <code>pos</code> is <code>offset</code> and the initial value of
* <code>count</code> is the minimum of <code>offset+length</code> and <code>buf.length</code>. The buffer array is not copied. The buffer's mark is set to the specified offset.
*
* @param buf the input buffer.
* @param offset the offset in the buffer of the first byte to read.
@ -97,15 +79,12 @@ public class ByteArrayInputStream extends InputStream {
}
/**
* Reads the next byte of data from this input stream. The value byte is
* returned as an <code>int</code> in the range <code>0</code> to
* <code>255</code>. If no byte is available because the end of the stream
* has been reached, the value <code>-1</code> is returned.
* Reads the next byte of data from this input stream. The value byte is returned as an <code>int</code> in the range <code>0</code> to <code>255</code>. If no byte is available because the end of
* the stream has been reached, the value <code>-1</code> is returned.
* <p>
* This <code>read</code> method cannot block.
*
* @return the next byte of data, or <code>-1</code> if the end of the
* stream has been reached.
* @return the next byte of data, or <code>-1</code> if the end of the stream has been reached.
*/
@Override
public int read() {
@ -113,29 +92,19 @@ public class ByteArrayInputStream extends InputStream {
}
/**
* Reads up to <code>len</code> bytes of data into an array of bytes from
* this input stream. If <code>pos</code> equals <code>count</code>, then
* <code>-1</code> is returned to indicate end of file. Otherwise, the
* number <code>k</code> of bytes read is equal to the smaller of
* <code>len</code> and <code>count-pos</code>. If <code>k</code> is
* positive, then bytes <code>buf[pos]</code> through
* <code>buf[pos+k-1]</code> are copied into <code>b[off]</code> through
* <code>b[off+k-1]</code> in the manner performed by
* <code>System.arraycopy</code>. The value <code>k</code> is added into
* <code>pos</code> and <code>k</code> is returned.
* Reads up to <code>len</code> bytes of data into an array of bytes from this input stream. If <code>pos</code> equals <code>count</code>, then <code>-1</code> is returned to indicate end of
* file. Otherwise, the number <code>k</code> of bytes read is equal to the smaller of <code>len</code> and <code>count-pos</code>. If <code>k</code> is positive, then bytes <code>buf[pos]</code>
* through <code>buf[pos+k-1]</code> are copied into <code>b[off]</code> through <code>b[off+k-1]</code> in the manner performed by <code>System.arraycopy</code>. The value <code>k</code> is added
* into <code>pos</code> and <code>k</code> is returned.
* <p>
* This <code>read</code> method cannot block.
*
* @param b the buffer into which the data is read.
* @param off the start offset in the destination array <code>b</code>
* @param len the maximum number of bytes read.
* @return the total number of bytes read into the buffer, or
* <code>-1</code> if there is no more data because the end of the stream
* has been reached.
* @return the total number of bytes read into the buffer, or <code>-1</code> if there is no more data because the end of the stream has been reached.
* @exception NullPointerException If <code>b</code> is <code>null</code>.
* @exception IndexOutOfBoundsException If <code>off</code> is negative,
* <code>len</code> is negative, or <code>len</code> is greater than
* <code>b.length - off</code>
* @exception IndexOutOfBoundsException If <code>off</code> is negative, <code>len</code> is negative, or <code>len</code> is greater than <code>b.length - off</code>
*/
@Override
public int read(byte b[], int off, int len) {
@ -162,11 +131,8 @@ public class ByteArrayInputStream extends InputStream {
}
/**
* Skips <code>n</code> bytes of input from this input stream. Fewer bytes
* might be skipped if the end of the input stream is reached. The actual
* number <code>k</code> of bytes to be skipped is equal to the smaller of
* <code>n</code> and <code>count-pos</code>. The value <code>k</code> is
* added into <code>pos</code> and <code>k</code> is returned.
* Skips <code>n</code> bytes of input from this input stream. Fewer bytes might be skipped if the end of the input stream is reached. The actual number <code>k</code> of bytes to be skipped is
* equal to the smaller of <code>n</code> and <code>count-pos</code>. The value <code>k</code> is added into <code>pos</code> and <code>k</code> is returned.
*
* @param n the number of bytes to be skipped.
* @return the actual number of bytes skipped.
@ -183,14 +149,11 @@ public class ByteArrayInputStream extends InputStream {
}
/**
* Returns the number of remaining bytes that can be read (or skipped over)
* from this input stream.
* Returns the number of remaining bytes that can be read (or skipped over) from this input stream.
* <p>
* The value returned is <code>count&nbsp;- pos</code>, which is the number
* of bytes remaining to be read from the input buffer.
* The value returned is <code>count&nbsp;- pos</code>, which is the number of bytes remaining to be read from the input buffer.
*
* @return the number of remaining bytes that can be read (or skipped over)
* from this input stream without blocking.
* @return the number of remaining bytes that can be read (or skipped over) from this input stream without blocking.
*/
@Override
public int available() {
@ -198,9 +161,7 @@ public class ByteArrayInputStream extends InputStream {
}
/**
* Tests if this <code>InputStream</code> supports mark/reset. The
* <code>markSupported</code> method of <code>ByteArrayInputStream</code>
* always returns <code>true</code>.
* Tests if this <code>InputStream</code> supports mark/reset. The <code>markSupported</code> method of <code>ByteArrayInputStream</code> always returns <code>true</code>.
*
* @since JDK1.1
*/
@ -210,12 +171,10 @@ public class ByteArrayInputStream extends InputStream {
}
/**
* Set the current marked position in the stream. ByteArrayInputStream
* objects are marked at position zero by default when constructed. They may
* be marked at another position within the buffer by this method.
* Set the current marked position in the stream. ByteArrayInputStream objects are marked at position zero by default when constructed. They may be marked at another position within the buffer by
* this method.
* <p>
* If no mark has been set, then the value of the mark is the offset passed
* to the constructor (or 0 if the offset was not supplied).
* If no mark has been set, then the value of the mark is the offset passed to the constructor (or 0 if the offset was not supplied).
*
* <p>
* Note: The <code>readAheadLimit</code> for this class has no meaning.
@ -228,9 +187,7 @@ public class ByteArrayInputStream extends InputStream {
}
/**
* Resets the buffer to the marked position. The marked position is 0 unless
* another position was marked or an offset was specified in the
* constructor.
* Resets the buffer to the marked position. The marked position is 0 unless another position was marked or an offset was specified in the constructor.
*/
@Override
public void reset() {
@ -238,9 +195,7 @@ public class ByteArrayInputStream extends InputStream {
}
/**
* Closing a <tt>ByteArrayInputStream</tt> has no effect. The methods in
* this class can be called after the stream has been closed without
* generating an <tt>IOException</tt>.
* Closing a <tt>ByteArrayInputStream</tt> has no effect. The methods in this class can be called after the stream has been closed without generating an <tt>IOException</tt>.
* <p>
*/
@Override

View File

@ -22,14 +22,11 @@ import java.io.UnsupportedEncodingException;
import java.util.Arrays;
/**
* This class provides a more efficient implementation of the
* java.io.ByteArrayOutputStream. The efficiency is gained in two ways:
* This class provides a more efficient implementation of the java.io.ByteArrayOutputStream. The efficiency is gained in two ways:
* <ul>
* <li>The write methods are not synchronized</li>
* <li>The class provides {@link #getUnderlyingBuffer()} and
* {@link #getBufferLength()}, which can be used to access the underlying byte
* array directly, rather than the System.arraycopy that {@link #toByteArray()}
* uses
* <li>The class provides {@link #getUnderlyingBuffer()} and {@link #getBufferLength()}, which can be used to access the underlying byte array directly, rather than the System.arraycopy that
* {@link #toByteArray()} uses
* </ul>
*
*/
@ -46,16 +43,14 @@ public class ByteArrayOutputStream extends OutputStream {
protected int count;
/**
* Creates a new byte array output stream. The buffer capacity is initially
* 32 bytes, though its size increases if necessary.
* Creates a new byte array output stream. The buffer capacity is initially 32 bytes, though its size increases if necessary.
*/
public ByteArrayOutputStream() {
this(32);
}
/**
* Creates a new byte array output stream, with a buffer capacity of the
* specified size, in bytes.
* Creates a new byte array output stream, with a buffer capacity of the specified size, in bytes.
*
* @param size the initial size.
* @exception IllegalArgumentException if size is negative.
@ -69,13 +64,10 @@ public class ByteArrayOutputStream extends OutputStream {
}
/**
* Increases the capacity if necessary to ensure that it can hold at least
* the number of elements specified by the minimum capacity argument.
* Increases the capacity if necessary to ensure that it can hold at least the number of elements specified by the minimum capacity argument.
*
* @param minCapacity the desired minimum capacity
* @throws OutOfMemoryError if {@code minCapacity < 0}. This is interpreted
* as a request for the unsatisfiably large capacity
* {@code (long) Integer.MAX_VALUE + (minCapacity - Integer.MAX_VALUE)}.
* @throws OutOfMemoryError if {@code minCapacity < 0}. This is interpreted as a request for the unsatisfiably large capacity {@code (long) Integer.MAX_VALUE + (minCapacity - Integer.MAX_VALUE)}.
*/
private void ensureCapacity(int minCapacity) {
// overflow-conscious code
@ -85,8 +77,7 @@ public class ByteArrayOutputStream extends OutputStream {
}
/**
* Increases the capacity to ensure that it can hold at least the number of
* elements specified by the minimum capacity argument.
* Increases the capacity to ensure that it can hold at least the number of elements specified by the minimum capacity argument.
*
* @param minCapacity the desired minimum capacity
*/
@ -119,8 +110,7 @@ public class ByteArrayOutputStream extends OutputStream {
}
/**
* Writes <code>len</code> bytes from the specified byte array starting at
* offset <code>off</code> to this byte array output stream.
* Writes <code>len</code> bytes from the specified byte array starting at offset <code>off</code> to this byte array output stream.
*
* @param b the data.
* @param off the start offset in the data.
@ -138,9 +128,8 @@ public class ByteArrayOutputStream extends OutputStream {
}
/**
* Writes the complete contents of this byte array output stream to the
* specified output stream argument, as if by calling the output stream's
* write method using <code>out.write(buf, 0, count)</code>.
* Writes the complete contents of this byte array output stream to the specified output stream argument, as if by calling the output stream's write method using
* <code>out.write(buf, 0, count)</code>.
*
* @param out the output stream to which to write the data.
* @exception IOException if an I/O error occurs.
@ -150,10 +139,8 @@ public class ByteArrayOutputStream extends OutputStream {
}
/**
* Resets the <code>count</code> field of this byte array output stream to
* zero, so that all currently accumulated output in the output stream is
* discarded. The output stream can be used again, reusing the already
* allocated buffer space.
* Resets the <code>count</code> field of this byte array output stream to zero, so that all currently accumulated output in the output stream is discarded. The output stream can be used again,
* reusing the already allocated buffer space.
*
* @see java.io.ByteArrayInputStream#count
*/
@ -162,9 +149,7 @@ public class ByteArrayOutputStream extends OutputStream {
}
/**
* Creates a newly allocated byte array. Its size is the current size of
* this output stream and the valid contents of the buffer have been copied
* into it.
* Creates a newly allocated byte array. Its size is the current size of this output stream and the valid contents of the buffer have been copied into it.
*
* @return the current contents of this output stream, as a byte array.
* @see java.io.ByteArrayOutputStream#size()
@ -176,8 +161,7 @@ public class ByteArrayOutputStream extends OutputStream {
/**
* Returns the current size of the buffer.
*
* @return the value of the <code>count</code> field, which is the number of
* valid bytes in this output stream.
* @return the value of the <code>count</code> field, which is the number of valid bytes in this output stream.
* @see java.io.ByteArrayOutputStream#count
*/
public int size() {
@ -185,16 +169,12 @@ public class ByteArrayOutputStream extends OutputStream {
}
/**
* Converts the buffer's contents into a string decoding bytes using the
* platform's default character set. The length of the new <tt>String</tt>
* is a function of the character set, and hence may not be equal to the
* size of the buffer.
* Converts the buffer's contents into a string decoding bytes using the platform's default character set. The length of the new <tt>String</tt>
* is a function of the character set, and hence may not be equal to the size of the buffer.
*
* <p>
* This method always replaces malformed-input and unmappable-character
* sequences with the default replacement string for the platform's default
* character set. The {@linkplain java.nio.charset.CharsetDecoder} class
* should be used when more control over the decoding process is required.
* This method always replaces malformed-input and unmappable-character sequences with the default replacement string for the platform's default character set. The
* {@linkplain java.nio.charset.CharsetDecoder} class should be used when more control over the decoding process is required.
*
* @return String decoded from the buffer's contents.
* @since JDK1.1
@ -205,22 +185,16 @@ public class ByteArrayOutputStream extends OutputStream {
}
/**
* Converts the buffer's contents into a string by decoding the bytes using
* the specified {@link java.nio.charset.Charset charsetName}. The length of
* the new <tt>String</tt> is a function of the charset, and hence may not
* be equal to the length of the byte array.
* Converts the buffer's contents into a string by decoding the bytes using the specified {@link java.nio.charset.Charset charsetName}. The length of the new <tt>String</tt> is a function of the
* charset, and hence may not be equal to the length of the byte array.
*
* <p>
* This method always replaces malformed-input and unmappable-character
* sequences with this charset's default replacement string. The {@link
* java.nio.charset.CharsetDecoder} class should be used when more control
* over the decoding process is required.
* This method always replaces malformed-input and unmappable-character sequences with this charset's default replacement string. The {@link
* java.nio.charset.CharsetDecoder} class should be used when more control over the decoding process is required.
*
* @param charsetName the name of a supported
* {@linkplain java.nio.charset.Charset <code>charset</code>}
* @param charsetName the name of a supported {@linkplain java.nio.charset.Charset <code>charset</code>}
* @return String decoded from the buffer's contents.
* @exception UnsupportedEncodingException If the named charset is not
* supported
* @exception UnsupportedEncodingException If the named charset is not supported
* @since JDK1.1
*/
public String toString(String charsetName) throws UnsupportedEncodingException {
@ -228,9 +202,7 @@ public class ByteArrayOutputStream extends OutputStream {
}
/**
* Closing a <tt>ByteArrayOutputStream</tt> has no effect. The methods in
* this class can be called after the stream has been closed without
* generating an <tt>IOException</tt>.
* Closing a <tt>ByteArrayOutputStream</tt> has no effect. The methods in this class can be called after the stream has been closed without generating an <tt>IOException</tt>.
* <p>
*
*/

View File

@ -33,7 +33,6 @@ public class ByteCountingOutputStream extends OutputStream {
this.bytesWritten = initialByteCount;
}
@Override
public void write(int b) throws IOException {
out.write(b);
@ -45,8 +44,6 @@ public class ByteCountingOutputStream extends OutputStream {
write(b, 0, b.length);
}
;
@Override
public void write(byte[] b, int off, int len) throws IOException {
out.write(b, off, len);

View File

@ -23,14 +23,12 @@ import java.io.OutputStream;
import java.io.UTFDataFormatException;
/**
* This class is different from java.io.DataOutputStream in that it does
* synchronize on its methods.
* This class is different from java.io.DataOutputStream in that it does synchronize on its methods.
*/
public class DataOutputStream extends FilterOutputStream implements DataOutput {
/**
* The number of bytes written to the data output stream so far. If this
* counter overflows, it will be wrapped to Integer.MAX_VALUE.
* The number of bytes written to the data output stream so far. If this counter overflows, it will be wrapped to Integer.MAX_VALUE.
*/
protected int written;
@ -40,9 +38,7 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput {
private byte[] bytearr = null;
/**
* Creates a new data output stream to write data to the specified
* underlying output stream. The counter <code>written</code> is set to
* zero.
* Creates a new data output stream to write data to the specified underlying output stream. The counter <code>written</code> is set to zero.
*
* @param out the underlying output stream, to be saved for later use.
* @see java.io.FilterOutputStream#out
@ -52,8 +48,7 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput {
}
/**
* Increases the written counter by the specified value until it reaches
* Integer.MAX_VALUE.
* Increases the written counter by the specified value until it reaches Integer.MAX_VALUE.
*/
private void incCount(int value) {
int temp = written + value;
@ -64,9 +59,7 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput {
}
/**
* Writes the specified byte (the low eight bits of the argument
* <code>b</code>) to the underlying output stream. If no exception is
* thrown, the counter <code>written</code> is incremented by
* Writes the specified byte (the low eight bits of the argument <code>b</code>) to the underlying output stream. If no exception is thrown, the counter <code>written</code> is incremented by
* <code>1</code>.
* <p>
* Implements the <code>write</code> method of <code>OutputStream</code>.
@ -82,10 +75,8 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput {
}
/**
* Writes <code>len</code> bytes from the specified byte array starting at
* offset <code>off</code> to the underlying output stream. If no exception
* is thrown, the counter <code>written</code> is incremented by
* <code>len</code>.
* Writes <code>len</code> bytes from the specified byte array starting at offset <code>off</code> to the underlying output stream. If no exception is thrown, the counter <code>written</code> is
* incremented by <code>len</code>.
*
* @param b the data.
* @param off the start offset in the data.
@ -100,11 +91,9 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput {
}
/**
* Flushes this data output stream. This forces any buffered output bytes to
* be written out to the stream.
* Flushes this data output stream. This forces any buffered output bytes to be written out to the stream.
* <p>
* The <code>flush</code> method of <code>DataOutputStream</code> calls the
* <code>flush</code> method of its underlying output stream.
* The <code>flush</code> method of <code>DataOutputStream</code> calls the <code>flush</code> method of its underlying output stream.
*
* @exception IOException if an I/O error occurs.
* @see java.io.FilterOutputStream#out
@ -116,11 +105,8 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput {
}
/**
* Writes a <code>boolean</code> to the underlying output stream as a 1-byte
* value. The value <code>true</code> is written out as the value
* <code>(byte)1</code>; the value <code>false</code> is written out as the
* value <code>(byte)0</code>. If no exception is thrown, the counter
* <code>written</code> is incremented by <code>1</code>.
* Writes a <code>boolean</code> to the underlying output stream as a 1-byte value. The value <code>true</code> is written out as the value <code>(byte)1</code>; the value <code>false</code> is
* written out as the value <code>(byte)0</code>. If no exception is thrown, the counter <code>written</code> is incremented by <code>1</code>.
*
* @param v a <code>boolean</code> value to be written.
* @exception IOException if an I/O error occurs.
@ -133,9 +119,7 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput {
}
/**
* Writes out a <code>byte</code> to the underlying output stream as a
* 1-byte value. If no exception is thrown, the counter <code>written</code>
* is incremented by <code>1</code>.
* Writes out a <code>byte</code> to the underlying output stream as a 1-byte value. If no exception is thrown, the counter <code>written</code> is incremented by <code>1</code>.
*
* @param v a <code>byte</code> value to be written.
* @exception IOException if an I/O error occurs.
@ -148,9 +132,7 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput {
}
/**
* Writes a <code>short</code> to the underlying output stream as two bytes,
* high byte first. If no exception is thrown, the counter
* <code>written</code> is incremented by <code>2</code>.
* Writes a <code>short</code> to the underlying output stream as two bytes, high byte first. If no exception is thrown, the counter <code>written</code> is incremented by <code>2</code>.
*
* @param v a <code>short</code> to be written.
* @exception IOException if an I/O error occurs.
@ -164,9 +146,7 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput {
}
/**
* Writes a <code>char</code> to the underlying output stream as a 2-byte
* value, high byte first. If no exception is thrown, the counter
* <code>written</code> is incremented by <code>2</code>.
* Writes a <code>char</code> to the underlying output stream as a 2-byte value, high byte first. If no exception is thrown, the counter <code>written</code> is incremented by <code>2</code>.
*
* @param v a <code>char</code> value to be written.
* @exception IOException if an I/O error occurs.
@ -180,9 +160,7 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput {
}
/**
* Writes an <code>int</code> to the underlying output stream as four bytes,
* high byte first. If no exception is thrown, the counter
* <code>written</code> is incremented by <code>4</code>.
* Writes an <code>int</code> to the underlying output stream as four bytes, high byte first. If no exception is thrown, the counter <code>written</code> is incremented by <code>4</code>.
*
* @param v an <code>int</code> to be written.
* @exception IOException if an I/O error occurs.
@ -200,9 +178,7 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput {
private final byte writeBuffer[] = new byte[8];
/**
* Writes a <code>long</code> to the underlying output stream as eight
* bytes, high byte first. In no exception is thrown, the counter
* <code>written</code> is incremented by <code>8</code>.
* Writes a <code>long</code> to the underlying output stream as eight bytes, high byte first. In no exception is thrown, the counter <code>written</code> is incremented by <code>8</code>.
*
* @param v a <code>long</code> to be written.
* @exception IOException if an I/O error occurs.
@ -223,11 +199,8 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput {
}
/**
* Converts the float argument to an <code>int</code> using the
* <code>floatToIntBits</code> method in class <code>Float</code>, and then
* writes that <code>int</code> value to the underlying output stream as a
* 4-byte quantity, high byte first. If no exception is thrown, the counter
* <code>written</code> is incremented by <code>4</code>.
* Converts the float argument to an <code>int</code> using the <code>floatToIntBits</code> method in class <code>Float</code>, and then writes that <code>int</code> value to the underlying output
* stream as a 4-byte quantity, high byte first. If no exception is thrown, the counter <code>written</code> is incremented by <code>4</code>.
*
* @param v a <code>float</code> value to be written.
* @exception IOException if an I/O error occurs.
@ -240,11 +213,8 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput {
}
/**
* Converts the double argument to a <code>long</code> using the
* <code>doubleToLongBits</code> method in class <code>Double</code>, and
* then writes that <code>long</code> value to the underlying output stream
* as an 8-byte quantity, high byte first. If no exception is thrown, the
* counter <code>written</code> is incremented by <code>8</code>.
* Converts the double argument to a <code>long</code> using the <code>doubleToLongBits</code> method in class <code>Double</code>, and then writes that <code>long</code> value to the underlying
* output stream as an 8-byte quantity, high byte first. If no exception is thrown, the counter <code>written</code> is incremented by <code>8</code>.
*
* @param v a <code>double</code> value to be written.
* @exception IOException if an I/O error occurs.
@ -257,10 +227,8 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput {
}
/**
* Writes out the string to the underlying output stream as a sequence of
* bytes. Each character in the string is written out, in sequence, by
* discarding its high eight bits. If no exception is thrown, the counter
* <code>written</code> is incremented by the length of <code>s</code>.
* Writes out the string to the underlying output stream as a sequence of bytes. Each character in the string is written out, in sequence, by discarding its high eight bits. If no exception is
* thrown, the counter <code>written</code> is incremented by the length of <code>s</code>.
*
* @param s a string of bytes to be written.
* @exception IOException if an I/O error occurs.
@ -276,11 +244,8 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput {
}
/**
* Writes a string to the underlying output stream as a sequence of
* characters. Each character is written to the data output stream as if by
* the <code>writeChar</code> method. If no exception is thrown, the counter
* <code>written</code> is incremented by twice the length of
* <code>s</code>.
* Writes a string to the underlying output stream as a sequence of characters. Each character is written to the data output stream as if by the <code>writeChar</code> method. If no exception is
* thrown, the counter <code>written</code> is incremented by twice the length of <code>s</code>.
*
* @param s a <code>String</code> value to be written.
* @exception IOException if an I/O error occurs.
@ -303,15 +268,10 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput {
* <a href="DataInput.html#modified-utf-8">modified UTF-8</a>
* encoding in a machine-independent manner.
* <p>
* First, two bytes are written to the output stream as if by the
* <code>writeShort</code> method giving the number of bytes to follow. This
* value is the number of bytes actually written out, not the length of the
* string. Following the length, each character of the string is output, in
* sequence, using the modified UTF-8 encoding for the character. If no
* exception is thrown, the counter <code>written</code> is incremented by
* the total number of bytes written to the output stream. This will be at
* least two plus the length of <code>str</code>, and at most two plus
* thrice the length of <code>str</code>.
* First, two bytes are written to the output stream as if by the <code>writeShort</code> method giving the number of bytes to follow. This value is the number of bytes actually written out, not
* the length of the string. Following the length, each character of the string is output, in sequence, using the modified UTF-8 encoding for the character. If no exception is thrown, the counter
* <code>written</code> is incremented by the total number of bytes written to the output stream. This will be at least two plus the length of <code>str</code>, and at most two plus thrice the
* length of <code>str</code>.
*
* @param str a string to be written.
* @exception IOException if an I/O error occurs.
@ -326,15 +286,10 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput {
* <a href="DataInput.html#modified-utf-8">modified UTF-8</a>
* encoding in a machine-independent manner.
* <p>
* First, two bytes are written to out as if by the <code>writeShort</code>
* method giving the number of bytes to follow. This value is the number of
* bytes actually written out, not the length of the string. Following the
* length, each character of the string is output, in sequence, using the
* modified UTF-8 encoding for the character. If no exception is thrown, the
* counter <code>written</code> is incremented by the total number of bytes
* written to the output stream. This will be at least two plus the length
* of <code>str</code>, and at most two plus thrice the length of
* <code>str</code>.
* First, two bytes are written to out as if by the <code>writeShort</code> method giving the number of bytes to follow. This value is the number of bytes actually written out, not the length of
* the string. Following the length, each character of the string is output, in sequence, using the modified UTF-8 encoding for the character. If no exception is thrown, the counter
* <code>written</code> is incremented by the total number of bytes written to the output stream. This will be at least two plus the length of <code>str</code>, and at most two plus thrice the
* length of <code>str</code>.
*
* @param str a string to be written.
* @param out destination to write to
@ -404,9 +359,7 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput {
}
/**
* Returns the current value of the counter <code>written</code>, the number
* of bytes written to this data output stream so far. If the counter
* overflows, it will be wrapped to Integer.MAX_VALUE.
* Returns the current value of the counter <code>written</code>, the number of bytes written to this data output stream so far. If the counter overflows, it will be wrapped to Integer.MAX_VALUE.
*
* @return the value of the <code>written</code> field.
* @see java.io.DataOutputStream#written

View File

@ -21,9 +21,7 @@ import java.io.OutputStream;
/**
* <p>
* This class extends the {@link java.util.zip.GZIPOutputStream} by allowing the
* constructor to provide a compression level, and uses a default value of 1,
* rather than 5.
* This class extends the {@link java.util.zip.GZIPOutputStream} by allowing the constructor to provide a compression level, and uses a default value of 1, rather than 5.
* </p>
*/
public class GZIPOutputStream extends java.util.zip.GZIPOutputStream {

View File

@ -190,8 +190,7 @@ public class LeakyBucketStreamThrottler implements StreamThrottler {
}
/**
* This class is responsible for draining water from the leaky bucket. I.e.,
* it actually moves the data
* This class is responsible for draining water from the leaky bucket. I.e., it actually moves the data
*/
private class Drain implements Runnable {

View File

@ -22,8 +22,7 @@ import java.io.IOException;
import java.io.InputStream;
/**
* An InputStream that will throw EOFException if the underlying InputStream
* runs out of data before reaching the configured minimum amount of data
* An InputStream that will throw EOFException if the underlying InputStream runs out of data before reaching the configured minimum amount of data
*/
public class MinimumLengthInputStream extends FilterInputStream {

View File

@ -21,9 +21,8 @@ import java.io.IOException;
import java.io.InputStream;
/**
* Wraps and InputStream so that the underlying InputStream cannot be closed.
* This is used so that the InputStream can be wrapped with yet another
* InputStream and prevent the outer layer from closing the inner InputStream
* Wraps and InputStream so that the underlying InputStream cannot be closed. This is used so that the InputStream can be wrapped with yet another InputStream and prevent the outer layer from closing
* the inner InputStream
*/
public class NonCloseableInputStream extends FilterInputStream {

View File

@ -40,9 +40,7 @@ public class StreamUtils {
}
/**
* Copies <code>numBytes</code> from <code>source</code> to
* <code>destination</code>. If <code>numBytes</code> are not available from
* <code>source</code>, throws EOFException
* Copies <code>numBytes</code> from <code>source</code> to <code>destination</code>. If <code>numBytes</code> are not available from <code>source</code>, throws EOFException
*
* @param source the source of bytes to copy
* @param destination the destination to copy bytes to
@ -64,9 +62,7 @@ public class StreamUtils {
}
/**
* Reads data from the given input stream, copying it to the destination
* byte array. If the InputStream has less data than the given byte array,
* throws an EOFException
* Reads data from the given input stream, copying it to the destination byte array. If the InputStream has less data than the given byte array, throws an EOFException
*
* @param source the source to copy bytes from
* @param destination the destination to fill
@ -77,15 +73,12 @@ public class StreamUtils {
}
/**
* Reads data from the given input stream, copying it to the destination
* byte array. If the InputStream has less data than the given byte array,
* throws an EOFException if <code>ensureCapacity</code> is true and
* otherwise returns the number of bytes copied
* Reads data from the given input stream, copying it to the destination byte array. If the InputStream has less data than the given byte array, throws an EOFException if
* <code>ensureCapacity</code> is true and otherwise returns the number of bytes copied
*
* @param source the source to read bytes from
* @param destination the destination to fill
* @param ensureCapacity whether or not to enforce that the InputStream have
* at least as much data as the capacity of the destination byte array
* @param ensureCapacity whether or not to enforce that the InputStream have at least as much data as the capacity of the destination byte array
* @return the number of bytes actually filled
* @throws IOException if unable to read from the underlying stream
*/
@ -109,10 +102,8 @@ public class StreamUtils {
}
/**
* Copies data from in to out until either we are out of data (returns null)
* or we hit one of the byte patterns identified by the
* <code>stoppers</code> parameter (returns the byte pattern matched). The
* bytes in the stopper will be copied.
* Copies data from in to out until either we are out of data (returns null) or we hit one of the byte patterns identified by the <code>stoppers</code> parameter (returns the byte pattern
* matched). The bytes in the stopper will be copied.
*
* @param in the source to read bytes from
* @param out the destination to write bytes to
@ -151,11 +142,8 @@ public class StreamUtils {
}
/**
* Copies data from in to out until either we are out of data (returns null)
* or we hit one of the byte patterns identified by the
* <code>stoppers</code> parameter (returns the byte pattern matched). The
* byte pattern matched will NOT be copied to the output and will be un-read
* from the input.
* Copies data from in to out until either we are out of data (returns null) or we hit one of the byte patterns identified by the <code>stoppers</code> parameter (returns the byte pattern
* matched). The byte pattern matched will NOT be copied to the output and will be un-read from the input.
*
* @param in the source to read bytes from
* @param out the destination to write bytes to

View File

@ -19,9 +19,8 @@ package org.apache.nifi.stream.io;
import java.io.OutputStream;
/**
* This class extends the {@link java.util.zip.ZipOutputStream} by providing a
* constructor that allows the user to specify the compression level. The
* default compression level is 1, as opposed to Java's default of 5.
* This class extends the {@link java.util.zip.ZipOutputStream} by providing a constructor that allows the user to specify the compression level. The default compression level is 1, as opposed to
* Java's default of 5.
*/
public class ZipOutputStream extends java.util.zip.ZipOutputStream {

View File

@ -19,9 +19,7 @@ package org.apache.nifi.util;
public class EscapeUtils {
/**
* Escapes the specified html by replacing &amp;, &lt;, &gt;, &quot;, &#39;,
* &#x2f; with their corresponding html entity. If html is null, null is
* returned.
* Escapes the specified html by replacing &amp;, &lt;, &gt;, &quot;, &#39;, &#x2f; with their corresponding html entity. If html is null, null is returned.
*
* @param html to escape
* @return escaped html

View File

@ -17,10 +17,8 @@
package org.apache.nifi.util;
/**
* Wraps a Long value so that it can be declared <code>final</code> and still be
* accessed from which inner classes; the functionality is similar to that of an
* AtomicLong, but operations on this class are not atomic. This results in
* greater performance when the atomicity is not needed.
* Wraps a Long value so that it can be declared <code>final</code> and still be accessed from which inner classes; the functionality is similar to that of an AtomicLong, but operations on this class
* are not atomic. This results in greater performance when the atomicity is not needed.
*/
public class LongHolder extends ObjectHolder<Long> {

View File

@ -24,9 +24,8 @@ import java.util.Arrays;
* </p>
*
* <p>
* This class implements an efficient naive search algorithm, which allows the
* user of the library to identify byte sequences in a stream on-the-fly so that
* the stream can be segmented without having to buffer the data.
* This class implements an efficient naive search algorithm, which allows the user of the library to identify byte sequences in a stream on-the-fly so that the stream can be segmented without having
* to buffer the data.
* </p>
*
* <p>
@ -60,10 +59,8 @@ public class NaiveSearchRingBuffer {
}
/**
* @return the contents of the internal buffer, which represents the last X
* bytes added to the buffer, where X is the minimum of the number of bytes
* added to the buffer or the length of the byte sequence for which we are
* looking
* @return the contents of the internal buffer, which represents the last X bytes added to the buffer, where X is the minimum of the number of bytes added to the buffer or the length of the byte
* sequence for which we are looking
*/
public byte[] getBufferContents() {
final int contentLength = Math.min(lookingFor.length, bufferSize);
@ -83,9 +80,7 @@ public class NaiveSearchRingBuffer {
}
/**
* @return <code>true</code> if the number of bytes that have been added to
* the buffer is at least equal to the length of the byte sequence for which
* we are searching
* @return <code>true</code> if the number of bytes that have been added to the buffer is at least equal to the length of the byte sequence for which we are searching
*/
public boolean isFilled() {
return bufferSize >= buffer.length;
@ -101,12 +96,10 @@ public class NaiveSearchRingBuffer {
}
/**
* Add the given byte to the buffer and notify whether or not the byte
* completes the desired byte sequence.
* Add the given byte to the buffer and notify whether or not the byte completes the desired byte sequence.
*
* @param data the data to add to the buffer
* @return <code>true</code> if this byte completes the byte sequence,
* <code>false</code> otherwise.
* @return <code>true</code> if this byte completes the byte sequence, <code>false</code> otherwise.
*/
public boolean addAndCompare(final byte data) {
buffer[insertionPointer] = data;

View File

@ -42,8 +42,7 @@ public class RingBuffer<T> {
}
/**
* Adds the given value to the RingBuffer and returns the value that was
* removed in order to make room.
* Adds the given value to the RingBuffer and returns the value that was removed in order to make room.
*
* @param value the new value to add
* @return value previously in the buffer
@ -202,11 +201,8 @@ public class RingBuffer<T> {
}
/**
* Iterates over each element in the RingBuffer, calling the
* {@link ForEachEvaluator#evaluate(Object) evaluate} method on each element
* in the RingBuffer. If the Evaluator returns {@code false}, the method
* will skip all remaining elements in the RingBuffer; otherwise, the next
* element will be evaluated until all elements have been evaluated.
* Iterates over each element in the RingBuffer, calling the {@link ForEachEvaluator#evaluate(Object) evaluate} method on each element in the RingBuffer. If the Evaluator returns {@code false},
* the method will skip all remaining elements in the RingBuffer; otherwise, the next element will be evaluated until all elements have been evaluated.
*
* @param evaluator used to evaluate each item in the ring buffer
*/
@ -215,15 +211,11 @@ public class RingBuffer<T> {
}
/**
* Iterates over each element in the RingBuffer, calling the
* {@link ForEachEvaluator#evaluate(Object) evaluate} method on each element
* in the RingBuffer. If the Evaluator returns {@code false}, the method
* will skip all remaining elements in the RingBuffer; otherwise, the next
* element will be evaluated until all elements have been evaluated.
* Iterates over each element in the RingBuffer, calling the {@link ForEachEvaluator#evaluate(Object) evaluate} method on each element in the RingBuffer. If the Evaluator returns {@code false},
* the method will skip all remaining elements in the RingBuffer; otherwise, the next element will be evaluated until all elements have been evaluated.
*
* @param evaluator the evaluator
* @param iterationDirection the order in which to iterate over the elements
* in the RingBuffer
* @param iterationDirection the order in which to iterate over the elements in the RingBuffer
*/
public void forEach(final ForEachEvaluator<T> evaluator, final IterationDirection iterationDirection) {
readLock.lock();
@ -266,16 +258,14 @@ public class RingBuffer<T> {
}
/**
* Defines an interface that can be used to iterate over all of the elements
* in the RingBuffer via the {@link #forEach} method
* Defines an interface that can be used to iterate over all of the elements in the RingBuffer via the {@link #forEach} method
*
* @param <S> the type to evaluate
*/
public static interface ForEachEvaluator<S> {
/**
* Evaluates the given element and returns {@code true} if the next
* element should be evaluated, {@code false} otherwise
* Evaluates the given element and returns {@code true} if the next element should be evaluated, {@code false} otherwise
*
* @param value the value to evaluate
* @return true if should continue evaluating; false otherwise

View File

@ -58,8 +58,7 @@ public final class StopWatch {
* @param timeUnit the unit for which the duration should be reported
* @return the duration of the stopwatch in the specified unit
*
* @throws IllegalStateException if the StopWatch has not been stopped via
* {@link #stop()}
* @throws IllegalStateException if the StopWatch has not been stopped via {@link #stop()}
*/
public long getDuration(final TimeUnit timeUnit) {
if (duration < 0) {

View File

@ -39,8 +39,7 @@ import java.util.Random;
import org.slf4j.Logger;
/**
* A utility class containing a few useful static methods to do typical IO
* operations.
* A utility class containing a few useful static methods to do typical IO operations.
*
* @author unattributed
*/
@ -94,12 +93,10 @@ public class FileUtils {
}
/**
* Deletes the given file. If the given file exists but could not be deleted
* this will be printed as a warning to the given logger
* Deletes the given file. If the given file exists but could not be deleted this will be printed as a warning to the given logger
*
* @param file the file to delete
* @param logger the logger to provide logging information to about the
* operation
* @param logger the logger to provide logging information to about the operation
* @return true if given file no longer exists
*/
public static boolean deleteFile(final File file, final Logger logger) {
@ -107,13 +104,11 @@ public class FileUtils {
}
/**
* Deletes the given file. If the given file exists but could not be deleted
* this will be printed as a warning to the given logger
* Deletes the given file. If the given file exists but could not be deleted this will be printed as a warning to the given logger
*
* @param file the file to delete
* @param logger the logger to write to
* @param attempts indicates how many times an attempt to delete should be
* made
* @param attempts indicates how many times an attempt to delete should be made
* @return true if given file no longer exists
*/
public static boolean deleteFile(final File file, final Logger logger, final int attempts) {
@ -143,8 +138,7 @@ public class FileUtils {
}
/**
* Deletes all of the given files. If any exist and cannot be deleted that
* will be printed at warn to the given logger.
* Deletes all of the given files. If any exist and cannot be deleted that will be printed at warn to the given logger.
*
* @param files can be null
* @param logger can be null
@ -154,13 +148,11 @@ public class FileUtils {
}
/**
* Deletes all of the given files. If any exist and cannot be deleted that
* will be printed at warn to the given logger.
* Deletes all of the given files. If any exist and cannot be deleted that will be printed at warn to the given logger.
*
* @param files can be null
* @param logger can be null
* @param attempts indicates how many times an attempt should be made to
* delete each file
* @param attempts indicates how many times an attempt should be made to delete each file
*/
public static void deleteFile(final List<File> files, final Logger logger, final int attempts) {
if (null == files || files.isEmpty()) {
@ -188,9 +180,8 @@ public class FileUtils {
}
/**
* Deletes all files (not directories..) in the given directory (non
* recursive) that match the given filename filter. If any file cannot be
* deleted then this is printed at warn to the given logger.
* Deletes all files (not directories..) in the given directory (non recursive) that match the given filename filter. If any file cannot be deleted then this is printed at warn to the given
* logger.
*
* @param directory the directory to scan for files to delete
* @param filter if null then no filter is used
@ -201,9 +192,7 @@ public class FileUtils {
}
/**
* Deletes all files (not directories) in the given directory (recursive)
* that match the given filename filter. If any file cannot be deleted then
* this is printed at warn to the given logger.
* Deletes all files (not directories) in the given directory (recursive) that match the given filename filter. If any file cannot be deleted then this is printed at warn to the given logger.
*
* @param directory the directory to scan
* @param filter if null then no filter is used
@ -215,16 +204,13 @@ public class FileUtils {
}
/**
* Deletes all files (not directories) in the given directory (recursive)
* that match the given filename filter. If any file cannot be deleted then
* this is printed at warn to the given logger.
* Deletes all files (not directories) in the given directory (recursive) that match the given filename filter. If any file cannot be deleted then this is printed at warn to the given logger.
*
* @param directory the directory to scan
* @param filter if null then no filter is used
* @param logger the logger
* @param recurse whether to recurse subdirectories or not
* @param deleteEmptyDirectories default is false; if true will delete
* directories found that are empty
* @param deleteEmptyDirectories default is false; if true will delete directories found that are empty
*/
public static void deleteFilesInDir(final File directory, final FilenameFilter filter, final Logger logger, final boolean recurse, final boolean deleteEmptyDirectories) {
// ensure the specified directory is actually a directory and that it exists
@ -269,11 +255,9 @@ public class FileUtils {
}
/**
* Randomly generates a sequence of bytes and overwrites the contents of the
* file a number of times. The file is then deleted.
* Randomly generates a sequence of bytes and overwrites the contents of the file a number of times. The file is then deleted.
*
* @param file File to be overwritten a number of times and, ultimately,
* deleted
* @param file File to be overwritten a number of times and, ultimately, deleted
* @param passes Number of times file should be overwritten
* @throws IOException if something makes shredding or deleting a problem
*/
@ -349,29 +333,19 @@ public class FileUtils {
}
/**
* Copies the given source file to the given destination file. The given
* destination will be overwritten if it already exists.
* Copies the given source file to the given destination file. The given destination will be overwritten if it already exists.
*
* @param source the file to copy
* @param destination the file to copy to
* @param lockInputFile if true will lock input file during copy; if false
* will not
* @param lockOutputFile if true will lock output file during copy; if false
* will not
* @param move if true will perform what is effectively a move operation
* rather than a pure copy. This allows for potentially highly efficient
* movement of the file but if not possible this will revert to a copy then
* delete behavior. If false, then the file is copied and the source file is
* retained. If a true rename/move occurs then no lock is held during that
* time.
* @param logger if failures occur, they will be logged to this logger if
* possible. If this logger is null, an IOException will instead be thrown,
* indicating the problem.
* @param lockInputFile if true will lock input file during copy; if false will not
* @param lockOutputFile if true will lock output file during copy; if false will not
* @param move if true will perform what is effectively a move operation rather than a pure copy. This allows for potentially highly efficient movement of the file but if not possible this will
* revert to a copy then delete behavior. If false, then the file is copied and the source file is retained. If a true rename/move occurs then no lock is held during that time.
* @param logger if failures occur, they will be logged to this logger if possible. If this logger is null, an IOException will instead be thrown, indicating the problem.
* @return long number of bytes copied
* @throws FileNotFoundException if the source file could not be found
* @throws IOException if unable to read or write the underlying streams
* @throws SecurityException if a security manager denies the needed file
* operations
* @throws SecurityException if a security manager denies the needed file operations
*/
public static long copyFile(final File source, final File destination, final boolean lockInputFile, final boolean lockOutputFile, final boolean move, final Logger logger)
throws FileNotFoundException, IOException {
@ -434,21 +408,17 @@ public class FileUtils {
}
/**
* Copies the given source file to the given destination file. The given
* destination will be overwritten if it already exists.
* Copies the given source file to the given destination file. The given destination will be overwritten if it already exists.
*
* @param source the file to copy from
* @param destination the file to copy to
* @param lockInputFile if true will lock input file during copy; if false
* will not
* @param lockOutputFile if true will lock output file during copy; if false
* will not
* @param lockInputFile if true will lock input file during copy; if false will not
* @param lockOutputFile if true will lock output file during copy; if false will not
* @param logger the logger to use
* @return long number of bytes copied
* @throws FileNotFoundException if the source file could not be found
* @throws IOException if unable to read or write to file
* @throws SecurityException if a security manager denies the needed file
* operations
* @throws SecurityException if a security manager denies the needed file operations
*/
public static long copyFile(final File source, final File destination, final boolean lockInputFile, final boolean lockOutputFile, final Logger logger) throws FileNotFoundException, IOException {
return FileUtils.copyFile(source, destination, lockInputFile, lockOutputFile, false, logger);
@ -497,10 +467,8 @@ public class FileUtils {
}
/**
* Renames the given file from the source path to the destination path. This
* handles multiple attempts. This should only be used to rename within a
* given directory. Renaming across directories might not work well. See the
* <code>File.renameTo</code> for more information.
* Renames the given file from the source path to the destination path. This handles multiple attempts. This should only be used to rename within a given directory. Renaming across directories
* might not work well. See the <code>File.renameTo</code> for more information.
*
* @param source the file to rename
* @param destination the file path to rename to
@ -512,19 +480,14 @@ public class FileUtils {
}
/**
* Renames the given file from the source path to the destination path. This
* handles multiple attempts. This should only be used to rename within a
* given directory. Renaming across directories might not work well. See the
* <code>File.renameTo</code> for more information.
* Renames the given file from the source path to the destination path. This handles multiple attempts. This should only be used to rename within a given directory. Renaming across directories
* might not work well. See the <code>File.renameTo</code> for more information.
*
* @param source the file to rename
* @param destination the file path to rename to
* @param maxAttempts the max number of attempts to attempt the rename
* @param replace if true and a rename attempt fails will check if a file is
* already at the destination path. If so it will delete that file and
* attempt the rename according the remaining maxAttempts. If false, any
* conflicting files will be left as they were and the rename attempts will
* fail if conflicting.
* @param replace if true and a rename attempt fails will check if a file is already at the destination path. If so it will delete that file and attempt the rename according the remaining
* maxAttempts. If false, any conflicting files will be left as they were and the rename attempts will fail if conflicting.
* @throws IOException if rename isn't successful
*/
public static void renameFile(final File source, final File destination, final int maxAttempts, final boolean replace) throws IOException {
@ -553,20 +516,15 @@ public class FileUtils {
}
/**
* Syncs a primary copy of a file with the copy in the restore directory. If
* the restore directory does not have a file and the primary has a file,
* the the primary's file is copied to the restore directory. Else if the
* restore directory has a file, but the primary does not, then the
* restore's file is copied to the primary directory. Else if the primary
* file is different than the restore file, then an IllegalStateException is
* thrown. Otherwise, if neither file exists, then no syncing is performed.
* Syncs a primary copy of a file with the copy in the restore directory. If the restore directory does not have a file and the primary has a file, the the primary's file is copied to the restore
* directory. Else if the restore directory has a file, but the primary does not, then the restore's file is copied to the primary directory. Else if the primary file is different than the restore
* file, then an IllegalStateException is thrown. Otherwise, if neither file exists, then no syncing is performed.
*
* @param primaryFile the primary file
* @param restoreFile the restore file
* @param logger a logger
* @throws IOException if an I/O problem was encountered during syncing
* @throws IllegalStateException if the primary and restore copies exist but
* are different
* @throws IllegalStateException if the primary and restore copies exist but are different
*/
public static void syncWithRestore(final File primaryFile, final File restoreFile, final Logger logger)
throws IOException {

View File

@ -22,11 +22,8 @@ import java.util.ArrayList;
import java.util.List;
/**
* An {@link UpdateMonitor} that combines multiple <code>UpdateMonitor</code>s
* such that it will indicate a change in a file only if ALL sub-monitors
* indicate a change. The sub-monitors will be applied in the order given and if
* any indicates that the state has not changed, the subsequent sub-monitors may
* not be given a chance to run
* An {@link UpdateMonitor} that combines multiple <code>UpdateMonitor</code>s such that it will indicate a change in a file only if ALL sub-monitors indicate a change. The sub-monitors will be
* applied in the order given and if any indicates that the state has not changed, the subsequent sub-monitors may not be given a chance to run
*/
public class CompoundUpdateMonitor implements UpdateMonitor {

View File

@ -23,8 +23,7 @@ import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
/**
* Allows the user to configure a {@link java.nio.file.Path Path} to watch for
* modifications and periodically poll to check if the file has been modified
* Allows the user to configure a {@link java.nio.file.Path Path} to watch for modifications and periodically poll to check if the file has been modified
*/
public class SynchronousFileWatcher {
@ -58,8 +57,7 @@ public class SynchronousFileWatcher {
}
/**
* Checks if the file has been updated according to the configured
* {@link UpdateMonitor} and resets the state
* Checks if the file has been updated according to the configured {@link UpdateMonitor} and resets the state
*
* @return true if updated; false otherwise
* @throws IOException if failure occurs checking for changes

View File

@ -23,32 +23,26 @@ import java.util.Set;
import org.apache.nifi.util.search.ahocorasick.SearchState;
/**
* Defines an interface to search for content given a set of search terms. Any
* implementation of search must be thread safe.
* Defines an interface to search for content given a set of search terms. Any implementation of search must be thread safe.
*
*/
public interface Search<T> {
/**
* Establishes the dictionary of terms which will be searched in subsequent
* search calls. This can be called only once
* Establishes the dictionary of terms which will be searched in subsequent search calls. This can be called only once
*
* @param terms the terms to create a dictionary of
*/
void initializeDictionary(Set<SearchTerm<T>> terms);
/**
* Searches the given input stream for matches between the already specified
* dictionary and the contents scanned.
* Searches the given input stream for matches between the already specified dictionary and the contents scanned.
*
* @param haystack the source data to scan for hits
* @param findAll if true will find all matches if false will find only the
* first match
* @return SearchState containing results Map might be empty which indicates
* no matches found but will not be null
* @param findAll if true will find all matches if false will find only the first match
* @return SearchState containing results Map might be empty which indicates no matches found but will not be null
* @throws IOException Thrown for any exceptions occurring while searching.
* @throws IllegalStateException if the dictionary has not yet been
* initialized
* @throws IllegalStateException if the dictionary has not yet been initialized
*/
SearchState<T> search(InputStream haystack, boolean findAll) throws IOException;

View File

@ -40,9 +40,8 @@ public class SearchTerm<T> {
}
/**
* Constructs a search term. Optionally performs a defensive copy of the
* given byte array. If the caller indicates a defensive copy is not
* necessary then they must not change the given arrays state any longer
* Constructs a search term. Optionally performs a defensive copy of the given byte array. If the caller indicates a defensive copy is not necessary then they must not change the given arrays
* state any longer
*
* @param bytes the bytes of the new search term
* @param defensiveCopy if true will make a defensive copy; false otherwise