1 | /**************************************************************** |
---|
2 | * Licensed to the Apache Software Foundation (ASF) under one * |
---|
3 | * or more contributor license agreements. See the NOTICE file * |
---|
4 | * distributed with this work for additional information * |
---|
5 | * regarding copyright ownership. The ASF licenses this file * |
---|
6 | * to you under the Apache License, Version 2.0 (the * |
---|
7 | * "License"); you may not use this file except in compliance * |
---|
8 | * with the License. You may obtain a copy of the License at * |
---|
9 | * * |
---|
10 | * http://www.apache.org/licenses/LICENSE-2.0 * |
---|
11 | * * |
---|
12 | * Unless required by applicable law or agreed to in writing, * |
---|
13 | * software distributed under the License is distributed on an * |
---|
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * |
---|
15 | * KIND, either express or implied. See the License for the * |
---|
16 | * specific language governing permissions and limitations * |
---|
17 | * under the License. * |
---|
18 | ****************************************************************/ |
---|
19 | |
---|
20 | package org.apache.james.mime4j.dom; |
---|
21 | |
---|
22 | /** |
---|
23 | * MIME entity. An entity has a header and a body (see RFC 2045). |
---|
24 | */ |
---|
25 | public interface Entity extends Disposable { |
---|
26 | |
---|
27 | /** |
---|
28 | * Gets the parent entity of this entity. |
---|
29 | * Returns <code>null</code> if this is the root entity. |
---|
30 | * |
---|
31 | * @return the parent or <code>null</code>. |
---|
32 | */ |
---|
33 | Entity getParent(); |
---|
34 | |
---|
35 | /** |
---|
36 | * Sets the parent entity of this entity. |
---|
37 | * |
---|
38 | * @param parent the parent entity or <code>null</code> if |
---|
39 | * this will be the root entity. |
---|
40 | */ |
---|
41 | void setParent(Entity parent); |
---|
42 | |
---|
43 | /** |
---|
44 | * Gets the entity header. |
---|
45 | * |
---|
46 | * @return the header. |
---|
47 | */ |
---|
48 | Header getHeader(); |
---|
49 | |
---|
50 | /** |
---|
51 | * Sets the entity header. |
---|
52 | * |
---|
53 | * @param header the header. |
---|
54 | */ |
---|
55 | void setHeader(Header header); |
---|
56 | |
---|
57 | /** |
---|
58 | * Gets the body of this entity. |
---|
59 | * |
---|
60 | * @return the body, |
---|
61 | */ |
---|
62 | Body getBody(); |
---|
63 | |
---|
64 | /** |
---|
65 | * Sets the body of this entity. |
---|
66 | * |
---|
67 | * @param body the body. |
---|
68 | * @throws IllegalStateException if the body has already been set. |
---|
69 | */ |
---|
70 | void setBody(Body body); |
---|
71 | |
---|
72 | /** |
---|
73 | * Removes and returns the body of this entity. The removed body may be |
---|
74 | * attached to another entity. If it is no longer needed it should be |
---|
75 | * {@link Disposable#dispose() disposed} of. |
---|
76 | * |
---|
77 | * @return the removed body or <code>null</code> if no body was set. |
---|
78 | */ |
---|
79 | Body removeBody(); |
---|
80 | |
---|
81 | /** |
---|
82 | * Determines if the MIME type of this <code>Entity</code> is |
---|
83 | * <code>multipart/*</code>. Since multipart-entities must have |
---|
84 | * a boundary parameter in the <code>Content-Type</code> field this |
---|
85 | * method returns <code>false</code> if no boundary exists. |
---|
86 | * |
---|
87 | * @return <code>true</code> on match, <code>false</code> otherwise. |
---|
88 | */ |
---|
89 | boolean isMultipart(); |
---|
90 | |
---|
91 | /** |
---|
92 | * Determines the MIME type of this <code>Entity</code>. The MIME type |
---|
93 | * is derived by looking at the parent's Content-Type field if no |
---|
94 | * Content-Type field is set for this <code>Entity</code>. |
---|
95 | * |
---|
96 | * @return the MIME type. |
---|
97 | */ |
---|
98 | String getMimeType(); |
---|
99 | |
---|
100 | /** |
---|
101 | * Determines the MIME character set encoding of this <code>Entity</code>. |
---|
102 | * |
---|
103 | * @return the MIME character set encoding. |
---|
104 | */ |
---|
105 | String getCharset(); |
---|
106 | |
---|
107 | /** |
---|
108 | * Determines the transfer encoding of this <code>Entity</code>. |
---|
109 | * |
---|
110 | * @return the transfer encoding. |
---|
111 | */ |
---|
112 | String getContentTransferEncoding(); |
---|
113 | |
---|
114 | /** |
---|
115 | * Return the disposition type of the content disposition of this |
---|
116 | * <code>Entity</code>. |
---|
117 | * |
---|
118 | * @return the disposition type or <code>null</code> if no disposition |
---|
119 | * type has been set. |
---|
120 | */ |
---|
121 | String getDispositionType(); |
---|
122 | |
---|
123 | /** |
---|
124 | * Returns the filename parameter of the content disposition of this |
---|
125 | * <code>Entity</code>. |
---|
126 | * |
---|
127 | * @return the filename parameter of the content disposition or |
---|
128 | * <code>null</code> if the filename has not been set. |
---|
129 | */ |
---|
130 | String getFilename(); |
---|
131 | |
---|
132 | } |
---|