it.geosolutions.imageio.stream.input
Class FileImageInputStreamExtImpl

Object
  extended by ImageInputStreamImpl
      extended by FileImageInputStreamExtImpl
All Implemented Interfaces:
FileImageInputStreamExt, DataInput, ImageInputStream

public class FileImageInputStreamExtImpl
extends ImageInputStreamImpl
implements FileImageInputStreamExt

An implementation of ImageInputStream that gets its input from a File. The eraf contents are assumed to be stable during the lifetime of the object.

Author:
Simone Giannecchini, GeoSolutions

Field Summary
 
Fields inherited from class ImageInputStreamImpl
bitOffset, byteOrder, flushedPos, streamPos
 
Constructor Summary
FileImageInputStreamExtImpl(File f)
          Constructs a FileImageInputStreamExtImpl that will read from a given File.
FileImageInputStreamExtImpl(File f, int bufferSize)
          Constructs a FileImageInputStreamExtImpl that will read from a given File.
 
Method Summary
 void close()
          Closes the underlying EnhancedRandomAccessFile.
 void dispose()
          Disposes this FileImageInputStreamExtImpl by closing its underlying EnhancedRandomAccessFile.
 ByteOrder getByteOrder()
           
 File getFile()
          Retrieves the File we are connected to.
 long getStreamPosition()
           
 boolean isCached()
           
 long length()
          Returns the length of the underlying eraf, or -1 if it is unknown.
 int read()
          Reads an int from the underlying EnhancedRandomAccessFile.
 int read(byte[] b)
           
 int read(byte[] b, int off, int len)
          Read up to len bytes into an array, at a specified offset.
 byte readByte()
           
 char readChar()
           
 double readDouble()
           
 float readFloat()
           
 void readFully(byte[] b)
           
 void readFully(byte[] b, int off, int len)
           
 int readInt()
           
 String readLine()
           
 long readLong()
           
 short readShort()
           
 int readUnsignedByte()
           
 long readUnsignedInt()
           
 int readUnsignedShort()
           
 String readUTF()
           
 void seek(long pos)
          Seeks the current position to pos.
 void setByteOrder(ByteOrder byteOrder)
           
 int skipBytes(int n)
           
 long skipBytes(long n)
           
 String toString()
          Provides a simple description for this ImageInputStream.
 
Methods inherited from class ImageInputStreamImpl
checkClosed, finalize, flush, flushBefore, getBitOffset, getFlushedPosition, isCachedFile, isCachedMemory, mark, readBit, readBits, readBoolean, readBytes, readFully, readFully, readFully, readFully, readFully, readFully, reset, setBitOffset
 
Methods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ImageInputStream
flush, flushBefore, getBitOffset, getFlushedPosition, isCachedFile, isCachedMemory, mark, readBit, readBits, readBoolean, readBytes, readFully, readFully, readFully, readFully, readFully, readFully, reset, setBitOffset
 

Constructor Detail

FileImageInputStreamExtImpl

public FileImageInputStreamExtImpl(File f)
                            throws FileNotFoundException,
                                   IOException
Constructs a FileImageInputStreamExtImpl that will read from a given File.

The eraf contents must not change between the time this object is constructed and the time of the last call to a read method.

Parameters:
f - a File to read from.
Throws:
NullPointerException - if f is null.
SecurityException - if a security manager exists and does not allow read access to the eraf.
FileNotFoundException - if f is a directory or cannot be opened for reading for any other reason.
IOException - if an I/O error occurs.

FileImageInputStreamExtImpl

public FileImageInputStreamExtImpl(File f,
                                   int bufferSize)
                            throws IOException
Constructs a FileImageInputStreamExtImpl that will read from a given File.

The eraf contents must not change between the time this object is constructed and the time of the last call to a read method.

Parameters:
f - a File to read from.
bufferSize - size of the underlying buffer.
Throws:
NullPointerException - if f is null.
SecurityException - if a security manager exists and does not allow read access to the eraf.
FileNotFoundException - if f is a directory or cannot be opened for reading for any other reason.
IOException - if an I/O error occurs.
Method Detail

readByte

public byte readByte()
              throws IOException
Specified by:
readByte in interface DataInput
Specified by:
readByte in interface ImageInputStream
Overrides:
readByte in class ImageInputStreamImpl
Throws:
IOException

readChar

public char readChar()
              throws IOException
Specified by:
readChar in interface DataInput
Specified by:
readChar in interface ImageInputStream
Overrides:
readChar in class ImageInputStreamImpl
Throws:
IOException

readDouble

public double readDouble()
                  throws IOException
Specified by:
readDouble in interface DataInput
Specified by:
readDouble in interface ImageInputStream
Overrides:
readDouble in class ImageInputStreamImpl
Throws:
IOException

readFloat

public float readFloat()
                throws IOException
Specified by:
readFloat in interface DataInput
Specified by:
readFloat in interface ImageInputStream
Overrides:
readFloat in class ImageInputStreamImpl
Throws:
IOException

