KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > axis > attachments > Attachments


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.jboss.axis.attachments;
17
18 import org.jboss.axis.Part;
19
20 /**
21  * Access the Attachments of a Message. This interface essentially
22  * firewalls the rest of Axis from any dependencies on javax.activation.
23  * <p/>
24  * If javax.activation is not available, this is the *only* class that
25  * will be compiled in org.jboss.axis.attachments.
26  *
27  * @author Rob Jellinghaus (robj@unrealities.com)
28  * @author Rick Rineholt
29  */

30 public interface Attachments
31 {
32    /**
33     * Adds an existing attachment to this list.
34     * Note: Passed part will be bound to this message.
35     *
36     * @param newPart new part to add
37     * @return Part old attachment with the same Content-ID, or null.
38     * @throws org.jboss.axis.AxisFault
39     */

40    public Part addAttachmentPart(Part newPart)
41            throws org.jboss.axis.AxisFault;
42
43    /**
44     * This method uses getAttacmentByReference() to look for attachment.
45     * If attachment has been found, it will be removed from the list, and
46     * returned to the user.
47     *
48     * @param reference The reference that referers to an attachment.
49     * @return The part associated with the removed attachment, or null.
50     * @throws org.jboss.axis.AxisFault
51     */

52    public Part removeAttachmentPart(String JavaDoc reference)
53            throws org.jboss.axis.AxisFault;
54
55    /**
56     * Removes all <CODE>AttachmentPart</CODE> objects that have
57     * been added to this <CODE>SOAPMessage</CODE> object.
58     * <p/>
59     * <P>This method does not touch the SOAP part.</P>
60     */

61    public void removeAllAttachments();
62
63    /**
64     * This method should look at a refernce and determine if it is a CID: or url
65     * to look for attachment.
66     *
67     * @param reference The reference in the xml that referers to an attachment.
68     * @return The part associated with the attachment.
69     * @throws org.jboss.axis.AxisFault
70     */

71    public Part getAttachmentByReference(String JavaDoc reference)
72            throws org.jboss.axis.AxisFault;
73
74    /**
75     * This method will return all attachments as a collection.
76     *
77     * @return A collection of attachments.
78     * @throws org.jboss.axis.AxisFault
79     */

80    public java.util.Collection JavaDoc getAttachments()
81            throws org.jboss.axis.AxisFault;
82
83    /**
84     * Retrieves all the <CODE>AttachmentPart</CODE> objects
85     * that have header entries that match the specified headers.
86     * Note that a returned attachment could have headers in
87     * addition to those specified.
88     *
89     * @param headers a <CODE>MimeHeaders</CODE>
90     * object containing the MIME headers for which to
91     * search
92     * @return an iterator over all attachments that have a header
93     * that matches one of the given headers
94     */

95    public java.util.Iterator JavaDoc getAttachments(javax.xml.soap.MimeHeaders JavaDoc headers);
96
97    /**
98     * Create a new attachment Part in this Message.
99     * Will actually, and always, return an AttachmentPart.
100     *
101     * @param part The part that is referenced
102     * @return a new attachment part
103     * @throws org.jboss.axis.AxisFault
104     */

105    public Part createAttachmentPart(Object JavaDoc part)
106            throws org.jboss.axis.AxisFault;
107
108    /**
109     * Create a new attachment Part in this Message.
110     * Will actually, and always, return an AttachmentPart.
111     *
112     * @return a new attachment part
113     * @throws org.jboss.axis.AxisFault
114     */

115    public Part createAttachmentPart() throws org.jboss.axis.AxisFault;
116
117    /**
118     * Will the attachments of this message to that of the colleciton.
119     *
120     * @param parts
121     * @throws org.jboss.axis.AxisFault
122     */

123    public void setAttachmentParts(java.util.Collection JavaDoc parts)
124            throws org.jboss.axis.AxisFault;
125
126    /**
127     * From the complex stream return the SOAP part.
128     *
129     * @return will return the root part if the stream is supported,
130     * otherwise null.
131     */

132    public Part getRootPart();
133
134    /**
135     * Sets the root part of this multipart block
136     *
137     * @param newRoot the new root <code>Part</code>
138     */

139    public void setRootPart(Part newRoot);
140
141    /**
142     * Get the content length of the stream.
143     *
144     * @return the content length of
145     * @throws org.jboss.axis.AxisFault
146     */

147    public long getContentLength() throws org.jboss.axis.AxisFault;
148
149    /**
150     * Write the content to the stream.
151     *
152     * @param os the stream
153     * @throws org.jboss.axis.AxisFault
154     */

155    public void writeContentToStream(java.io.OutputStream JavaDoc os)
156            throws org.jboss.axis.AxisFault;
157
158    /**
159     * Write the content to the stream.
160     *
161     * @return the content type
162     * @throws org.jboss.axis.AxisFault
163     */

164    public String JavaDoc getContentType() throws org.jboss.axis.AxisFault;
165
166    /**
167     * This is the number of attachments.
168     *
169     * @return the number of attachments
170     */

171    public int getAttachmentCount();
172
173    /**
174     * Determine if an object is to be treated as an attchment.
175     *
176     * @param value the value that is to be determined if
177     * its an attachment.
178     * @return True if value should be treated as an attchment.
179     */

180    public boolean isAttachment(Object JavaDoc value);
181
182
183    /**
184     * Use the default attatchment send type.
185     */

186    public final int SEND_TYPE_NOTSET = 1;
187
188    /**
189     * Use the SOAP with MIME attatchment send type.
190     */

191    public final int SEND_TYPE_MIME = 2; //use mime
192

193    /**
194     * Use the DIME attatchment type.
195     */

196    public final int SEND_TYPE_DIME = 3; //use dime;
197

198    /**
199     * Use the DIME attatchment type.
200     */

201    public final int SEND_TYPE_NONE = 4; //don't send as attachments
202

203    final int SEND_TYPE_MAX = 4;
204
205    /**
206     * The default attatchment type. MIME
207     */

208    final int SEND_TYPE_DEFAULT = SEND_TYPE_MIME;
209
210    /**
211     * The prefix used to assoc. attachments as content-id
212     */

213    public final String JavaDoc CIDprefix = "cid:";
214
215    /**
216     * Set the format for attachments.
217     *
218     * @param sendtype the format to send.
219     * SEND_TYPE_MIME for Multipart Releated Mail type attachments.
220     * SEND_TYPE_DIME for DIME type attachments.
221     */

222
223    public void setSendType(int sendtype);
224
225    /**
226     * Determine if an object is to be treated as an attchment.
227     *
228     * @return SEND_TYPE_MIME, SEND_TYPE_DIME, SEND_TYPE_NOTSET
229     */

230
231    public int getSendType();
232
233    /**
234     * dispose of the attachments and their files; do not use the object
235     * after making this call.
236     */

237
238    public void dispose();
239 }
Popular Tags