1 /*
   2  * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package javax.activation;
  27 
  28 import java.io.InputStream;
  29 import java.io.OutputStream;
  30 import java.io.IOException;
  31 
  32 /**
  33  * The DataSource interface provides the JavaBeans Activation Framework
  34  * with an abstraction of an arbitrary collection of data.  It
  35  * provides a type for that data as well as access
  36  * to it in the form of <code>InputStreams</code> and
  37  * <code>OutputStreams</code> where appropriate.
  38  *
  39  * @since 1.6
  40  */
  41 
  42 public interface DataSource {
  43 
  44     /**
  45      * This method returns an <code>InputStream</code> representing
  46      * the data and throws the appropriate exception if it can
  47      * not do so.  Note that a new <code>InputStream</code> object must be
  48      * returned each time this method is called, and the stream must be
  49      * positioned at the beginning of the data.
  50      *
  51      * @return an InputStream
  52      * @exception       IOException     for failures creating the InputStream
  53      */
  54     public InputStream getInputStream() throws IOException;
  55 
  56     /**
  57      * This method returns an <code>OutputStream</code> where the
  58      * data can be written and throws the appropriate exception if it can
  59      * not do so.  Note that a new <code>OutputStream</code> object must
  60      * be returned each time this method is called, and the stream must
  61      * be positioned at the location the data is to be written.
  62      *
  63      * @return an OutputStream
  64      * @exception       IOException     for failures creating the OutputStream
  65      */
  66     public OutputStream getOutputStream() throws IOException;
  67 
  68     /**
  69      * This method returns the MIME type of the data in the form of a
  70      * string. It should always return a valid type. It is suggested
  71      * that getContentType return "application/octet-stream" if the
  72      * DataSource implementation can not determine the data type.
  73      *
  74      * @return the MIME Type
  75      */
  76     public String getContentType();
  77 
  78     /**
  79      * Return the <i>name</i> of this object where the name of the object
  80      * is dependant on the nature of the underlying objects. DataSources
  81      * encapsulating files may choose to return the filename of the object.
  82      * (Typically this would be the last component of the filename, not an
  83      * entire pathname.)
  84      *
  85      * @return the name of the object.
  86      */
  87     public String getName();
  88 }