< prev index next >
src/java.desktop/share/classes/javax/imageio/stream/MemoryCacheImageInputStream.java
Print this page
*** 30,47 ****
import com.sun.imageio.stream.StreamFinalizer;
import sun.java2d.Disposer;
import sun.java2d.DisposerRecord;
/**
! * An implementation of <code>ImageInputStream</code> that gets its
! * input from a regular <code>InputStream</code>. A memory buffer is
* used to cache at least the data between the discard position and
* the current read position.
*
* <p> In general, it is preferable to use a
! * <code>FileCacheImageInputStream</code> when reading from a regular
! * <code>InputStream</code>. This class is provided for cases where
* it is not possible to create a writable temporary file.
*
*/
public class MemoryCacheImageInputStream extends ImageInputStreamImpl {
--- 30,47 ----
import com.sun.imageio.stream.StreamFinalizer;
import sun.java2d.Disposer;
import sun.java2d.DisposerRecord;
/**
! * An implementation of {@code ImageInputStream} that gets its
! * input from a regular {@code InputStream}. A memory buffer is
* used to cache at least the data between the discard position and
* the current read position.
*
* <p> In general, it is preferable to use a
! * {@code FileCacheImageInputStream} when reading from a regular
! * {@code InputStream}. This class is provided for cases where
* it is not possible to create a writable temporary file.
*
*/
public class MemoryCacheImageInputStream extends ImageInputStreamImpl {
*** 54,70 ****
/** The DisposerRecord that resets the underlying MemoryCache. */
private final DisposerRecord disposerRecord;
/**
! * Constructs a <code>MemoryCacheImageInputStream</code> that will read
! * from a given <code>InputStream</code>.
*
! * @param stream an <code>InputStream</code> to read from.
*
! * @exception IllegalArgumentException if <code>stream</code> is
! * <code>null</code>.
*/
public MemoryCacheImageInputStream(InputStream stream) {
if (stream == null) {
throw new IllegalArgumentException("stream == null!");
}
--- 54,70 ----
/** The DisposerRecord that resets the underlying MemoryCache. */
private final DisposerRecord disposerRecord;
/**
! * Constructs a {@code MemoryCacheImageInputStream} that will read
! * from a given {@code InputStream}.
*
! * @param stream an {@code InputStream} to read from.
*
! * @exception IllegalArgumentException if {@code stream} is
! * {@code null}.
*/
public MemoryCacheImageInputStream(InputStream stream) {
if (stream == null) {
throw new IllegalArgumentException("stream == null!");
}
*** 124,175 ****
super.flushBefore(pos); // this will call checkClosed() for us
cache.disposeBefore(pos);
}
/**
! * Returns <code>true</code> since this
! * <code>ImageInputStream</code> caches data in order to allow
* seeking backwards.
*
! * @return <code>true</code>.
*
* @see #isCachedMemory
* @see #isCachedFile
*/
public boolean isCached() {
return true;
}
/**
! * Returns <code>false</code> since this
! * <code>ImageInputStream</code> does not maintain a file cache.
*
! * @return <code>false</code>.
*
* @see #isCached
* @see #isCachedMemory
*/
public boolean isCachedFile() {
return false;
}
/**
! * Returns <code>true</code> since this
! * <code>ImageInputStream</code> maintains a main memory cache.
*
! * @return <code>true</code>.
*
* @see #isCached
* @see #isCachedFile
*/
public boolean isCachedMemory() {
return true;
}
/**
! * Closes this <code>MemoryCacheImageInputStream</code>, freeing
! * the cache. The source <code>InputStream</code> is not closed.
*/
public void close() throws IOException {
super.close();
disposerRecord.dispose(); // this resets the MemoryCache
stream = null;
--- 124,175 ----
super.flushBefore(pos); // this will call checkClosed() for us
cache.disposeBefore(pos);
}
/**
! * Returns {@code true} since this
! * {@code ImageInputStream} caches data in order to allow
* seeking backwards.
*
! * @return {@code true}.
*
* @see #isCachedMemory
* @see #isCachedFile
*/
public boolean isCached() {
return true;
}
/**
! * Returns {@code false} since this
! * {@code ImageInputStream} does not maintain a file cache.
*
! * @return {@code false}.
*
* @see #isCached
* @see #isCachedMemory
*/
public boolean isCachedFile() {
return false;
}
/**
! * Returns {@code true} since this
! * {@code ImageInputStream} maintains a main memory cache.
*
! * @return {@code true}.
*
* @see #isCached
* @see #isCachedFile
*/
public boolean isCachedMemory() {
return true;
}
/**
! * Closes this {@code MemoryCacheImageInputStream}, freeing
! * the cache. The source {@code InputStream} is not closed.
*/
public void close() throws IOException {
super.close();
disposerRecord.dispose(); // this resets the MemoryCache
stream = null;
< prev index next >