Class SequenceLexicoder<E>

Type Parameters:
E - list element type.
All Implemented Interfaces:
Encoder<List<E>>, Lexicoder<List<E>>

public class SequenceLexicoder<E> extends AbstractLexicoder<List<E>>
A Lexicoder to encode/decode a Java List to/from a byte array where the concatenation of each encoded element sorts lexicographically. Note: Unlike ListLexicoder, this implementation supports empty lists. The lists are encoded with the elements separated by null (0x0) bytes, which null bytes appearing in the elements escaped as two 0x1 bytes, and 0x1 bytes appearing in the elements escaped as 0x1 and 0x2 bytes. The list is terminated with a final delimiter after the last element, with no bytes following it. An empty list is represented as an empty byte array, with no delimiter, whereas a list with a single empty element is represented as a single terminating delimiter.
Since:
2.0.0
  • Constructor Details

    • SequenceLexicoder

      public SequenceLexicoder(Lexicoder<E> elementLexicoder)
      Primary constructor.
      Parameters:
      elementLexicoder - Lexicoder to apply to elements.
  • Method Details

    • encode

      public byte[] encode(List<E> v)
      Returns:
      a byte array containing the concatenation of each element in the list encoded.
    • decodeUnchecked

      protected List<E> decodeUnchecked(byte[] b, int offset, int len)
      Description copied from class: AbstractEncoder
      Decodes a byte array without checking if the offset and len exceed the bounds of the actual array.
      Specified by:
      decodeUnchecked in class AbstractEncoder<List<E>>