View Javadoc
1   package org.esigate.events.impl;
2   
3   import java.nio.charset.Charset;
4   
5   import org.esigate.events.Event;
6   
7   /**
8    * Encoding event : when a HTTP response is read as String.
9    * 
10   * @author Nicolas Richeton
11   * 
12   */
13  public class ReadEntityEvent extends Event {
14      /**
15       * Response mime type.
16       */
17      private final String mimeType;
18  
19      /**
20       * Declared or detected charset.
21       * <p>
22       * The charset can be modified by an extension.
23       * <p>
24       * Note : if charset is modified, entityContent should be updated too.
25       */
26      private final Charset charset;
27  
28      /**
29       * The raw entity content, without any character set applied. It can be used to re-decode the entity content if the
30       * default charset was incorrect.
31       */
32      private final byte[] rawEntityContent;
33      /**
34       * The current, decoded entity content.
35       * <p>
36       * An extension can update this content if is incorrect.
37       * <p>
38       * Note : if entityContent is modified, charset should be updated too.
39       */
40      private String entityContent;
41  
42      public ReadEntityEvent(String mimeType, Charset charset, byte[] rawEntityContent) {
43          this.mimeType = mimeType;
44          this.charset = charset;
45          this.rawEntityContent = rawEntityContent;
46      }
47  
48      public String getEntityContent() {
49          return entityContent;
50      }
51  
52      public void setEntityContent(String entityContent) {
53          this.entityContent = entityContent;
54      }
55  
56      public String getMimeType() {
57          return mimeType;
58      }
59  
60      public Charset getCharset() {
61          return charset;
62      }
63  
64      public byte[] getRawEntityContent() {
65          return rawEntityContent;
66      }
67  }