CachedOutputStream (Apache CXF JavaDoc 4.1.0-SNAPSHOT API)
Description: declaration: package: org.apache.cxf.io, class: CachedOutputStream

Package org.apache.cxf.io

# Class CachedOutputStream

java.lang.Object
java.io.OutputStream
org.apache.cxf.io.CachedOutputStream

All Implemented Interfaces:
  `Closeable`, `Flushable`, `AutoCloseable`

Direct Known Subclasses:
  `CacheAndWriteOutputStream`, `WriteOnCloseOutputStream`

public class CachedOutputStream extends OutputStream

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected OutputStream`
  `currentStream`
  `protected boolean`
  `outputLocked`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `CachedOutputStream()`
  `CachedOutputStream(long threshold)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `close()`
  `static void`
  `copyStream(InputStream in, OutputStream out, int bufferSize)`
  `void`
  `deregisterCallback(CachedOutputStreamCallback cb)`
  `protected void`
  `doClose()`
  Perform any actions required on stream closure (handle response etc.)
  `protected void`
  `doFlush()`
  Perform any actions required on stream flush (freeze headers, reset output stream ... etc.)
  `boolean`
  `equals(Object obj)`
  `void`
  `flush()`
  `byte[]`
  `getBytes()`
  `List<CachedOutputStreamCallback>`
  `getCallbacks()`
  `InputStream`
  `getInputStream()`
  `OutputStream`
  `getOut()`
  `File`
  `getTempFile()`
  `long`
  `getThreshold()`
  `int`
  `hashCode()`
  `void`
  `holdTempFile()`
  `static boolean`
  `isThresholdSysPropSet()`
  Returns true if the default threshold is explicitly set via CachedConstants.THRESHOLD_SYS_PROP
  `void`
  `lockOutputStream()`
  Locks the output stream to prevent additional writes, but maintains a pointer to it so an InputStream can be obtained
  `protected void`
  `onWrite()`
  `protected void`
  `postClose()`
  Perform any actions required after stream closure (close the other related stream etc.)
  `void`
  `registerCallback(CachedOutputStreamCallback cb)`
  `void`
  `releaseTempFileHold()`
  `void`
  `resetOut(OutputStream out, boolean copyOldContent)`
  Replace the original stream with the new one, optionally copying the content of the old one into the new one.
  `void`
  `setCipherTransformation(String cipherTransformation)`
  `static void`
  `setDefaultCipherTransformation(String n)`
  `static void`
  `setDefaultMaxSize(long l)`
  `static void`
  `setDefaultThreshold(int i)`
  `void`
  `setMaxSize(long maxSize)`
  `void`
  `setOutputDir(File outputDir)`
  `void`
  `setThreshold(long threshold)`
  `long`
  `size()`
  `String`
  `toString()`
  `void`
  `write(byte[] b)`
  `void`
  `write(byte[] b, int off, int len)`
  `void`
  `write(int b)`
  `void`
  `writeCacheTo(OutputStream out)`
  `void`
  `writeCacheTo(StringBuilder out)`
  `void`
  `writeCacheTo(StringBuilder out, long limit)`
  `void`
  `writeCacheTo(StringBuilder out, String charsetName)`
  `void`
  `writeCacheTo(StringBuilder out, String charsetName, long limit)`

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

  `nullOutputStream`

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

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### outputLocked

    protected boolean outputLocked

  - ### currentStream

    protected OutputStream currentStream

- ## Constructor Details

  - ### CachedOutputStream

    public CachedOutputStream()

  - ### CachedOutputStream

    public CachedOutputStream(long threshold)

