Package: BODY
BODY
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
BODY(FetchResponse) |
|
|
|
|
|
||||||||||||||||||||
getByteArray() |
|
|
|
|
|
||||||||||||||||||||
getByteArrayInputStream() |
|
|
|
|
|
||||||||||||||||||||
getOrigin() |
|
|
|
|
|
||||||||||||||||||||
getSection() |
|
|
|
|
|
||||||||||||||||||||
isHeader() |
|
|
|
|
|
||||||||||||||||||||
static {...} |
|
|
|
|
|
Coverage
1: /*
2: * Copyright (c) 1997, 2023 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 Public License v. 2.0, which is available at
6: * http://www.eclipse.org/legal/epl-2.0.
7: *
8: * This Source Code may also be made available under the following Secondary
9: * Licenses when the conditions for such availability set forth in the
10: * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11: * version 2 with the GNU Classpath Exception, which is available at
12: * https://www.gnu.org/software/classpath/license.html.
13: *
14: * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15: */
16:
17: package org.eclipse.angus.mail.imap.protocol;
18:
19: import java.io.ByteArrayInputStream;
20: import org.eclipse.angus.mail.iap.*;
21: import org.eclipse.angus.mail.iap.ByteArray;
22: import org.eclipse.angus.mail.iap.ParsingException;
23:
24: /**
25: * The BODY fetch response item.
26: *
27: * @author John Mani
28: * @author Bill Shannon
29: */
30:
31: public class BODY implements Item {
32:
33: static final char[] name = {'B','O','D','Y'};
34:
35: private final int msgno;
36: private final ByteArray data;
37: private final String section;
38: private final int origin;
39: private final boolean isHeader;
40:
41: /**
42: * Constructor
43: *
44: * @param        r        the FetchResponse
45: * @exception ParsingException for parsing failures
46: */
47: public BODY(FetchResponse r) throws ParsingException {
48:         msgno = r.getNumber();
49:
50:         r.skipSpaces();
51:
52:•        if (r.readByte() != '[')
53:          throw new ParsingException(
54:                  "BODY parse error: missing ``['' at section start");
55:         section = r.readString(']');
56:•        if (r.readByte() != ']')
57:          throw new ParsingException(
58:                  "BODY parse error: missing ``]'' at section end");
59:         isHeader = section.regionMatches(true, 0, "HEADER", 0, 6);
60:
61:•        if (r.readByte() == '<') { // origin
62:          origin = r.readNumber();
63:          r.skip(1); // skip '>';
64:         } else
65:          origin = -1;
66:
67:         data = r.readByteArray();
68: }
69:
70: public ByteArray getByteArray() {
71:         return data;
72: }
73:
74: public ByteArrayInputStream getByteArrayInputStream() {
75:•        if (data != null)
76:          return data.toByteArrayInputStream();
77:         else
78:          return null;
79: }
80:
81: public boolean isHeader() {
82:         return isHeader;
83: }
84:
85: public String getSection() {
86:         return section;
87: }
88:
89: /**
90: * @return origin
91: * @since        Jakarta Mail 1.6.4
92: */
93: public int getOrigin() {
94:         return origin;
95: }
96: }