|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--juju.reattore.io.impl.ChannelFileSource
A byte source that serves from a file using channels. Implemented by reading the whole file into a byte buffer.
Field Summary |
Fields inherited from interface juju.reattore.io.Source |
EOF |
Constructor Summary | |
ChannelFileSource(java.io.File file)
Create a new source around the given file. |
Method Summary | |
void |
dispose()
Called when the user is finished with this source. |
int |
get()
Gets the next byte from the stream. |
int |
get(byte[] into,
int offset,
int length)
Bulk get operation. |
java.nio.ByteBuffer |
getBulk()
Returns the next chunk of the source in a ByteBuffer. |
boolean |
isExpired()
Called before the source is used, and may be used to mark this source as expired and in need of re-generation. |
void |
release()
Releases this source from the cache. |
int |
remaining()
Returns the number of elements remaining in the stream. |
void |
rewind()
Resets this source into the original state. |
void |
setCacheCallback(Cache ch)
Binds this source to a cache. |
void |
setReadSize(int to)
Test method that changes the maximum size a file may be before it is chunked into parts. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ChannelFileSource(java.io.File file) throws java.io.IOException
file
- The file to wrap around.
java.io.IOException
- if the file cannot be opened.Method Detail |
public void setReadSize(int to)
to
- The maximum size in bytes.public java.nio.ByteBuffer getBulk() throws java.io.IOException
BulkByteSource
getBulk
in interface BulkByteSource
java.io.IOException
- on error.BulkByteSource
public int get() throws java.io.IOException
ByteSource
get
in interface ByteSource
java.io.IOException
- on error.ByteSource
public int get(byte[] into, int offset, int length) throws java.io.IOException
ByteSource
get
in interface ByteSource
into
- The buffer to get into.offset
- The offset in the buffer to begin writing at.length
- The maximum number of elements to read.
java.io.IOException
- on error.ByteSource
public int remaining() throws java.io.IOException
ByteSource
remaining
in interface ByteSource
java.io.IOException
- on error.ByteSource
public void release()
CachableSource
release
in interface CachableSource
CachableSource
public void dispose()
Source
dispose
in interface Source
Source
public void rewind()
CachableSource
rewind
in interface CachableSource
CachableSource
public boolean isExpired()
CachableSource
isExpired
in interface CachableSource
CachableSource
public void setCacheCallback(Cache ch)
CachableSource
setCacheCallback
in interface CachableSource
ch
- The cache to bind to.CachableSource
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |