Mercurial > hg > digilib-old
diff servlet/src/digilib/io/ImageCacheStream.java @ 590:69bc69381ac4 stream
more work on stream input and more cleanup
author | robcast |
---|---|
date | Thu, 06 Jan 2011 20:42:29 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/servlet/src/digilib/io/ImageCacheStream.java Thu Jan 06 20:42:29 2011 +0100 @@ -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; + } + +}