Class ByteFilteringOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
org.apache.nifi.processors.hadoop.util.ByteFilteringOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
This class allows the user to define byte-array filters or single-byte filters that will modify the content that is written to the underlying stream. Each filter can be given a maximum number of
replacements that it should perform.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final List<ByteFilteringOutputStream.Filter> private final List<ByteFilteringOutputStream.Filter> private final OutputStreamFields inherited from class java.io.FilterOutputStream
out -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFilter(byte[] toReplace, byte[] replaceWith) Causes this stream to write replaceWith in place of toReplace ifwrite(byte[], int, int)is called where the value to write is equal to toReplace.voidaddFilter(byte[] toReplace, byte[] replaceWith, int maxReplacements) Causes this stream to write replaceWith in place of toReplace ifwrite(byte[], int, int)is called where the value to write is equal to toReplace.voidaddFilter(byte toReplace, byte replaceWith) Causes this stream to write replaceWith in place of toReplace ifwrite(int)is called where the value to write is equal to toReplace.voidaddFilter(byte toReplace, byte replaceWith, int maxReplacements) Causes this stream to write replaceWith in place of toReplace ifwrite(int)is called where the value to write is equal to toReplace.voidwrite(byte[] buffer, int offset, int length) voidwrite(int data) Methods inherited from class java.io.FilterOutputStream
close, flush, writeMethods inherited from class java.io.OutputStream
nullOutputStream
-
Field Details
-
multiByteFilters
-
singleByteFilters
-
wrapped
-
-
Constructor Details
-
ByteFilteringOutputStream
- Throws:
IOException
-
-
Method Details
-
write
- Overrides:
writein classFilterOutputStream- Throws:
IOException
-
write
- Overrides:
writein classFilterOutputStream- Throws:
IOException
-
addFilter
public void addFilter(byte[] toReplace, byte[] replaceWith) Causes this stream to write replaceWith in place of toReplace ifwrite(byte[], int, int)is called where the value to write is equal to toReplace.- Parameters:
toReplace- the byte array to replacereplaceWith- the byte array to be substituted
-
addFilter
public void addFilter(byte[] toReplace, byte[] replaceWith, int maxReplacements) Causes this stream to write replaceWith in place of toReplace ifwrite(byte[], int, int)is called where the value to write is equal to toReplace.- Parameters:
toReplace- the byte array to replacereplaceWith- the byte array to be substitutedmaxReplacements- the maximum number of replacements that should be made
-
addFilter
public void addFilter(byte toReplace, byte replaceWith) Causes this stream to write replaceWith in place of toReplace ifwrite(int)is called where the value to write is equal to toReplace.- Parameters:
toReplace- the byte to replacereplaceWith- the byte to be substituted
-
addFilter
public void addFilter(byte toReplace, byte replaceWith, int maxReplacements) Causes this stream to write replaceWith in place of toReplace ifwrite(int)is called where the value to write is equal to toReplace.- Parameters:
toReplace- the byte to replacereplaceWith- the byte to be substitutedmaxReplacements- the maximum number of replacements that should be made
-