Interface Encoder

All Known Implementing Classes:
AsciiEncoder, ByteOrCharArrayEncoder, CharSequenceEncoder, NullEncoder, ThrowableEncoder

public interface Encoder

An interface that you can use to encode any object inside a ByteBuffer. This is important to avoid calling toString() in the objects passed to the log() method. For example, MentaLog already comes with encoders for null, CharSequences, and byte/char arrays that do not create any strings (garbage). Refer to: for documentations, recipes and more.

Sergio Oliveira Jr. -

Field Summary
static Encoder ASCII
static Encoder BYTE_OR_CHAR_ARRAY
static Encoder CHAR_SEQUENCE
static Encoder NULL
static Encoder THROWABLE
Method Summary
 boolean encode(Object obj, ByteBuffer dest, int varargsPos, int varargsLen)
          Encode the given object into the provided byte buffer.

Field Detail


static final Encoder NULL


static final Encoder CHAR_SEQUENCE


static final Encoder BYTE_OR_CHAR_ARRAY


static final Encoder THROWABLE


static final Encoder ASCII
Method Detail


boolean encode(Object obj,
               ByteBuffer dest,
               int varargsPos,
               int varargsLen)
Encode the given object into the provided byte buffer. Note: You should use instanceof to check and cast the object to a type that this encoder can encode. Each encoder receives all objects passed to the log() method. If a encoder receives an object it does not support, it does nothing and returns false, so the next encoder in the chain will be applied.

obj - That object to be encoded.
dest - The byte buffer that will receive the encoded object.
true if the object was encoded, false otherwise

Copyright © 2013. All Rights Reserved.