Class IdentityEncoder

  • All Implemented Interfaces:
    ContentEncoder, FileContentEncoder

    public class IdentityEncoder
    extends AbstractContentEncoder
    implements FileContentEncoder
    Content encoder that writes data without any transformation. The end of the content entity is demarcated by closing the underlying connection (EOF condition). Entities transferred using this input stream can be of unlimited length.

    This decoder is optimized to transfer data directly from a FileChannel to the underlying I/O session's channel whenever possible avoiding intermediate buffering in the session buffer.

    • Method Detail

      • write

        public int write​(ByteBuffer src)
                  throws IOException
        Description copied from interface: ContentEncoder
        Writes a portion of entity content to the underlying channel.
        Specified by:
        write in interface ContentEncoder
        src - The buffer from which content is to be retrieved
        The number of bytes read, possibly zero
        IOException - if I/O error occurs while writing content
      • transfer

        public long transfer​(FileChannel src,
                             long position,
                             long count)
                      throws IOException
        Description copied from interface: FileContentEncoder
        Transfers a portion of entity content from the given file channel to the underlying network channel.
        Specified by:
        transfer in interface FileContentEncoder
        src - the source FileChannel to transfer data from.
        position - The position within the file at which the transfer is to begin; must be non-negative
        count - The maximum number of bytes to be transferred; must be non-negative
        The number of bytes, possibly zero, that were actually transferred
        IOException - if some I/O error occurs.