Converted media Interface to use streams (Java IO) instead of byte buffers of
[mir.git] / source / mir / media / MirMedia.java
index 0431e9b..7851d90 100755 (executable)
@@ -1,12 +1,40 @@
 /*
- * put your module comment here
+ * Copyright (C) 2001, 2002  The Mir-coders group
  *
+ * This file is part of Mir.
+ *
+ * Mir is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Mir is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mir; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * In addition, as a special exception, The Mir-coders gives permission to link
+ * the code of this program with the com.oreilly.servlet library, any library
+ * licensed under the Apache Software License, The Sun (tm) Java Advanced
+ * Imaging library (JAI), The Sun JIMI library (or with modified versions of
+ * the above that use the same license as the above), and distribute linked
+ * combinations including the two.  You must obey the GNU General Public
+ * License in all respects for all of the code used other than the above
+ * mentioned libraries.  If you modify this file, you may extend this exception
+ * to your version of the file, but you are not obligated to do so.  If you do
+ * not wish to do so, delete this exception statement from your version.
  */
 
-
 package  mir.media;
 
 import java.util.*;
+import java.io.InputStream;
+
+import freemarker.template.SimpleList;
 
 import mir.entity.*;
 
@@ -66,39 +94,39 @@ public interface  MirMedia{
    * all the info for the specific media type itself. It's job is store the
    * Media data (content) itself, this could be on the local filesystem, in the
    * DB or even on a remote host. It then inserts the MetaData in the DB.
-   * @param uploadedData, a byte array containing the uploaded data.
+   * @param InputStream, a stream of the uploaded data.
    * @param ent, an Entity holding the media MetaData
    * @param mediaType, an Entity holding the media_table entry
    * @return boolean, success/fail
    * @see mir.entity.Entity
    */
-  public abstract boolean set (byte[] uploadedData, Entity ent,
+  public abstract void set (InputStream in, Entity ent,
                                 Entity mediaTypeEnt ) throws MirMediaException;
 
        public abstract void produce (Entity ent, Entity mediaTypeEnt ) 
     throws MirMediaException;
 
   /**
-   * Get's the media data from storage and returns it as a byte array
+   * Get's the media data from storage and returns it as an InputStream
    * Not very useful for most media types as they are stored in a file,
    * but very usefull for ones stored in the DB as it is necessary to get
    * it first before making a file out of it (in Producer*).
    * @param ent, an Entity holding the media MetaData
    * @param mediaType, an Entity holding the media_table entry
-   * @return byte[]
+   * @return java.io.InputStream
    * @see mir.entity.Entity
    */
-  public abstract byte[] get (Entity ent, Entity mediaTypeEnt)
+  public abstract InputStream getMedia (Entity ent, Entity mediaTypeEnt)
           throws MirMediaException;
 
   /**
    * Pretty much like get() above. But get's the specific Icon
    * representation. useful for media stored in the DB.
    * @param ent, an Entity holding the media MetaData
-   * @return byte[]
+   * @return java.io.InputStream
    * @see mir.entity.Entity
    */
-  public abstract byte[] getIcon (Entity ent) throws MirMediaException;
+  public abstract InputStream getIcon (Entity ent) throws MirMediaException;
 
        /**
    * gets the final content representation for the media
@@ -113,23 +141,7 @@ public interface  MirMedia{
    * @see mir.entity.Entity
    * @see mir.misc.StringUtil
    */
-  public abstract String getURL (Entity ent, Entity mediaTypeEnt)
-    throws MirMediaException;
-
-       /**
-   * gets the summary representation for the media
-   * in the form of a URL (String). Usually the URL points
-   * to some sort of an icon that previews what kind of
-   * media an article will contain.
-   * It should use the helper functions in the StringUtil class to
-   * build URL's safely, eliminating any *illegal* user input.
-   * @param ent, an Entity holding the media MetaData
-   * @param mediaTypeEnt, an Entity holding the media_table entry
-   * @return String, the url.
-   * @see mir.entity.Entity
-   * @see mir.misc.StringUtil
-   */
-  public abstract String getListView (Entity ent, Entity mediaTypeEnt)
+  public abstract SimpleList getURL (Entity ent, Entity mediaTypeEnt)
     throws MirMediaException;
 
        /**
@@ -176,7 +188,7 @@ public interface  MirMedia{
    * @return String, the icon filename.
    * @see mir.misc.MirConfig
    */
-  public abstract String getBigIcon ();
+  public abstract String getBigIconName ();
   
        /**
    * Returns the file name of the small Icon representing 
@@ -188,33 +200,40 @@ public interface  MirMedia{
    * @return String, the icon filename.
    * @see mir.misc.MirConfig
    */
-  public abstract String getTinyIcon ();
+  public abstract String getTinyIconName ();
 
        /**
    * Returns the IMG SRC "ALT" text to be used
    * for the Icon representations
    * @return String, the ALT text.
    */
-  public abstract String getIconAlt ();
+  public abstract String getIconAltName ();
 
        /**
-   * your all smart enough to figure it out.
+   * your can all figure it out.
    * @return boolean.
    */
   public abstract boolean isVideo ();
 
        /**
-   * your all smart enough to figure it out.
+   * you can all figure it out.
    * @return boolean.
    */
   public abstract boolean isAudio ();
 
        /**
-   * your all smart enough to figure it out.
+   * you can all figure it out.
    * @return boolean.
    */
   public abstract boolean isImage ();
 
+  /**
+   * returns a brief text dscription of what this
+   * media type is.
+   * @return String
+   */
+  public abstract String getDescr (Entity mediaTypeEnt);
+
 }