it.geosolutions.imageio.stream.input
Class ImageInputStreamAdapter

Object
  extended by ImageInputStreamImpl
      extended by ImageInputStreamAdapter
All Implemented Interfaces:
DataInput, ImageInputStream

public class ImageInputStreamAdapter
extends ImageInputStreamImpl

An implementation of ImageInputStream that gets its input from a regular InputStream. No buffering is performed in this adapter hence it is suitable whenever the underlying is is able to perform marking itself, like it happens for a BufferedInputStream.

In general, it is preferable to use a FileCacheImageInputStream or MemoryCacheImageInputStream when reading from a regular InputStream, but this class can help with improving perfomances in some cases.

Author:
Simone Giannecchini, GeoSolutions

Field Summary
 
Fields inherited from class ImageInputStreamImpl
bitOffset, byteOrder, flushedPos, streamPos
 
Constructor Summary
ImageInputStreamAdapter(InputStream stream)
          Constructs a nImageInputStreamAdapter that will read from a given InputStream.
 
Method Summary
 void close()
          Closes this ImageInputStreamAdapter.
static ImageInputStream getStream(InputStream stream)
           
 boolean isCached()
          Returns true since this ImageInputStream does not cache data in order to allow seeking backwards but it relies on the underlying InputStream.
 boolean isCachedFile()
          Returns false since this ImageInputStream does not maintain a eraf cache.
 boolean isCachedMemory()
          Returns false since this ImageInputStream does not maintain a main memory cache.
 void mark()
           
 int read()
           
 int read(byte[] b, int off, int len)
           
 void reset()
           
 
Methods inherited from class ImageInputStreamImpl
checkClosed, finalize, flush, flushBefore, getBitOffset, getByteOrder, getFlushedPosition, getStreamPosition, length, read, readBit, readBits, readBoolean, readByte, readBytes, readChar, readDouble, readFloat, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedInt, readUnsignedShort, readUTF, seek, setBitOffset, setByteOrder, skipBytes, skipBytes
 
Methods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageInputStreamAdapter

public ImageInputStreamAdapter(InputStream stream)
Constructs a nImageInputStreamAdapter that will read from a given InputStream.

Parameters:
is - an InputStream to read from.
Throws:
IllegalArgumentException - if is is null.
Method Detail

read

public int read()
         throws IOException
Specified by:
read in interface ImageInputStream
Specified by:
read in class ImageInputStreamImpl
Throws:
IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws IOException
Specified by:
read in interface ImageInputStream
Specified by:
read in class ImageInputStreamImpl
Throws:
IOException

isCached

public boolean isCached()
Returns true since this ImageInputStream does not cache data in order to allow seeking backwards but it relies on the underlying InputStream.

Specified by:
isCached in interface ImageInputStream
Overrides:
isCached in class ImageInputStreamImpl
Returns:
true.
See Also:
isCachedMemory(), isCachedFile()

isCachedFile

public boolean isCachedFile()
Returns false since this ImageInputStream does not maintain a eraf cache.

Specified by:
isCachedFile in interface ImageInputStream
Overrides:
isCachedFile in class ImageInputStreamImpl
Returns:
false.
See Also:
isCached(), isCachedMemory()

isCachedMemory

public boolean isCachedMemory()
Returns false since this ImageInputStream does not maintain a main memory cache.

Specified by:
isCachedMemory in interface ImageInputStream
Overrides:
isCachedMemory in class ImageInputStreamImpl
Returns:
true.
See Also:
isCached(), isCachedFile()

close

public void close()
           throws IOException
Closes this ImageInputStreamAdapter. The source InputStream is not closed.

Specified by:
close in interface ImageInputStream
Overrides:
close in class ImageInputStreamImpl
Throws:
IOException

mark

public void mark()
Specified by:
mark in interface ImageInputStream
Overrides:
mark in class ImageInputStreamImpl

reset

public void reset()
           throws IOException
Specified by:
reset in interface ImageInputStream
Overrides:
reset in class ImageInputStreamImpl
Throws:
IOException

getStream

public static final ImageInputStream getStream(InputStream stream)


Copyright © 2006-2010 GeoSolutions. All Rights Reserved.