AbstractServletOutputStream (Apache Tomcat 7.0.108 API Documentation)

org.apache.coyote.http11.upgrade

## Class AbstractServletOutputStream

- java.lang.Object
- - java.io.OutputStream
  - - javax.servlet.ServletOutputStream
    - - org.apache.coyote.http11.upgrade.AbstractServletOutputStream

- All Implemented Interfaces:
    Closeable, Flushable, AutoCloseable
  Direct Known Subclasses:
    AprServletOutputStream, BioServletOutputStream, NioServletOutputStream

      public abstract class AbstractServletOutputStream
      extends ServletOutputStream

  Implements the new Servlet 3.1 methods for `ServletOutputStream`.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static StringManager` | `sm`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractServletOutputStream(int asyncWriteBufferSize)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()`
    `protected abstract void` | `doClose()`
    `protected abstract void` | `doFlush()`
    `protected abstract int` | `doWrite(boolean block, byte[] b, int off, int len)` Abstract method to be overridden by concrete implementations.
    `protected boolean` | `isCloseRequired()`
    `boolean` | `isReady()` New Servlet 3.1 method.
    `protected void` | `onError(Throwable t)`
    `protected void` | `onWritePossible()`
    `void` | `setWriteListener(WriteListener listener)` New Servlet 3.1 method.
    `void` | `write(byte[] b, int off, int len)`
    `void` | `write(int b)`

    - ### Methods inherited from class javax.servlet.ServletOutputStream

      `print, print, print, print, print, print, print, println, println, println, println, println, println, println, println`

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

      `flush, write`

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

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

- - ### Field Detail

    - #### sm

          protected static final StringManager sm

  - ### Constructor Detail

    - #### AbstractServletOutputStream

          public AbstractServletOutputStream(int asyncWriteBufferSize)

  - ### Method Detail

    - #### isReady

          public final boolean isReady()

      New Servlet 3.1 method.

    - #### setWriteListener

          public final void setWriteListener(WriteListener listener)

      New Servlet 3.1 method.

    - #### isCloseRequired

          protected final boolean isCloseRequired()

    - #### write

          public void write(int b)
                     throws IOException

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

    - #### write

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

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

    - #### close

          public void close()
                     throws IOException

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

    - #### onWritePossible

          protected final void onWritePossible()
                                        throws IOException

      Throws:
        `IOException`

    - #### onError

          protected final void onError(Throwable t)

    - #### doWrite

          protected abstract int doWrite(boolean block,
                    byte[] b,
                    int off,
                    int len)
                                  throws IOException

      Abstract method to be overridden by concrete implementations. The base class will ensure that there are no concurrent calls to this method for the same socket by ensuring that the writeLock is held when making any calls to this method.
      Throws:
        `IOException`

    - #### doFlush

          protected abstract void doFlush()
                                   throws IOException

      Throws:
        `IOException`

    - #### doClose

          protected abstract void doClose()
                                   throws IOException

      Throws:
        `IOException`

Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.