fiftyone.mobile.detection.entities.stream
Class Source

java.lang.Object
  extended by fiftyone.mobile.detection.entities.stream.Source
All Implemented Interfaces:
Disposable

public class Source
extends Object
implements Disposable

Encapsulates either a byte array or a file containing the uncompressed data structures used by the data set.

Must be disposed to ensure that the readers are closed and the file free for other uses. Does not need to be disposed if a byte array is used.


Field Summary
private  byte[] data
           
private  FileInputStream fileInputStream
           
 
Constructor Summary
Source(byte[] data)
           
Source(String filename)
           
 
Method Summary
private  ByteBuffer createByteBuffer()
           
private  MappedByteBuffer createMappedByteBuffer()
           
 BinaryReader createReader()
          Creates a new reader and stores a reference to it.
 void dispose()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fileInputStream

private final FileInputStream fileInputStream

data

private final byte[] data
Constructor Detail

Source

public Source(String filename)
       throws FileNotFoundException
Throws:
FileNotFoundException

Source

public Source(byte[] data)
Method Detail

dispose

public void dispose()
Specified by:
dispose in interface Disposable

createReader

public BinaryReader createReader()
                          throws IOException
Creates a new reader and stores a reference to it.

Returns:
A reader open for read access to the stream
Throws:
IOException

createByteBuffer

private ByteBuffer createByteBuffer()
                             throws IOException
Throws:
IOException

createMappedByteBuffer

private MappedByteBuffer createMappedByteBuffer()
                                         throws IOException
Throws:
IOException