Methods Summary |
---|
public void | close()Closes this MemoryCacheImageInputStream , freeing
the cache. The source InputStream is not closed.
super.close();
cache.reset();
stream = null;
|
public void | flushBefore(long pos)
super.flushBefore(pos);
cache.disposeBefore(pos);
|
public boolean | isCached()Returns true since this
ImageInputStream caches data in order to allow
seeking backwards.
return true;
|
public boolean | isCachedFile()Returns false since this
ImageInputStream does not maintain a file cache.
return false;
|
public boolean | isCachedMemory()Returns true since this
ImageInputStream maintains a main memory cache.
return true;
|
public int | read()
checkClosed();
bitOffset = 0;
long thisByte = streamPos;
long pos = cache.loadFromStream(stream, streamPos+1);
if (pos >= streamPos+1) {
return cache.read(streamPos++);
} else {
return -1;
}
|
public int | read(byte[] b, int off, int len)
checkClosed();
// Will throw NullPointerException
if (off < 0 || len < 0 || off + len > b.length || off + len < 0) {
throw new IndexOutOfBoundsException
("off < 0 || len < 0 || off + len > b.length!");
}
bitOffset = 0;
if (len == 0) {
return 0;
}
long pos = cache.loadFromStream(stream, streamPos+len);
len = (int)(pos - streamPos); // In case stream ended early
if (len > 0) {
cache.read(b, off, len, streamPos);
streamPos += len;
return len;
} else {
return -1;
}
|