Class VoidEncoding

All Implemented Interfaces:
Encoding<Void>, NaturalSortAware, Serializable, Comparator<Void>

public class VoidEncoding extends PrimitiveEncoding<Void>
Encoding for void primitive type.

Doesn't support any values.

See Also:
  • Constructor Details

    • VoidEncoding

      public VoidEncoding()
  • Method Details

    • read

      public Void read(ByteReader reader)
      Description copied from interface: Encoding
      Read a value from the given input.
      Parameters:
      reader - byte input
      Returns:
      decoded value (possibly null)
    • write

      public void write(ByteWriter writer, Void value)
      Description copied from interface: Encoding
      Write a value to the given output.
      Parameters:
      writer - byte output
      value - value to write (possibly null)
    • skip

      public void skip(ByteReader reader)
      Description copied from interface: Encoding
      Read and discard a byte[] encoded value from the given input.

      If the value skipped over is invalid, this method may, but is not required to, throw IllegalArgumentException.

      If the value skipped over is truncated, this method must throw IndexOutOfBoundsException.

      Parameters:
      reader - byte input
    • convertNumber

      protected Void convertNumber(Number value)
      Specified by:
      convertNumber in class PrimitiveEncoding<Void>
    • hasPrefix0x00

      public boolean hasPrefix0x00()
      Description copied from interface: Encoding
      Determine whether any of this encoding's encoded values start with a 0x00 byte. Certain optimizations are possible when this is not the case. It is safe for this method to always return true.

      Note: changing the result of this method may result in an incompatible encoding if this encoding is wrapped in another class.

      Returns:
      true if an encoded value starting with 0x00 exists
    • hasPrefix0xff

      public boolean hasPrefix0xff()
      Description copied from interface: Encoding
      Determine whether any of this encoding's encoded values start with a 0xff byte. Certain optimizations are possible when this is not the case. It is safe for this method to always return true.

      Note: changing the result of this method may result in an incompatible encoding if this encoding is wrapped in another class.

      Returns:
      true if an encoded value starting with 0xff exists
    • getFixedWidth

      public OptionalInt getFixedWidth()
      Description copied from interface: Encoding
      Get the fixed width of this encoding, if any.

      Some encodings encode every value into the same number of bytes. For such encodings, this method returns that number. For variable width encodings, this method must return empty.

      Returns:
      the number of bytes of every encoded value, or empty if the encoding length varies