1. /*
  2. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  3. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  4. */
  5. package javax.activation;
  6. import java.io.InputStream;
  7. import java.io.OutputStream;
  8. import java.io.IOException;
  9. /**
  10. * The DataSource interface provides the JavaBeans Activation Framework
  11. * with an abstraction of some arbitrary collection of data. It
  12. * provides a type for that data as well as access
  13. * to it in the form of <code>InputStreams</code> and
  14. * <code>OutputStreams</code> where appropriate.
  15. */
  16. public interface DataSource {
  17. /**
  18. * This method returns an <code>InputStream</code> representing the
  19. * the data and throws the appropriate exception if it can
  20. * not do so. Note that a new <code>InputStream</code> object must be
  21. * returned each time this method is called, and the stream must be
  22. * positioned at the beginning of the data.
  23. *
  24. * @return an InputStream
  25. */
  26. public InputStream getInputStream() throws IOException;
  27. /**
  28. * This method returns an <code>OutputStream</code> where the
  29. * data can be written and throws the appropriate exception if it can
  30. * not do so. Note that a new <code>OutputStream</code> object must
  31. * be returned each time this method is called, and the stream must
  32. * be positioned at the location the data is to be written.
  33. *
  34. * @return an OutputStream
  35. */
  36. public OutputStream getOutputStream() throws IOException;
  37. /**
  38. * This method returns the MIME type of the data in the form of a
  39. * string. It should always return a valid type. It is suggested
  40. * that getContentType return "application/octet-stream" if the
  41. * DataSource implementation can not determine the data type.
  42. *
  43. * @return the MIME Type
  44. */
  45. public String getContentType();
  46. /**
  47. * Return the <i>name</i> of this object where the name of the object
  48. * is dependant on the nature of the underlying objects. DataSources
  49. * encapsulating files may choose to return the filename of the object.
  50. * (Typically this would be the last component of the filename, not an
  51. * entire pathname.)
  52. *
  53. * @return the name of the object.
  54. */
  55. public String getName();
  56. }