net.sourceforge.dvb.projectx.xinput.file
Class XInputFileImpl

java.lang.Object
  |
  +--net.sourceforge.dvb.projectx.xinput.file.XInputFileImpl

public class XInputFileImpl
extends java.lang.Object
implements XInputFileIF


Constructor Summary
XInputFileImpl(java.io.File aFile)
          Create a XInputFile of type FileType.FILE.
 
Method Summary
 boolean exists()
          Checks if file exists
 java.lang.Object getConstructorParameter()
           
 FileType getFileType()
          Gets the type of this XInputFile implementation.
 java.io.InputStream getInputStream()
          Get input stream from the file. close() on stream closes XInputFile, too.
 java.io.InputStream getInputStream(long start_position)
          Get input stream from the file. close() on stream closes XInputFile, too.
 java.lang.String getName()
          Get Name of file
 java.lang.String getParent()
          Get Path of parent
 StreamInfo getStreamInfo()
           
 java.lang.String getUrl()
          Get url representation of the object.
 long lastModified()
          Time in milliseconds from the epoch.
 long length()
          Length of file in bytes.
 void randomAccessClose()
           
 long randomAccessGetFilePointer()
           
 void randomAccessOpen(java.lang.String mode)
          Opens XInputFile for random access
 int randomAccessRead()
           
 int randomAccessRead(byte[] aBuffer)
           
 int randomAccessRead(byte[] aBuffer, int aOffset, int aLength)
           
 java.lang.String randomAccessReadLine()
           
 long randomAccessReadLong()
           
 void randomAccessSeek(long aPosition)
           
 void randomAccessSingleRead(byte[] aBuffer, long aPosition)
          Convinience method for a single random read access to a input file.
 void randomAccessWrite(byte[] aBuffer)
           
 boolean rename()
          rename this file
 void setConstructorParameter(java.lang.Object obj)
           
 boolean setLastModified()
          sets Time in milliseconds from the epoch.
 void setStreamInfo(StreamInfo _streamInfo)
           
 java.lang.String toString()
          Get String representation of the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XInputFileImpl

public XInputFileImpl(java.io.File aFile)
Create a XInputFile of type FileType.FILE.
Parameters:
aFile - File data to use
Throws:
java.lang.IllegalArgumentException - If aFile is not a file
Method Detail

toString

public java.lang.String toString()
Get String representation of the object.
Specified by:
toString in interface XInputFileIF
Overrides:
toString in class java.lang.Object
Returns:
String representation of the object

setConstructorParameter

public void setConstructorParameter(java.lang.Object obj)
Specified by:
setConstructorParameter in interface XInputFileIF

getConstructorParameter

public java.lang.Object getConstructorParameter()
Specified by:
getConstructorParameter in interface XInputFileIF

getUrl

public java.lang.String getUrl()
Get url representation of the object.
Specified by:
getUrl in interface XInputFileIF
Returns:
String with url

length

public long length()
Length of file in bytes.
Specified by:
length in interface XInputFileIF
Returns:
Length of file in bytes

lastModified

public long lastModified()
Time in milliseconds from the epoch.
Specified by:
lastModified in interface XInputFileIF
Returns:
Time in milliseconds from the epoch

setLastModified

public boolean setLastModified()
sets Time in milliseconds from the epoch.
Specified by:
setLastModified in interface XInputFileIF
Returns:
Time in milliseconds from the epoch

exists

public boolean exists()
Checks if file exists
Specified by:
exists in interface XInputFileIF
Returns:
Result of check

getName

public java.lang.String getName()
Get Name of file
Specified by:
getName in interface XInputFileIF
Returns:
Name of file

getParent

public java.lang.String getParent()
Get Path of parent
Specified by:
getParent in interface XInputFileIF
Returns:
Path of parent

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.FileNotFoundException,
                                          java.net.MalformedURLException,
                                          java.io.IOException
