org.apache.axiom.util.base64

## Class AbstractBase64EncodingOutputStream

- java.lang.Object
- - java.io.OutputStream
  - - org.apache.axiom.util.base64.AbstractBase64EncodingOutputStream

- All Implemented Interfaces:
    Closeable, Flushable, AutoCloseable
  Direct Known Subclasses:
    Base64EncodingOutputStream, Base64EncodingStringBufferOutputStream, Base64EncodingWriterOutputStream

      public abstract class AbstractBase64EncodingOutputStream
      extends OutputStream

  Base class for `OutputStream` implementations that encode data in base64.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractBase64EncodingOutputStream()` Default constructor.
    `AbstractBase64EncodingOutputStream(boolean ignoreFlush)` Constructor.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()`
    `void` | `complete()` Write out any pending data, including padding if necessary.
    `protected abstract void` | `doClose()` Close the underlying stream, if applicable.
    `protected abstract void` | `doFlush()` Flush the underlying stream, if applicable.
    `protected abstract void` | `doWrite(byte[] b)` Write base64 encoded data.
    `void` | `flush()`
    `protected abstract void` | `flushBuffer()` Write any pending data to the underlying stream, if applicable.
    `void` | `write(byte[] b, int off, int len)`
    `void` | `write(int b)`

    - ### Methods inherited from class java.io.OutputStream

      `write`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### AbstractBase64EncodingOutputStream

          public AbstractBase64EncodingOutputStream(boolean ignoreFlush)

      Constructor.
      Parameters:
        `ignoreFlush` - Specifies if calls to `flush()` should be ignored. Setting this to `true` is particular useful in conjunction with `DataHandler.writeTo(OutputStream)`: that method may call `flush()` after writing the data, but the call to `DataHandler.writeTo(OutputStream)` must be followed by a call to `close()` or `complete()` which would then output a single chunk with a few bytes. In some cases this may be inconvenient.

    - #### AbstractBase64EncodingOutputStream

          public AbstractBase64EncodingOutputStream()

      Default constructor. This constructor does the same as `AbstractBase64EncodingOutputStream(boolean)` with `ignoreFlush` set to `false`.

  - ### Method Detail

    - #### write

          public final void write(byte[] b,
                                  int off,
                                  int len)
                           throws IOException

      Overrides:
        `write` in class `OutputStream`
      Throws:
        `IOException`

    - #### write

          public final void write(int b)
                           throws IOException

      Specified by:
        `write` in class `OutputStream`
      Throws:
        `IOException`

    - #### complete

          public final void complete()
                              throws IOException

      Write out any pending data, including padding if necessary.
      Throws:
        `IOException` - if an I/O error occurs

    - #### flush

          public final void flush()
                           throws IOException

      Specified by:
        `flush` in interface `Flushable`
      Overrides:
        `flush` in class `OutputStream`
      Throws:
        `IOException`

    - #### close

          public final void close()
                           throws IOException

      Specified by:
        `close` in interface `Closeable`
      Specified by:
        `close` in interface `AutoCloseable`
      Overrides:
        `close` in class `OutputStream`
      Throws:
        `IOException`

    - #### doWrite

          protected abstract void doWrite(byte[] b)
                                   throws IOException

      Write base64 encoded data. If necessary, the implementation should accumulate the data in a buffer before writing it to the underlying stream.
      Parameters:
        `b` - a byte array of length 4
      Throws:
        `IOException` - if an I/O error occurs

    - #### flushBuffer

          protected abstract void flushBuffer()
                                       throws IOException

      Write any pending data to the underlying stream, if applicable. Note that implementations should not flush the underlying stream.
      Throws:
        `IOException` - if an I/O error occurs

    - #### doFlush

          protected abstract void doFlush()
                                   throws IOException

      Flush the underlying stream, if applicable.
      Throws:
        `IOException` - if an I/O error occurs

    - #### doClose

          protected abstract void doClose()
                                   throws IOException

      Close the underlying stream, if applicable.
      Throws:
        `IOException` - if an I/O error occurs

Copyright © The Apache Software Foundation. All Rights Reserved.