Class ContentChannelOutputStream

  • All Implemented Interfaces:
    com.yahoo.io.WritableByteTransmitter, java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable

    public class ContentChannelOutputStream
    extends java.io.OutputStream
    implements com.yahoo.io.WritableByteTransmitter
    A buffered stream wrapping a ContentChannel.
    Author:
    Steinar Knutsen
    • Constructor Summary

      Constructors 
      Constructor Description
      ContentChannelOutputStream​(com.yahoo.jdisc.handler.ContentChannel endpoint)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Flush the internal buffers, does not touch the ContentChannel.
      void flush()
      Flush the internal buffers, does not touch the ContentChannel.
      void nonCopyingWrite​(byte[] b)
      Buffered write the contents of the array to this stream, transferring ownership of that array to this stream.
      void nonCopyingWrite​(byte[] b, int off, int len)
      Buffered write of the contents of the array to this stream, transferring ownership of that array to this stream.
      void send​(java.nio.ByteBuffer src)
      Write a ByteBuffer to the wrapped ContentChannel.
      void write​(byte[] b)
      Buffered write the contents of the array to this stream, copying the contents of the given array to this stream.
      void write​(byte[] b, int off, int len)
      Buffered write of the contents of the array to this stream, copying the contents of the given array to this stream.
      void write​(int b)
      Buffered write of a single byte.
      long written()
      Give the number of bytes written.
      • Methods inherited from class java.io.OutputStream

        nullOutputStream
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ContentChannelOutputStream

        public ContentChannelOutputStream​(com.yahoo.jdisc.handler.ContentChannel endpoint)
    • Method Detail

      • write

        public void write​(int b)
                   throws java.io.IOException
        Buffered write of a single byte.
        Specified by:
        write in class java.io.OutputStream
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Flush the internal buffers, does not touch the ContentChannel.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.OutputStream
        Throws:
        java.io.IOException
      • flush

        public void flush()
                   throws java.io.IOException
        Flush the internal buffers, does not touch the ContentChannel.
        Specified by:
        flush in interface java.io.Flushable
        Overrides:
        flush in class java.io.OutputStream
        Throws:
        java.io.IOException
      • write

        public void write​(byte[] b,
                          int off,
                          int len)
                   throws java.io.IOException
        Buffered write of the contents of the array to this stream, copying the contents of the given array to this stream. It is in other words safe to recycle the array b.
        Overrides:
        write in class java.io.OutputStream
        Throws:
        java.io.IOException
      • write

        public void write​(byte[] b)
                   throws java.io.IOException
        Buffered write the contents of the array to this stream, copying the contents of the given array to this stream. It is in other words safe to recycle the array b.
        Overrides:
        write in class java.io.OutputStream
        Throws:
        java.io.IOException
      • nonCopyingWrite

        public void nonCopyingWrite​(byte[] b,
                                    int off,
                                    int len)
                             throws java.io.IOException
        Buffered write of the contents of the array to this stream, transferring ownership of that array to this stream. It is in other words not safe to recycle the array b.
        Throws:
        java.io.IOException
      • nonCopyingWrite

        public void nonCopyingWrite​(byte[] b)
                             throws java.io.IOException
        Buffered write the contents of the array to this stream, transferring ownership of that array to this stream. It is in other words not safe to recycle the array b.
        Throws:
        java.io.IOException
      • send

        public void send​(java.nio.ByteBuffer src)
                  throws java.io.IOException
        Write a ByteBuffer to the wrapped ContentChannel. Do invoke flush() before send(ByteBuffer) to avoid garbled output if the stream API has been accessed before using the ByteBuffer based API. As with ContentChannel, this transfers ownership of the ByteBuffer to this stream.
        Specified by:
        send in interface com.yahoo.io.WritableByteTransmitter
        Throws:
        java.io.IOException
      • written

        public long written()
        Give the number of bytes written.
        Returns:
        the number of bytes written to this stream