1 /**
2 * Logback: the reliable, generic, fast and flexible logging framework.
3 * Copyright (C) 1999-2015, QOS.ch. All rights reserved.
4 *
5 * This program and the accompanying materials are dual-licensed under
6 * either the terms of the Eclipse Public License v1.0 as published by
7 * the Eclipse Foundation
8 *
9 * or (per the licensee's choosing)
10 *
11 * under the terms of the GNU Lesser General Public License version 2.1
12 * as published by the Free Software Foundation.
13 */
14 package ch.qos.logback.core.encoder;
15
16 import ch.qos.logback.core.spi.ContextAware;
17 import ch.qos.logback.core.spi.LifeCycle;
18
19 /**
20 * Encoders are responsible for transform an incoming event into a byte array
21 *
22 * @author Ceki Gülcü
23 * @author Joern Huxhorn
24 * @author Maarten Bosteels
25 *
26 * @param <E> event type
27 * @since 0.9.19
28 */
29 public interface Encoder<E> extends ContextAware, LifeCycle {
30
31 /**
32 * Get header bytes. This method is typically called upon opening of an output
33 * stream.
34 *
35 * @return header bytes. Null values are allowed.
36 */
37 byte[] headerBytes();
38
39 /**
40 * Encode an event as bytes.
41 *
42 * @param event
43 */
44 byte[] encode(E event);
45
46 /**
47 * Get footer bytes. This method is typically called prior to the closing of the
48 * stream where events are written.
49 *
50 * @return footer bytes. Null values are allowed.
51 */
52 byte[] footerBytes();
53 }