Sharkysoft home

lava.riff
Class RiffInputFile

java.lang.Object
  |
  +--lava.riff.RiffInputFile

public class RiffInputFile
extends java.lang.Object
implements IRiffInput

File-based RIFF data source.

Details: This class is a file-based implementation of IRiffInput.

Since:
1999.09.24
Version:
1999.09.24
Author:
Sharky

Constructor Summary
RiffInputFile(java.io.File file)
          Binds to file.
 
Method Summary
 void close()
          Closes input source.
 void free(long offset, long amount)
          Unbuffers bytes.
 long getLength()
          Returns file length.
 long getPosition()
          Returns read offset.
 int read()
          Reads byte.
 int read(byte[] dest, int offset, int amount)
          Reads BYTEs.
 int read(int[] dest, int offset, int amount)
          Reads DWORDs.
 int read(short[] dest, int offset, int amount)
          Reads WORDs.
 void setPosition(long newpos)
          Sets read offset.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RiffInputFile

public RiffInputFile(java.io.File file)
              throws java.io.IOException
Binds to file.

Details: This constructor initializes a new instance to read from the given file (file).

Parameters:
file - the input file
Method Detail

getLength

public long getLength()
               throws java.io.IOException
Description copied from interface: IRiffInput
Returns file length.

Details: This method returns the length of the RIFF file, if it is known, or -1 otherwise.

Specified by:
getLength in interface IRiffInput
Tags copied from interface: IRiffInput
Returns:
the length

getPosition

public long getPosition()
                 throws java.io.IOException
Description copied from interface: IRiffInput
Returns read offset.

Details: This method returns the read offset, or the position of the next byte to be read. The position reported may be greater than the length of the stream if it was previously set to be so. (See setPosition.)

Specified by:
getPosition in interface IRiffInput
Tags copied from interface: IRiffInput
Returns:
the position

setPosition

public void setPosition(long newpos)
                 throws java.io.IOException
Description copied from interface: IRiffInput
Sets read offset.

Details: This method sets the read offset, or the position of the next byte to be read, to newpos. Setting the position to a value greater than the length of the file is legal, and will not cause an error unless a read is subsequently attempted from that position.

Specified by:
setPosition in interface IRiffInput
Tags copied from interface: IRiffInput
Parameters:
newpos - the new position

read

public int read()
         throws java.io.IOException
Description copied from interface: IRiffInput
Reads byte.

Details: This method reads and returns the next BYTE, i.e., the BYTE pointed to by the read offset. The read offset is automatically incremented by 1. The BYTE is zero-extended into an int before it is returned. If a BYTE could not be read because the end of the data source was reached, -1 is returned.

Specified by:
read in interface IRiffInput
Tags copied from interface: IRiffInput
Returns:
the byte

read

public int read(byte[] dest,
                int offset,
                int amount)
         throws java.io.IOException
Description copied from interface: IRiffInput
Reads BYTEs.

Details: This method reads a consecutive run of BYTEs from the data source, beginning with the BYTE at the current position. The BYTEs are stored in dest beginning at the given offset (offset). Up to amount BYTEs are read and stored, but the actual number of BYTEs read may be less if the end of the sequence is reached. If BYTEs are read, the number of BYTEs read is returned, but if no BYTEs can be read, -1 is returned. The read offset is automatically advanced by the number of BYTEs read.

Specified by:
read in interface IRiffInput
Tags copied from interface: IRiffInput
Parameters:
dest - the destination array
offset - offset into dest
amount - number of bytes to read
Returns:
actual number of bytes read

read

public int read(short[] dest,
                int offset,
                int amount)
         throws java.io.IOException
Description copied from interface: IRiffInput
Reads WORDs.

Details: This method reads a consecutive run of little-endian WORDs, or 16-bit integers, from the data source, beginning with the WORD at the current position. The WORDs are stored in dest beginning at the given offset (offset). Up to amount WORDs are read and stored, but the actual number of WORDs read may be less if the end of the sequence is reached. If WORDs are read, the number of WORDs read is returned, but if no WORDs can be read, -1 is returned. The read offset is automatically advanced by the number of BYTEs read.

Specified by:
read in interface IRiffInput
Tags copied from interface: IRiffInput
Parameters:
dest - the destination array
offset - offset into dest
amount - number of bytes to read
Returns:
actual number of bytes read

read

public int read(int[] dest,
                int offset,
                int amount)
         throws java.io.IOException
Description copied from interface: IRiffInput
Reads DWORDs.

Details: This method reads a consecutive run of little-endian DWORDs, or 32-bit integers, from the data source, beginning with the DWORD at the current position. The DWORDs are stored in dest beginning at the given offset (offset). Up to amount DWORDs are read and stored, but the actual number of DWORDs read may be less if the end of the sequence is reached. If DWORDs are read, the number of DWORDs read is returned, but if no DWORDs can be read, -1 is returned. The read offset is automatically advanced by the number of BYTEs read.

Specified by:
read in interface IRiffInput
Tags copied from interface: IRiffInput
Parameters:
dest - the destination array
offset - offset into dest
amount - number of bytes to read
Returns:
actual number of bytes read

free

public void free(long offset,
                 long amount)
Description copied from interface: IRiffInput
Unbuffers bytes.

Details: This method advises this implementation that the given range of bytes can be unbuffered because the consumer has no need to read them again. Revisiting segments of this data source after they have been freed can cause an exception, return incorrect data, or simply cause undetected, unpredictable results.

Specified by:
free in interface IRiffInput
Tags copied from interface: IRiffInput
Parameters:
offset - the position of the forgettable segment
amount - the length of the forgettable segment

close

public void close()
           throws java.io.IOException
Description copied from interface: IRiffInput
Closes input source.

Details: close closes this data source and releases associated resources. Calling any of the other methods after close may produce unpredictable results or generate an exception.

Specified by:
close in interface IRiffInput

Sharkysoft home