Get input stream from the file. close() on stream closes XInputFile, too.
Specified by:
getInputStream in interface XInputFileIF
Returns:
Input stream from the file

getInputStream

public java.io.InputStream getInputStream(long start_position)
                                   throws java.io.FileNotFoundException,
                                          java.net.MalformedURLException,
                                          java.io.IOException
Get input stream from the file. close() on stream closes XInputFile, too.
Specified by:
getInputStream in interface XInputFileIF
Returns:
Input stream from the file

rename

public boolean rename()
               throws java.io.IOException
rename this file
Specified by:
rename in interface XInputFileIF
Returns:
 

randomAccessOpen

public void randomAccessOpen(java.lang.String mode)
                      throws java.io.IOException
Opens XInputFile for random access
Specified by:
randomAccessOpen in interface XInputFileIF
Parameters:
mode - Access mode as in RandomAccessFile
Throws:
java.io.IOException -  

randomAccessClose

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

randomAccessSeek

public void randomAccessSeek(long aPosition)
                      throws java.io.IOException
Specified by:
randomAccessSeek in interface XInputFileIF
Parameters:
aPosition - The offset position, measured in bytes from the beginning of the file, at which to set the file pointer.
Throws:
java.io.IOException -  

randomAccessGetFilePointer

public long randomAccessGetFilePointer()
                                throws java.io.IOException
Specified by:
randomAccessGetFilePointer in interface XInputFileIF
Returns:
@throws IOException

randomAccessRead

public int randomAccessRead()
                     throws java.io.IOException
Specified by:
randomAccessRead in interface XInputFileIF
Returns:
@throws IOException

randomAccessRead

public int randomAccessRead(byte[] aBuffer)
                     throws java.io.IOException
Specified by:
randomAccessRead in interface XInputFileIF
Parameters:
aBuffer - The buffer into which the data is read.
Returns:
@throws java.io.IOException

randomAccessRead

public int randomAccessRead(byte[] aBuffer,
                            int aOffset,
                            int aLength)
                     throws java.io.IOException
Specified by:
randomAccessRead in interface XInputFileIF
Parameters:
aBuffer - The buffer into which the data is written.
aOffset - The offset at which the data should be written.
aLength - The amount of data to be read.
Returns:
@throws IOException

randomAccessReadLine

public java.lang.String randomAccessReadLine()
                                      throws java.io.IOException
Specified by:
randomAccessReadLine in interface XInputFileIF
Returns:
Read line
Throws:
java.io.IOException -  

randomAccessWrite

public void randomAccessWrite(byte[] aBuffer)
                       throws java.io.IOException
Specified by:
randomAccessWrite in interface XInputFileIF
Parameters:
aBuffer - The data.
Throws:
java.io.IOException -  

randomAccessSingleRead

public void randomAccessSingleRead(byte[] aBuffer,
                                   long aPosition)
                            throws java.io.IOException
Convinience method for a single random read access to a input file. The file is opened before and closed after read.
Specified by:
randomAccessSingleRead in interface XInputFileIF
Parameters:
aBuffer - Buffer to fill with read bytes (up to aBuffer.length() bytes)
aPosition - Fileposition at which we want read
Throws:
java.io.IOException -  

randomAccessReadLong

public long randomAccessReadLong()
                          throws java.io.IOException
Specified by:
randomAccessReadLong in interface XInputFileIF
Returns:
Long value read.
Throws:
java.io.IOException -  

getFileType

public FileType getFileType()
Description copied from interface: XInputFileIF
Gets the type of this XInputFile implementation.
Specified by:
getFileType in interface XInputFileIF
Tags copied from interface: XInputFileIF
Returns:
FileType

setStreamInfo

public void setStreamInfo(StreamInfo _streamInfo)
Specified by:
setStreamInfo in interface XInputFileIF

getStreamInfo

public StreamInfo getStreamInfo()
Specified by:
getStreamInfo in interface XInputFileIF