1 /*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3 *
4 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
5 *
6 * The contents of this file are subject to the terms of either the GNU
7 * General Public License Version 2 only ("GPL") or the Common Development
8 * and Distribution License("CDDL") (collectively, the "License"). You
9 * may not use this file except in compliance with the License. You can obtain
10 * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
11 * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
12 * language governing permissions and limitations under the License.
13 *
14 * When distributing the software, include this License Header Notice in each
15 * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
16 * Sun designates this particular file as subject to the "Classpath" exception
17 * as provided by Sun in the GPL Version 2 section of the License file that
18 * accompanied this code. If applicable, add the following below the License
19 * Header, with the fields enclosed by brackets [] replaced by your own
20 * identifying information: "Portions Copyrighted [year]
21 * [name of copyright owner]"
22 *
23 * Contributor(s):
24 *
25 * If you wish your version of this file to be governed by only the CDDL or
26 * only the GPL Version 2, indicate your decision by adding "[Contributor]
27 * elects to include this software in this distribution under the [CDDL or GPL
28 * Version 2] license." If you don't indicate a single choice of license, a
29 * recipient has the option to distribute your version of this file under
30 * either the CDDL, the GPL Version 2 or to extend the choice of license to
31 * its licensees as provided above. However, if you add GPL Version 2 code
32 * and therefore, elected the GPL Version 2 license, then the option applies
33 * only if the new code is made subject to such option by the copyright
34 * holder.
35 */
36
37 /*
38 * @(#)DataSource.java 1.12 07/05/14
39 */
40
41 package javax.activation;
42
43 import java.io.InputStream;
44 import java.io.OutputStream;
45 import java.io.IOException;
46
47 /**
48 * The DataSource interface provides the JavaBeans Activation Framework
49 * with an abstraction of an arbitrary collection of data. It
50 * provides a type for that data as well as access
51 * to it in the form of <code>InputStreams</code> and
52 * <code>OutputStreams</code> where appropriate.
53 */
54
55 public interface DataSource {
56
57 /**
58 * This method returns an <code>InputStream</code> representing
59 * the data and throws the appropriate exception if it can
60 * not do so. Note that a new <code>InputStream</code> object must be
61 * returned each time this method is called, and the stream must be
62 * positioned at the beginning of the data.
63 *
64 * @return an InputStream
65 */
66 public InputStream getInputStream() throws IOException;
67
68 /**
69 * This method returns an <code>OutputStream</code> where the
70 * data can be written and throws the appropriate exception if it can
71 * not do so. Note that a new <code>OutputStream</code> object must
72 * be returned each time this method is called, and the stream must
73 * be positioned at the location the data is to be written.
74 *
75 * @return an OutputStream
76 */
77 public OutputStream getOutputStream() throws IOException;
78
79 /**
80 * This method returns the MIME type of the data in the form of a
81 * string. It should always return a valid type. It is suggested
82 * that getContentType return "application/octet-stream" if the
83 * DataSource implementation can not determine the data type.
84 *
85 * @return the MIME Type
86 */
87 public String getContentType();
88
89 /**
90 * Return the <i>name</i> of this object where the name of the object
91 * is dependant on the nature of the underlying objects. DataSources
92 * encapsulating files may choose to return the filename of the object.
93 * (Typically this would be the last component of the filename, not an
94 * entire pathname.)
95 *
96 * @return the name of the object.
97 */
98 public String getName();
99 }