com.tuneology.avm.media
Class MediaBuffer

java.lang.Object
  |
  +--com.tuneology.avm.media.MediaBuffer
All Implemented Interfaces:
MediaData

public class MediaBuffer
extends java.lang.Object
implements MediaData

This class implements an in-memory implementation of the MediaData interface.

Version:
$Id: MediaBuffer.java,v 1.2 2003/03/19 02:26:07 xnarf Exp $
Author:
Fran Taylor

Constructor Summary
MediaBuffer(java.io.InputStream str)
           
MediaBuffer(long sz, MediaProperties p)
           
 
Method Summary
 boolean canSeek()
          Returns true if the file is capable of seeking.
 void close()
           
 java.io.File getFile()
          Returns a File object by which the contents can be read.
 long getFilePointer()
          Returns the current position in the file.
 java.lang.String getPath()
          Returns the pathname of the file if it has one, blank otherwise.
 MediaProperties getProperties()
           
 boolean isStream()
          Returns true if the source is a stream of indefinate length.
 long length()
          Returns the length of the file.
 int read(byte[] b, int off, int len)
           
 void releaseFile(java.io.File f)
          Deletes the contents of the file if it's a temp file.
 void seek(long pos)
          Moves the current position in the file.
 void setLength(long newLength)
           
 void write(byte[] b, int off, int len)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MediaBuffer

public MediaBuffer(long sz,
                   MediaProperties p)
Parameters:
sz - the initial size of the buffer

MediaBuffer

public MediaBuffer(java.io.InputStream str)
Parameters:
str - the initial contents of the buffer
Method Detail

getProperties

public MediaProperties getProperties()
Specified by:
getProperties in interface MediaData

getPath

public java.lang.String getPath()
Description copied from interface: MediaData
Returns the pathname of the file if it has one, blank otherwise.
Specified by:
getPath in interface MediaData
Following copied from interface: com.tuneology.avm.media.MediaData
Returns:
the pathname of the file if it has one, blank otherwise.

getFile

public java.io.File getFile()
                     throws java.io.IOException
Description copied from interface: MediaData
Returns a File object by which the contents can be read. This can be a temporary file, if necessary. Not allowed if the source is a stream.
Specified by:
getFile in interface MediaData
Throws:
java.io.IOException -  

releaseFile

public void releaseFile(java.io.File f)
                 throws java.io.IOException
Description copied from interface: MediaData
Deletes the contents of the file if it's a temp file.
Specified by:
releaseFile in interface MediaData
Throws:
java.io.IOException -  

isStream

public boolean isStream()
Returns true if the source is a stream of indefinate length.
Specified by:
isStream in interface MediaData
Returns:
true if the source is a stream of indefinate length.

length

public long length()
            throws java.io.IOException
Description copied from interface: MediaData
Returns the length of the file.
Specified by:
length in interface MediaData
Returns:
the length of the file.
Throws:
java.io.IOException -  

canSeek

public boolean canSeek()
Returns true if the file is capable of seeking.
Specified by:
canSeek in interface MediaData

seek

public void seek(long pos)
          throws java.io.IOException
Description copied from interface: MediaData
Moves the current position in the file.
Specified by:
seek in interface MediaData
Parameters:
pos -  
Throws:
java.io.IOException -  

getFilePointer

public long getFilePointer()
                    throws java.io.IOException
Returns the current position in the file.
Specified by:
getFilePointer in interface MediaData
Returns:
the current position in the file.
Throws:
java.io.IOException -  

setLength

public void setLength(long newLength)
               throws java.io.IOException
Specified by:
setLength in interface MediaData
Parameters:
newLength -  
Throws:
java.io.IOException -  

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Specified by:
read in interface MediaData
Parameters:
b -  
off -  
len -  
Throws:
java.io.IOException -  

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Specified by:
write in interface MediaData
Throws:
java.io.IOException -  

close

public void close()
           throws java.io.IOException
Specified by:
close in interface MediaData
Throws:
java.io.IOException -