Mercurial > hg > digilib-old
diff common/src/main/java/digilib/io/ImageCacheStream.java @ 903:7779b37d1d05
refactored into maven modules per servlet type.
can build servlet-api 2.3 and 3.0 via profile now!
author | robcast |
---|---|
date | Tue, 26 Apr 2011 20:24:31 +0200 |
parents | servlet/src/main/java/digilib/io/ImageCacheStream.java@ba1eb2d821a2 |
children | 28d007673346 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/src/main/java/digilib/io/ImageCacheStream.java Tue Apr 26 20:24:31 2011 +0200 @@ -0,0 +1,49 @@ +/** + * + */ +package digilib.io; + +import java.io.InputStream; + +import javax.imageio.stream.ImageInputStream; +import javax.imageio.stream.MemoryCacheImageInputStream; + +/** + * @author casties + * + */ +public class ImageCacheStream extends ImageStream { + + public ImageCacheStream(InputStream stream, String mimeType) { + super(stream, mimeType); + } + + /* + * (non-Javadoc) + * + * @see digilib.io.ImageInput#hasImageInputStream() + */ + @Override + public boolean hasImageInputStream() { + return true; + } + + /* + * (non-Javadoc) + * + * @see digilib.io.ImageInput#getImageInputStream() + */ + @Override + public ImageInputStream getImageInputStream() { + /* + * TODO: which type of stream backing? + * In general, it is preferable to + * use a FileCacheImageInputStream when reading from a regular + * InputStream. This class is provided for cases where it is not + * possible to create a writable temporary file. + */ + ImageInputStream iis = new MemoryCacheImageInputStream(this.stream); + return iis; + } + +}