Skip to content

Package: MIMEEvent$EndPart

MIMEEvent$EndPart

nameinstructionbranchcomplexitylinemethod
MIMEEvent.EndPart()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getEventType()
M: 0 C: 2
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /*
2: * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
3: *
4: * This program and the accompanying materials are made available under the
5: * terms of the Eclipse Distribution License v. 1.0, which is available at
6: * http://www.eclipse.org/org/documents/edl-v10.php.
7: *
8: * SPDX-License-Identifier: BSD-3-Clause
9: */
10:
11: package org.jvnet.mimepull;
12:
13: import java.nio.ByteBuffer;
14:
15: /**
16: * @author Jitendra Kotamraju
17: */
18: abstract class MIMEEvent {
19:
20: enum EVENT_TYPE {START_MESSAGE, START_PART, HEADERS, CONTENT, END_PART, END_MESSAGE}
21:
22: /**
23: * Returns a event for parser's current cursor location in the MIME message.
24: *
25: * <p>
26: * {@link EVENT_TYPE#START_MESSAGE} and {@link EVENT_TYPE#START_MESSAGE} events
27: * are generated only once.
28: *
29: * <p>
30: * {@link EVENT_TYPE#START_PART}, {@link EVENT_TYPE#END_PART}, {@link EVENT_TYPE#HEADERS}
31: * events are generated only once for each attachment part.
32: *
33: * <p>
34: * {@link EVENT_TYPE#CONTENT} event may be generated more than once for an attachment
35: * part.
36: *
37: * @return event type
38: */
39: abstract EVENT_TYPE getEventType();
40:
41: static final StartMessage START_MESSAGE = new StartMessage();
42: static final StartPart START_PART = new StartPart();
43: static final EndPart END_PART = new EndPart();
44: static final EndMessage END_MESSAGE = new EndMessage();
45:
46: static final class StartMessage extends MIMEEvent {
47: @Override
48: EVENT_TYPE getEventType() {
49: return EVENT_TYPE.START_MESSAGE;
50: }
51: }
52:
53: static final class StartPart extends MIMEEvent {
54: @Override
55: EVENT_TYPE getEventType() {
56: return EVENT_TYPE.START_PART;
57: }
58: }
59:
60: static final class EndPart extends MIMEEvent {
61: @Override
62: EVENT_TYPE getEventType () {
63: return EVENT_TYPE.END_PART;
64: }
65: }
66:
67: static final class Headers extends MIMEEvent {
68: InternetHeaders ih;
69:
70: Headers(InternetHeaders ih) {
71: this.ih = ih;
72: }
73:
74: @Override
75: EVENT_TYPE getEventType() {
76: return EVENT_TYPE.HEADERS;
77: }
78:
79: InternetHeaders getHeaders() {
80: return ih;
81: }
82: }
83:
84: static final class Content extends MIMEEvent {
85: private final ByteBuffer buf;
86:
87: Content(ByteBuffer buf) {
88: this.buf = buf;
89: }
90:
91: @Override
92: EVENT_TYPE getEventType() {
93: return EVENT_TYPE.CONTENT;
94: }
95:
96: ByteBuffer getData() {
97: return buf;
98: }
99: }
100:
101: static final class EndMessage extends MIMEEvent {
102: @Override
103: EVENT_TYPE getEventType() {
104: return EVENT_TYPE.END_MESSAGE;
105: }
106: }
107:
108: }