KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > 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.apache.axis.attachments;
17
18 import org.apache.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.apache.axis.attachments.
26  *
27  * @author Rob Jellinghaus (robj@unrealities.com)
28  * @author Rick Rineholt
29  */

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

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

52     public Part removeAttachmentPart(String JavaDoc reference)
53             throws org.apache.axis.AxisFault;
54
55     /**
56      * Removes all <CODE>AttachmentPart</CODE> objects that have
57      * been added to this <CODE>SOAPMessage</CODE> object.
58      *
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      *
70      * @throws org.apache.axis.AxisFault
71      */

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

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

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

109     public Part createAttachmentPart(Object JavaDoc part)
110             throws org.apache.axis.AxisFault;
111
112     /**
113      * Create a new attachment Part in this Message.
114      * Will actually, and always, return an AttachmentPart.
115      *
116      * @return a new attachment part
117      *
118      * @throws org.apache.axis.AxisFault
119      */

120     public Part createAttachmentPart() throws org.apache.axis.AxisFault;
121
122     /**
123      * Will the attachments of this message to that of the colleciton.
124      *
125      * @param parts
126      *
127      * @throws org.apache.axis.AxisFault
128      */

129     public void setAttachmentParts(java.util.Collection JavaDoc parts)
130             throws org.apache.axis.AxisFault;
131
132     /**
133      * From the complex stream return the SOAP part.
134      * @return will return the root part if the stream is supported,
135      * otherwise null.
136      */

137     public Part getRootPart();
138
139     /**
140      * Sets the root part of this multipart block
141      *
142      * @param newRoot the new root <code>Part</code>
143      */

144     public void setRootPart(Part newRoot);
145
146     /**
147      * Get the content length of the stream.
148      *
149      * @return the content length of
150      *
151      * @throws org.apache.axis.AxisFault
152      */

153     public long getContentLength() throws org.apache.axis.AxisFault;
154
155     /**
156      * Write the content to the stream.
157      *
158      * @param os the stream
159      *
160      * @throws org.apache.axis.AxisFault
161      */

162     public void writeContentToStream(java.io.OutputStream JavaDoc os)
163             throws org.apache.axis.AxisFault;
164
165     /**
166      * Write the content to the stream.
167      *
168      * @return the content type
169      *
170      * @throws org.apache.axis.AxisFault
171      */

172     public String JavaDoc getContentType() throws org.apache.axis.AxisFault;
173
174     /**
175      * This is the number of attachments.
176      *
177      * @return the number of attachments
178      */

179     public int getAttachmentCount();
180
181     /**
182      * Determine if an object is to be treated as an attchment.
183      *
184      * @param value the value that is to be determined if
185      * its an attachment.
186      *
187      * @return True if value should be treated as an attchment.
188      */

189     public boolean isAttachment(Object JavaDoc value);
190
191
192     /** Use the default attatchment send type. */
193     public final int SEND_TYPE_NOTSET = 1;
194
195     /** Use the SOAP with MIME attatchment send type. */
196     public final int SEND_TYPE_MIME = 2; //use mime
197

198     /** Use the DIME attatchment type. */
199     public final int SEND_TYPE_DIME= 3; //use dime;
200

201     /** Use the DIME attatchment type. */
202     public final int SEND_TYPE_NONE= 4; //don't send as attachments
203

204     final int SEND_TYPE_MAX = 4;
205
206     /** The default attatchment type. MIME */
207     final int SEND_TYPE_DEFAULT = SEND_TYPE_MIME;
208
209     /** The prefix used to assoc. attachments as content-id */
210     public final String JavaDoc CIDprefix= "cid:";
211
212     /**
213      * Set the format for attachments.
214      *
215      * @param sendtype the format to send.
216      * SEND_TYPE_MIME for Multipart Releated Mail type attachments.
217      * SEND_TYPE_DIME for DIME type attachments.
218      */

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

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

235
236     public void dispose();
237 }
238
Popular Tags