Class BaseDecoderOutputStream

java.lang.Object
java.io.OutputStream
org.refcodes.codec.BaseDecoderOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public class BaseDecoderOutputStream extends OutputStream
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 Details

    • BaseDecoderOutputStream

      public BaseDecoderOutputStream(OutputStream aOutputStream, BaseMetrics aBaseMetrics) throws IOException
      Constructs a BaseDecoderOutputStream using 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 a BaseDecoderOutputStream using 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

      public BaseDecoderOutputStream(File aOutputFile, BaseMetrics aBaseMetrics) throws IOException
      Constructs a BaseDecoderOutputStream using 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 a BaseDecoderOutputStream using 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