readFully

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

readFully

public void readFully(byte[] b)
               throws IOException
Specified by:
readFully in interface DataInput
Specified by:
readFully in interface ImageInputStream
Overrides:
readFully in class ImageInputStreamImpl
Throws:
IOException

readInt

public int readInt()
            throws IOException
Specified by:
readInt in interface DataInput
Specified by:
readInt in interface ImageInputStream
Overrides:
readInt in class ImageInputStreamImpl
Throws:
IOException

readLine

public String readLine()
                throws IOException
Specified by:
readLine in interface DataInput
Specified by:
readLine in interface ImageInputStream
Overrides:
readLine in class ImageInputStreamImpl
Throws:
IOException

getByteOrder

public ByteOrder getByteOrder()
Specified by:
getByteOrder in interface ImageInputStream
Overrides:
getByteOrder in class ImageInputStreamImpl

getStreamPosition

public long getStreamPosition()
                       throws IOException
Specified by:
getStreamPosition in interface ImageInputStream
Overrides:
getStreamPosition in class ImageInputStreamImpl
Throws:
IOException

isCached

public boolean isCached()
Specified by:
isCached in interface ImageInputStream
Overrides:
isCached in class ImageInputStreamImpl

read

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

skipBytes

public long skipBytes(long n)
               throws IOException
Specified by:
skipBytes in interface ImageInputStream
Overrides:
skipBytes in class ImageInputStreamImpl
Throws:
IOException

readLong

public long readLong()
              throws IOException
Specified by:
readLong in interface DataInput
Specified by:
readLong in interface ImageInputStream
Overrides:
readLong in class ImageInputStreamImpl
Throws:
IOException

readShort

public short readShort()
                throws IOException
Specified by:
readShort in interface DataInput
Specified by:
readShort in interface ImageInputStream
Overrides:
readShort in class ImageInputStreamImpl
Throws:
IOException

readUnsignedByte

public int readUnsignedByte()
                     throws IOException
Specified by:
readUnsignedByte in interface DataInput
Specified by:
readUnsignedByte in interface ImageInputStream
Overrides:
readUnsignedByte in class ImageInputStreamImpl
Throws:
IOException

readUnsignedInt

public long readUnsignedInt()
                     throws IOException
Specified by:
readUnsignedInt in interface ImageInputStream
Overrides:
readUnsignedInt in class ImageInputStreamImpl
Throws:
IOException

readUnsignedShort

public int readUnsignedShort()
                      throws IOException
Specified by:
readUnsignedShort in interface DataInput
Specified by:
readUnsignedShort in interface ImageInputStream
Overrides:
readUnsignedShort in class ImageInputStreamImpl
Throws:
IOException

readUTF

public String readUTF()
               throws IOException
Specified by:
readUTF in interface DataInput
Specified by:
readUTF in interface ImageInputStream
Overrides:
readUTF in class ImageInputStreamImpl
Throws:
IOException

setByteOrder

public void setByteOrder(ByteOrder byteOrder)
Specified by:
setByteOrder in interface ImageInputStream
Overrides:
setByteOrder in class ImageInputStreamImpl

skipBytes

public int skipBytes(int n)
              throws IOException
Specified by:
skipBytes in interface DataInput
Specified by:
skipBytes in interface ImageInputStream
Overrides:
skipBytes in class ImageInputStreamImpl
Throws:
IOException

read

public int read()
         throws IOException
Reads an int from the underlying EnhancedRandomAccessFile.

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
Read up to len bytes into an array, at a specified offset. This will block until at least one byte has been read.

Specified by:
read in interface ImageInputStream
Specified by:
read in class ImageInputStreamImpl
Parameters:
b - the byte array to receive the bytes.
off - the offset in the array where copying will start.
len - the number of bytes to copy.
Returns:
the actual number of bytes read, or -1 if there is not more data due to the end of the eraf being reached.
Throws:
IOException

length

public long length()
Returns the length of the underlying eraf, or -1 if it is unknown.

Specified by:
length in interface ImageInputStream
Overrides:
length in class ImageInputStreamImpl
Returns:
the eraf length as a long, or -1.

seek

public void seek(long pos)
          throws IOException
Seeks the current position to pos.

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

close

public void close()
           throws IOException
Closes the underlying EnhancedRandomAccessFile.

Specified by:
close in interface ImageInputStream
Overrides:
close in class ImageInputStreamImpl
Throws:
IOException - in case something bad happens.

getFile

public File getFile()
Retrieves the File we are connected to.

Specified by:
getFile in interface FileImageInputStreamExt
Returns:
the associated File

dispose

public void dispose()
Disposes this FileImageInputStreamExtImpl by closing its underlying EnhancedRandomAccessFile.


toString

public String toString()
Provides a simple description for this ImageInputStream.

Overrides:
toString in class Object
Returns:
a simple description for this ImageInputStream.


Copyright © 2006-2010 GeoSolutions. All Rights Reserved.