Interface ByteSource

    • Method Detail

      • next

        int next()
        Consume the next byte, unsigned. Must be between 0 and 255, or END_OF_STREAM if there are no more bytes.
      • of

        static <V> ByteSource of​(ValueAccessor<V> accessor,
                                 V data,
                                 ByteComparable.Version version)
        Encodes byte-accessible data as a byte-comparable source that has 0s escaped and finishes in an escaped state. This provides a weakly-prefix-free byte-comparable version of the content to use in sequences. (See ByteSource.AbstractEscaper for a detailed explanation.)
      • of

        static ByteSource of​(java.nio.ByteBuffer buf,
                             ByteComparable.Version version)
        Encodes a byte buffer as a byte-comparable source that has 0s escaped and finishes in an escape. This provides a weakly-prefix-free byte-comparable version of the content to use in sequences. (See ByteSource.BufferEscaper/Multi for explanation.)
      • of

        static ByteSource of​(byte[] buf,
                             ByteComparable.Version version)
        Encodes a byte array as a byte-comparable source that has 0s escaped and finishes in an escape. This provides a prefix-free byte-comparable version of the content to use in sequences. (See ByteSource.BufferEscaper/Multi for explanation.)
      • ofMemory

        static ByteSource ofMemory​(long address,
                                   int length,
                                   ByteComparable.Version version)
        Encodes a memory range as a byte-comparable source that has 0s escaped and finishes in an escape. This provides a weakly-prefix-free byte-comparable version of the content to use in sequences. (See ByteSource.BufferEscaper/Multi for explanation.)
      • withTerminator

        static ByteSource withTerminator​(int terminator,
                                         ByteSource... srcs)
        Combines a chain of sources, turning their weak-prefix-free byte-comparable representation into the combination's prefix-free byte-comparable representation, with the included terminator character. For correctness, the terminator must be within MIN-MAX_SEPARATOR and outside the range reserved for NEXT_COMPONENT markers. Typically TERMINATOR, or LT/GT_NEXT_COMPONENT if used for partially specified bounds.
      • withTerminatorLegacy

        static ByteSource withTerminatorLegacy​(int terminator,
                                               ByteSource... srcs)
        As above, but permits any separator. The legacy format wasn't using weak prefix freedom and has some non-reversible transformations.
      • optionalSignedFixedLengthNumber

        static <V> ByteSource optionalSignedFixedLengthNumber​(ValueAccessor<V> accessor,
                                                              V data)
        Produce a source for a signed fixed-length number, also translating empty to null. The first byte has its sign bit inverted, and the rest are passed unchanged. Presumes that the length of the buffer is always either 0 or constant for the type, which permits decoding and ensures the representation is prefix-free.
      • signedFixedLengthNumber

        static <V> ByteSource signedFixedLengthNumber​(ValueAccessor<V> accessor,
                                                      V data)
        Produce a source for a signed fixed-length number. The first byte has its sign bit inverted, and the rest are passed unchanged. Presumes that the length of the buffer is always constant for the type.
      • optionalSignedFixedLengthFloat

        static <V> ByteSource optionalSignedFixedLengthFloat​(ValueAccessor<V> accessor,
                                                             V data)
        Produce a source for a signed fixed-length floating-point number, also translating empty to null. If sign bit is on, returns negated bytes. If not, add the sign bit value. (Sign of IEEE floats is the highest bit, the rest can be compared in magnitude by byte comparison.) Presumes that the length of the buffer is always either 0 or constant for the type, which permits decoding and ensures the representation is prefix-free.
      • signedFixedLengthFloat

        static <V> ByteSource signedFixedLengthFloat​(ValueAccessor<V> accessor,
                                                     V data)
        Produce a source for a signed fixed-length floating-point number. If sign bit is on, returns negated bytes. If not, add the sign bit value. (Sign of IEEE floats is the highest bit, the rest can be compared in magnitude by byte comparison.) Presumes that the length of the buffer is always constant for the type.
      • variableLengthInteger

        static ByteSource variableLengthInteger​(long value)
        Produce a source for a signed integer, stored using variable length encoding. The representation uses between 1 and 9 bytes, is prefix-free and compares correctly.
      • separatorPrefix

        static ByteSource separatorPrefix​(ByteSource prevMax,
                                          ByteSource currMin)
        Returns a separator for two byte sources, i.e. something that is definitely > prevMax, and <= currMin, assuming prevMax < currMin. This returns the shortest prefix of currMin that is greater than prevMax.
      • separatorGt

        static ByteSource separatorGt​(ByteSource prevMax,
                                      ByteSource currMin)
        Returns a separator for two byte sources, i.e. something that is definitely > prevMax, and <= currMin, assuming prevMax < currMin. This is a source of length 1 longer than the common prefix of the two sources, with last byte one higher than the prevMax source.
      • cutOrRightPad

        static ByteSource cutOrRightPad​(ByteSource src,
                                        int cutoff,
                                        int padding)
        Wrap a ByteSource in a length-fixing facade. If the length of src is less than cutoff, then pad it on the right with padding until the overall length equals cutoff. If the length of src is greater than cutoff, then truncate src to that size. Effectively a noop if src happens to have length cutoff.
        Parameters:
        src - the input source to wrap
        cutoff - the size of the source returned
        padding - a padding byte (an int subject to a 0xFF mask)
      • fixedLength

        static <V> ByteSource fixedLength​(ValueAccessor<V> accessor,
                                          V data)
        A byte source of the given bytes without any encoding. The resulting source is only guaranteed to give correct comparison results and be prefix-free if the underlying type has a fixed length. In tests, this method is also used to generate non-escaped test cases.
      • fixedLength

        static ByteSource fixedLength​(java.nio.ByteBuffer b)
        A byte source of the given bytes without any encoding. The resulting source is only guaranteed to give correct comparison results and be prefix-free if the underlying type has a fixed length. In tests, this method is also used to generate non-escaped test cases.
      • fixedLength

        static ByteSource fixedLength​(byte[] b)
        A byte source of the given bytes without any encoding. If used in a sequence, the resulting source is only guaranteed to give correct comparison results if the underlying type has a fixed length. In tests, this method is also used to generate non-escaped test cases.
      • fixedLength

        static ByteSource fixedLength​(byte[] b,
                                      int offset,
                                      int length)