|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.icepdf.core.util.ByteCache
public class ByteCache
The ByteCache class is designed to cache a byte array input
to file when a specified size has been reached (Cached). This cached byte
stream can be read from file when the byte array is needed by a program.
ByteCache creates a temporary file in the users temporary
directory and the file is deleted when the application is closed or when
the deleteFileCache is called.
File caching can be forced by calling the forceByteCaching() method, but
caching is normally done automatically when the byteArray reaches a
specified length. The length is specified by the system property
org.icepdf.core.util.byteFileCachingSize where the associated value is byte
array length in which the byte array will be cached to a temporary file.
Every time a new bye cache is created the full path to the file
is recored in the CacheManager class which allows the CacheManager to delete
a documents cached bytes when the document is closed.
| Constructor Summary | |
|---|---|
ByteCache(byte[] bytes,
Library library)
Creates a new instance of ByteCache object. |
|
ByteCache(int numNewBytes,
Library library)
Creates a new instance of ByteCache object. |
|
| Method Summary | |
|---|---|
void |
close()
Closes this file input stream and releases any system resources associated with the stream. |
void |
deleteFileCache()
Dispose of temp file and bytes array. |
void |
dispose(boolean cache)
Dispose this objects internal references and free up any available memory. |
void |
forceByteCaching()
Forces the caching of byte array to a temp file. |
int |
getLength()
Gets the length of the byte array stored in this byte cache. |
boolean |
inMemory()
|
boolean |
isCached()
Return if this byte cache has stored its byte data in a a temp file. |
int |
readByte()
Reads a byte of data from this input stream. |
int |
readBytes(byte[] bytes)
Reads up to bytes.length bytes of data from this input
stream into an array of bytes. |
int |
readBytes(byte[] bytes,
int offset,
int length)
Reads up to length bytes of data from this byte cache
into an array of bytes. |
void |
reset()
Resets the buffer to the marked position. |
byte[] |
toByteArray()
Creates a newly allocated byte array. |
void |
writeBytes(byte[] bytes)
Writes bytes.length bytes from the specified byte array
to this byte cache.. |
void |
writeBytes(byte[] bytes,
int offset,
int numNewBytes)
Writes length bytes from the specified byte array
starting at offset offset to this byte cache. |
void |
writeBytes(java.io.InputStream in,
int numNewBytes)
Writes length bytes from the specified byte array
starting at offset offset to this byte cache. |
void |
writeBytes(int bytes)
Writes the specified byte to this byte cache. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ByteCache(byte[] bytes,
Library library)
ByteCache object.
bytes - bytes that will be stored in ByteCache .
public ByteCache(int numNewBytes,
Library library)
ByteCache object. This is an empty
place holder for a byte stream. The length value will be used to pre
determine if a temp file will be created even though no data has been
cached.
numNewBytes - estimated length of a byte array that will be read at a
later instnace.| Method Detail |
|---|
public void writeBytes(java.io.InputStream in,
int numNewBytes)
length bytes from the specified byte array
starting at offset offset to this byte cache.
in - InputStream which holds the data.numNewBytes - the number of bytes to write.
public void writeBytes(byte[] bytes,
int offset,
int numNewBytes)
length bytes from the specified byte array
starting at offset offset to this byte cache.
bytes - the data.offset - the start offset in the data.numNewBytes - the number of bytes to write.public void writeBytes(byte[] bytes)
bytes.length bytes from the specified byte array
to this byte cache..
bytes - the data.public void writeBytes(int bytes)
bytes - the byte to be written.
public int readBytes(byte[] bytes,
int offset,
int length)
length bytes of data from this byte cache
into an array of bytes. This method blocks until some input is
available.
bytes - the buffer into which the data is read.offset - the start offset of the data.length - the maximum number of bytes read.
-1 if there is no more data because the end of
the file has been reached.public int readBytes(byte[] bytes)
bytes.length bytes of data from this input
stream into an array of bytes. This method blocks until some input
is available.
bytes - the buffer into which the data is read.
-1 if there is no more data because the end of
the file has been reached.public int readByte()
-1 if the end of the
file is reached.public void forceByteCaching()
public void dispose(boolean cache)
cache - Whether to make it so we can continue to use this object laterpublic byte[] toByteArray()
public void deleteFileCache()
public void close()
public void reset()
public boolean isCached()
public int getLength()
public boolean inMemory()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||