Class BaseDecoderOutputStream
java.lang.Object
java.io.OutputStream
org.refcodes.codec.BaseDecoderOutputStream
- All Implemented Interfaces:
Closeable, Flushable, AutoCloseable
The
BaseDecoderOutputStream decodes encoded data written to this
stream and forwards the decoded bytes to an underlying OutputStream.
Encoded bytes are collected until a complete encoded block, as defined by
BaseMetrics.getDigitsPerInt(), is available. The block is then
decoded using a BaseDecoder, and the resulting raw bytes are written
to the configured output stream.
The stream may optionally ignore whitespace characters which are not part of the configured base alphabet. This is useful for encoded representations containing line breaks or formatting whitespace.
Make sure to call close() when done. Closing validates that no
incomplete encoded block remains and closes the underlying output stream.
-
Constructor Summary
ConstructorsConstructorDescriptionBaseDecoderOutputStream(File aOutputFile, BaseMetrics aBaseMetrics) Constructs aBaseDecoderOutputStreamusing the given output file and base metrics.BaseDecoderOutputStream(File aOutputFile, BaseMetrics aBaseMetrics, boolean isFilterWhiteSpaces) Constructs aBaseDecoderOutputStreamusing the given output file, base metrics and whitespace-filtering configuration.BaseDecoderOutputStream(OutputStream aOutputStream, BaseMetrics aBaseMetrics) Constructs aBaseDecoderOutputStreamusing the given output stream and base metrics.BaseDecoderOutputStream(OutputStream aOutputStream, BaseMetrics aBaseMetrics, boolean isFilterWhiteSpaces) Constructs aBaseDecoderOutputStreamusing the given output stream, base metrics and whitespace-filtering configuration. -
Method Summary
Methods inherited from class OutputStream
nullOutputStream, write
-
Constructor Details
-
BaseDecoderOutputStream
public BaseDecoderOutputStream(OutputStream aOutputStream, BaseMetrics aBaseMetrics) throws IOException Constructs aBaseDecoderOutputStreamusing the given output stream and base metrics.- Parameters:
aOutputStream- The output stream receiving the decoded data.aBaseMetrics- The base metrics used to decode the encoded data.- Throws:
IOException- Thrown in case initializing the stream caused an I/O-related problem.
-
BaseDecoderOutputStream
public BaseDecoderOutputStream(OutputStream aOutputStream, BaseMetrics aBaseMetrics, boolean isFilterWhiteSpaces) throws IOException Constructs aBaseDecoderOutputStreamusing the given output stream, base metrics and whitespace-filtering configuration.- Parameters:
aOutputStream- The output stream receiving the decoded data.aBaseMetrics- The base metrics used to decode the encoded data.isFilterWhiteSpaces- Determines whether whitespace characters not contained in the base alphabet are ignored.- Throws:
IOException- Thrown in case initializing the stream caused an I/O-related problem.
-
BaseDecoderOutputStream
Constructs aBaseDecoderOutputStreamusing the given output file and base metrics.- Parameters:
aOutputFile- The output file receiving the decoded data.aBaseMetrics- The base metrics used to decode the encoded data.- Throws:
IOException- Thrown in case opening the output file caused an I/O-related problem.
-
BaseDecoderOutputStream
public BaseDecoderOutputStream(File aOutputFile, BaseMetrics aBaseMetrics, boolean isFilterWhiteSpaces) throws IOException Constructs aBaseDecoderOutputStreamusing the given output file, base metrics and whitespace-filtering configuration.- Parameters:
aOutputFile- The output file receiving the decoded data.aBaseMetrics- The base metrics used to decode the encoded data.isFilterWhiteSpaces- Determines whether whitespace characters not contained in the base alphabet are ignored.- Throws:
IOException- Thrown in case opening the output file caused an I/O-related problem.
-
-
Method Details
-
write
- Specified by:
writein classOutputStream- Throws:
IOException
-
write
- Overrides:
writein classOutputStream- Throws:
IOException
-
flush
- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
-
close
Closing fails if an incomplete encoded block remains. Properly padded encodings such as Base64 always finish on a complete encoded block.
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException
-
isClosed
public boolean isClosed()Determines whether this stream has been closed.- Returns:
trueif this stream has been closed.
-