public class TrimPrefixAndSuffixEncoder extends Object implements ISequenceEncoder
dst
relative to src
by trimming whatever
non-equal suffix and prefix src
and dst
have. The
output code is (bytes):
{P}{K}{suffix}where (
P
- 'A') bytes should be trimmed from the start of
src
, (K
- 'A') bytes should be trimmed from the
end of src
and then the suffix
should be appended
to the resulting byte sequence.
Examples:
src: abc dst: abcd encoded: AAd src: abc dst: xyz encoded: ADxyz
Constructor and Description |
---|
TrimPrefixAndSuffixEncoder() |
Modifier and Type | Method and Description |
---|---|
ByteBuffer |
decode(ByteBuffer reuse,
ByteBuffer source,
ByteBuffer encoded)
|
ByteBuffer |
encode(ByteBuffer reuse,
ByteBuffer source,
ByteBuffer target)
|
String |
toString() |
public ByteBuffer encode(ByteBuffer reuse, ByteBuffer source, ByteBuffer target)
ISequenceEncoder
encode
in interface ISequenceEncoder
reuse
- Reuses the provided ByteBuffer
or allocates a new one if there is not enough remaining space.source
- The source byte sequence.target
- The target byte sequence to encode relative to source
ByteBuffer
with encoded target
.public ByteBuffer decode(ByteBuffer reuse, ByteBuffer source, ByteBuffer encoded)
ISequenceEncoder
decode
in interface ISequenceEncoder
reuse
- Reuses the provided ByteBuffer
or allocates a new one if there is not enough remaining space.source
- The source byte sequence.encoded
- The previously encoded byte sequence.ByteBuffer
with decoded target
.Copyright © 2016. All rights reserved.