org.mentalog.encoder
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: http://mentalog.soliveirajr.com for documentations, recipes and more.

Author:
Sergio Oliveira Jr. - sergio.oliveira.jr@gmail.com

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

NULL

static final Encoder NULL

CHAR_SEQUENCE

static final Encoder CHAR_SEQUENCE

BYTE_OR_CHAR_ARRAY

static final Encoder BYTE_OR_CHAR_ARRAY

THROWABLE

static final Encoder THROWABLE

ASCII

static final Encoder ASCII
Method Detail

encode

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.

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


Copyright © 2013. All Rights Reserved.