org.mentalog.encoder.CharSequenceEncoder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of menta-log Show documentation
Show all versions of menta-log Show documentation
A log library that embraces the kiss principle.
package org.mentalog.encoder;
import java.nio.ByteBuffer;
public class CharSequenceEncoder implements Encoder {
@Override
public boolean encode(Object obj, ByteBuffer bb, int varargsPos, int varargsLen) {
if (obj instanceof CharSequence) {
CharSequence s = (CharSequence) obj;
int len = s.length();
for (int i = 0; i < len; i++) {
bb.put((byte) s.charAt(i));
}
return true;
}
return false;
}
}