Trait/Object

com.twitter.io

ByteReader

Related Docs: object ByteReader | package io

Permalink

trait ByteReader extends AutoCloseable

A ByteReader provides a stateful API to extract bytes from an underlying buffer, which in most cases is a Buf. This conveniently allows codec implementations to decode frames, specifically when they need to decode and interpret the bytes as a numeric value.

Note

Unless otherwise stated, ByteReader implementations are not thread safe.

Linear Supertypes
AutoCloseable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ByteReader
  2. AutoCloseable
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def close(): Unit

    Permalink
    Definition Classes
    AutoCloseable
    Annotations
    @throws( classOf[java.lang.Exception] )
  2. abstract def process(from: Int, until: Int, processor: Processor): Int

    Permalink

    Process the underlying buffer 1-byte at a time using the given Buf.Processor, starting at index from of the underlying buffer until index until of the underlying buffer.

    Process the underlying buffer 1-byte at a time using the given Buf.Processor, starting at index from of the underlying buffer until index until of the underlying buffer. Processing will halt if the processor returns false or after processing the final byte.

    from

    the starting index, inclusive. Must be non-negative.

    until

    the ending index, exclusive. Must be non-negative.

    returns

    -1 if the processor processed all bytes or the last processed index if the processor returns false. Will return -1 if from is greater than or equal to until or length of the underlying buffer. Will return -1 if until is greater than or equal to length of the underlying buffer.

    Note

    this does not advance the byte cursor.

  3. abstract def process(processor: Processor): Int

    Permalink

    Process the underlying buffer 1-byte at a time using the given Buf.Processor, starting at index 0 of the underlying buffer until index length of the underlying buffer.

    Process the underlying buffer 1-byte at a time using the given Buf.Processor, starting at index 0 of the underlying buffer until index length of the underlying buffer. Processing will halt if the processor returns false or after processing the final byte.

    returns

    -1 if the processor processed all bytes or the last processed index if the processor returns false.

    Note

    this does not advance the byte cursor.

  4. abstract def readAll(): Buf

    Permalink

    Like read, but extracts the remainder of bytes from cursor to the length.

    Like read, but extracts the remainder of bytes from cursor to the length. Note, this advances the cursor to the end of the buf.

  5. abstract def readByte(): Byte

    Permalink

    Extract 8 bits and interpret as a signed integer, advancing the byte cursor by 1.

  6. abstract def readBytes(n: Int): Buf

    Permalink

    Returns a new buffer representing a slice of this buffer, delimited by the indices [cursor, remaining).

    Returns a new buffer representing a slice of this buffer, delimited by the indices [cursor, remaining). Out of bounds indices are truncated. Negative indices are not accepted.

  7. abstract def readDoubleBE(): Double

    Permalink

    Extract 64 bits and interpret as a big endian floating point, advancing the byte cursor by 4.

  8. abstract def readDoubleLE(): Double

    Permalink

    Extract 64 bits and interpret as a little endian floating point, advancing the byte cursor by 4.

  9. abstract def readFloatBE(): Float

    Permalink

    Extract 32 bits and interpret as a big endian floating point, advancing the byte cursor by 4.

  10. abstract def readFloatLE(): Float

    Permalink

    Extract 32 bits and interpret as a little endian floating point, advancing the byte cursor by 4.

  11. abstract def readIntBE(): Int

    Permalink

    Extract 32 bits and interpret as a big endian integer, advancing the byte cursor by 4.

  12. abstract def readIntLE(): Int

    Permalink

    Extract 32 bits and interpret as a little endian int, advancing the byte cursor by 4.

  13. abstract def readLongBE(): Long

    Permalink

    Extract 64 bits and interpret as a big endian integer, advancing the byte cursor by 8.

  14. abstract def readLongLE(): Long

    Permalink

    Extract 64 bits and interpret as a little endian integer, advancing the byte cursor by 8.

  15. abstract def readMediumBE(): Int

    Permalink

    Extract 24 bits and interpret as a big endian integer, advancing the byte cursor by 3.

  16. abstract def readMediumLE(): Int

    Permalink

    Extract 24 bits and interpret as a little endian integer, advancing the byte cursor by 3.

  17. abstract def readShortBE(): Short

    Permalink

    Extract 16 bits and interpret as a big endian integer, advancing the byte cursor by 2.

  18. abstract def readShortLE(): Short

    Permalink

    Extract 16 bits and interpret as a little endian integer, advancing the byte cursor by 2.

  19. abstract def readString(bytes: Int, charset: Charset): String

    Permalink

    Extract exactly the specified number of bytes into a String using the specified Charset, advancing the byte cursor by bytes.

    Extract exactly the specified number of bytes into a String using the specified Charset, advancing the byte cursor by bytes.

    Exceptions thrown

    UnderflowException if there are < bytes bytes available

  20. abstract def readUnsignedByte(): Short

    Permalink

    Extract 8 bits and interpret as an unsigned integer, advancing the byte cursor by 1.

  21. abstract def readUnsignedIntBE(): Long

    Permalink

    Extract 32 bits and interpret as a big endian unsigned integer, advancing the byte cursor by 4.

  22. abstract def readUnsignedIntLE(): Long

    Permalink

    Extract 32 bits and interpret as a little endian unsigned integer, advancing the byte cursor by 4.

  23. abstract def readUnsignedLongBE(): BigInt

    Permalink

    Extract 64 bits and interpret as a big endian unsigned integer, advancing the byte cursor by 8.

  24. abstract def readUnsignedLongLE(): BigInt

    Permalink

    Extract 64 bits and interpret as a little endian unsigned integer, advancing the byte cursor by 8.

  25. abstract def readUnsignedMediumBE(): Int

    Permalink

    Extract 24 bits and interpret as a big endian unsigned integer, advancing the byte cursor by 3.

  26. abstract def readUnsignedMediumLE(): Int

    Permalink

    Extract 24 bits and interpret as a little endian unsigned integer, advancing the byte cursor by 3.

  27. abstract def readUnsignedShortBE(): Int

    Permalink

    Extract 16 bits and interpret as a big endian unsigned integer, advancing the byte cursor by 2.

  28. abstract def readUnsignedShortLE(): Int

    Permalink

    Extract 16 bits and interpret as a little endian unsigned integer, advancing the byte cursor by 2.

  29. abstract def remaining: Int

    Permalink

    The remainder of bytes that the reader is capable of reading.

  30. abstract def remainingUntil(byte: Byte): Int

    Permalink

    The remainder of bytes until the first occurrence of byte (exclusive).

    The remainder of bytes until the first occurrence of byte (exclusive). Returns -1 when byte is not found on the underlying resource.

    Note

    All util and finagle Buf implementations will not copy onto the heap, but for other implementations, it may trigger a copy.

  31. abstract def skip(n: Int): Unit

    Permalink

    Skip over the next n bytes.

    Skip over the next n bytes.

    Exceptions thrown

    UnderflowException if there are < n bytes available

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  10. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  11. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  12. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  13. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  14. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  15. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  16. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  17. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  18. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  19. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AutoCloseable

Inherited from AnyRef

Inherited from Any

Ungrouped