MIME4J-5 Performance patch 3, https://issues.apache.org/jira/browse/MIME4J-5. Contrib...
[mime4j.git] / src / main / java / org / apache / james / mime4j / Event.java
blob88dcd4d16b9319325968464bed72602796f516f3
1 package org.apache.james.mime4j;
3 /**
4 * Enumerates events which can be monitored.
5 */
6 public final class Event {
8 /** Indicates that a body part ended prematurely. */
9 public static final Event MIME_BODY_PREMATURE_END
10 = new Event("Body part ended prematurely. " +
11 "Boundary detected in header or EOF reached.");
12 /** Indicates that unexpected end of headers detected.*/
13 public static final Event HEADERS_PREMATURE_END
14 = new Event("Unexpected end of headers detected. " +
15 "Higher level boundary detected or EOF reached.");
16 /** Indicates that unexpected end of headers detected.*/
17 public static final Event INALID_HEADER
18 = new Event("Invalid header encountered");
20 private final String code;
22 public Event(final String code) {
23 super();
24 if (code == null) {
25 throw new IllegalArgumentException("Code may not be null");
27 this.code = code;
30 public int hashCode() {
31 return code.hashCode();
34 public boolean equals(Object obj) {
35 if (obj == null) return false;
36 if (this == obj) return true;
37 if (obj instanceof Event) {
38 Event that = (Event) obj;
39 return this.code.equals(that.code);
40 } else {
41 return false;
45 public String toString() {
46 return code;