Copyright 2011-01-06 Werner Randelshofer

ch.randelshofer.media.binary
Class FileBasedBinaryModel

java.lang.Object
  extended by ch.randelshofer.media.binary.FileBasedBinaryModel
All Implemented Interfaces:
BinaryModel

public class FileBasedBinaryModel
extends java.lang.Object
implements BinaryModel

FileBasedBinaryModel.

FIXME - The file based binary model may grow infinitely large.

Version:
1.0.1 2010-05-24 Method getBytes sometimes returned invalid length.
1.0 2010-04-09 Created.
Author:
Werner Randelshofer

Constructor Summary
FileBasedBinaryModel(java.io.File file)
           
FileBasedBinaryModel(java.io.File file, long offset, long length)
           
 
Method Summary
 void close()
          Closes the model and disposes all resources.
 void finalize()
           
 int getBytes(long off, int len, byte[] target)
          Gets a sequence of bytes and copies them into the supplied byte array.
 long getLength()
          Returns the total length of the binary data.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileBasedBinaryModel

public FileBasedBinaryModel(java.io.File file)
                     throws java.io.IOException
Throws:
java.io.IOException

FileBasedBinaryModel

public FileBasedBinaryModel(java.io.File file,
                            long offset,
                            long length)
                     throws java.io.IOException
Throws:
java.io.IOException
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getLength

public long getLength()
Description copied from interface: BinaryModel
Returns the total length of the binary data.

Specified by:
getLength in interface BinaryModel

getBytes

public int getBytes(long off,
                    int len,
                    byte[] target)
Description copied from interface: BinaryModel
Gets a sequence of bytes and copies them into the supplied byte array.

Specified by:
getBytes in interface BinaryModel
Parameters:
off - the starting offset >= 0
len - the number of bytes >= 0 && <= size - offset
target - the target array to copy into

close

public void close()
Description copied from interface: BinaryModel
Closes the model and disposes all resources.

Specified by:
close in interface BinaryModel

finalize

public void finalize()
Overrides:
finalize in class java.lang.Object

Copyright 2011-01-06 Werner Randelshofer