- ## Method Details

  - ### holdTempFile

    public void holdTempFile()

  - ### releaseTempFileHold

    public void releaseTempFileHold()

  - ### registerCallback

    public void registerCallback(CachedOutputStreamCallback cb)

  - ### deregisterCallback

    public void deregisterCallback(CachedOutputStreamCallback cb)

  - ### getCallbacks

    public List<CachedOutputStreamCallback> getCallbacks()

  - ### doFlush

    protected void doFlush() throws IOException
    Perform any actions required on stream flush (freeze headers, reset output stream ... etc.)
    Throws:
      `IOException`

  - ### flush

    public void flush() throws IOException
    Specified by:
      `flush` in interface `Flushable`
    Overrides:
      `flush` in class `OutputStream`
    Throws:
      `IOException`

  - ### doClose

    protected void doClose() throws IOException
    Perform any actions required on stream closure (handle response etc.)
    Throws:
      `IOException`

  - ### postClose

    protected void postClose() throws IOException
    Perform any actions required after stream closure (close the other related stream etc.)
    Throws:
      `IOException`

  - ### lockOutputStream

    public void lockOutputStream() throws IOException
    Locks the output stream to prevent additional writes, but maintains a pointer to it so an InputStream can be obtained
    Throws:
      `IOException`

  - ### close

    public void close() throws IOException
    Specified by:
      `close` in interface `AutoCloseable`
    Specified by:
      `close` in interface `Closeable`
    Overrides:
      `close` in class `OutputStream`
    Throws:
      `IOException`

  - ### equals

    public boolean equals(Object obj)
    Overrides:
      `equals` in class `Object`

  - ### resetOut

    public void resetOut(OutputStream out, boolean copyOldContent) throws IOException
    Replace the original stream with the new one, optionally copying the content of the old one into the new one. When with Attachment, needs to replace the xml writer stream with the stream used by AttachmentSerializer or copy the cached output stream to the "real" output stream, i.e. onto the wire.
    Parameters:
      `out` - the new output stream
      `copyOldContent` - flag indicating if the old content should be copied
    Throws:
      `IOException`

  - ### copyStream

    public static void copyStream(InputStream in, OutputStream out, int bufferSize) throws IOException
    Throws:
      `IOException`

  - ### size

    public long size()

  - ### getBytes

    public byte[] getBytes() throws IOException
    Throws:
      `IOException`

  - ### writeCacheTo

    public void writeCacheTo(OutputStream out) throws IOException
    Throws:
      `IOException`

  - ### writeCacheTo

    public void writeCacheTo(StringBuilder out, long limit) throws IOException
    Throws:
      `IOException`

  - ### writeCacheTo

    public void writeCacheTo(StringBuilder out, String charsetName, long limit) throws IOException
    Throws:
      `IOException`

  - ### writeCacheTo

    public void writeCacheTo(StringBuilder out) throws IOException
    Throws:
      `IOException`

  - ### writeCacheTo

    public void writeCacheTo(StringBuilder out, String charsetName) throws IOException
    Throws:
      `IOException`

  - ### getOut

    public OutputStream getOut()
    Returns:
      the underlying output stream

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### onWrite

    protected void onWrite() throws IOException
    Throws:
      `IOException`

  - ### write

    public void write(byte[] b, int off, int len) throws IOException
    Overrides:
      `write` in class `OutputStream`
    Throws:
      `IOException`

  - ### write

    public void write(byte[] b) throws IOException
    Overrides:
      `write` in class `OutputStream`
    Throws:
      `IOException`

  - ### write

    public void write(int b) throws IOException
    Specified by:
      `write` in class `OutputStream`
    Throws:
      `IOException`

  - ### getTempFile

    public File getTempFile()

  - ### getInputStream

    public InputStream getInputStream() throws IOException
    Throws:
      `IOException`

  - ### setOutputDir

    public void setOutputDir(File outputDir) throws IOException
    Throws:
      `IOException`

  - ### getThreshold

    public long getThreshold()

  - ### setThreshold

    public void setThreshold(long threshold)

  - ### setMaxSize

    public void setMaxSize(long maxSize)

  - ### setCipherTransformation

    public void setCipherTransformation(String cipherTransformation)

  - ### setDefaultMaxSize

    public static void setDefaultMaxSize(long l)

  - ### setDefaultThreshold

    public static void setDefaultThreshold(int i)

  - ### isThresholdSysPropSet

    public static boolean isThresholdSysPropSet()
    Returns true if the default threshold is explicitly set via CachedConstants.THRESHOLD_SYS_PROP

  - ### setDefaultCipherTransformation

    public static void setDefaultCipherTransformation(String n)