View Javadoc
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>
27   *          event type
28   * @since 0.9.19
29   */
30  public interface Encoder<E> extends ContextAware, LifeCycle {
31  
32      /**
33       * Get header bytes. This method is typically called upon opening of 
34       * an output stream.
35       * 
36       * @return header bytes. Null values are allowed.
37       */
38      byte[] headerBytes();
39  
40      /**
41       * Encode an event as bytes.
42       *  
43       * @param event
44       */
45      byte[] encode(E event);
46                      
47      /**
48       * Get footer bytes. This method is typically called prior to the closing 
49       * of the stream where events are written.
50       * 
51       * @return footer bytes. Null values are allowed.
52       */
53      byte[] footerBytes();
54  }