Sharkysoft home

lava.riff
Class RiffOutputFile

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

public class RiffOutputFile
extends java.lang.Object
implements IRiffOutput

File-based RIFF data sink.

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

Since:
1999.09.24
Version:
1999.09.24
Author:
Sharky

Constructor Summary
RiffOutputFile(java.io.File dest)
          Binds to file.
 
Method Summary
 void close()
          Closes stream.
 void commit(long pos)
          Commits BYTEs.
 long getLength()
          Returns stream length.
 long getPosition()
          Returns write offset.
 void setLength(long newlen)
          Sets stream length.
 void setPosition(long pos)
          Sets write offset.
 void write(byte[] src, int offset, int amount)
          Writes BYTEs.
 void write(int c)
          Writes BYTE.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RiffOutputFile

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

Details: This constructor initializes a new instance to write data to the given file (file). If the destination file exists, it will be deleted.

Parameters:
file - the input file
Method Detail

setLength

public void setLength(long newlen)
               throws java.io.IOException
Description copied from interface: IRiffOutput
Sets stream length.

Details: This method sets the length of this stream to length. Declaring the stream's length in advance can help some implementations perform more efficiently and should be done whenever possible. It is illegal to call setLength with a length value that is less than the current flush pointer. If the sequence is closed before length bytes are written, the implementation may choose unpredictable values for the remaining bytes.

Specified by:
setLength in interface IRiffOutput
Tags copied from interface: IRiffOutput
Parameters:
length - the new length of this stream

getLength

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

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

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

setPosition

public void setPosition(long pos)
                 throws java.io.IOException
Description copied from interface: IRiffOutput
Sets write offset.

Details: This method sets the write offset, or the offset of the next BYTE to be written. If the new offset is less than the flush pointer, an error may occur.

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

getPosition

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

Details: This method returns the offset of the next BYTE that will be written if a write method is called.

Specified by:
getPosition in interface IRiffOutput
Tags copied from interface: IRiffOutput
Returns:
the stream pointer

write

public void write(int c)
           throws java.io.IOException
Description copied from interface: IRiffOutput
Writes BYTE.

Details: This method writes a single BYTE (b) to the output stream. Only the least significant 8 bits of b are used.

Specified by:
write in interface IRiffOutput
Tags copied from interface: IRiffOutput
Parameters:
b - the byte

write

public void write(byte[] src,
                  int offset,
                  int amount)
           throws java.io.IOException
Description copied from interface: IRiffOutput
Writes BYTEs.

Details: This method writes a sequence of BYTEs to the output stream. The BYTEs are read from the source array (src) beginning at the given offset (offset). amount BYTEs are written. The write offset is advanced by the number of bytes written.

Specified by:
write in interface IRiffOutput
Tags copied from interface: IRiffOutput
Parameters:
src - the sequence of bytes
offset - offset into src
amount - number of bytes to write

commit

public void commit(long pos)
            throws java.io.IOException
Description copied from interface: IRiffOutput
Commits BYTEs.

Details: This method freezes and commits the bytes written up to the given offset (upto). The values of bytes written to this point should no longer be modified. Bytes whose offsets are less than the new commit offset which were never written may be filled with zeros or unpredictable values.

It is acceptable to call commit with an upto value that is less than the current commit offset, but doing so has no effect.

Specified by:
commit in interface IRiffOutput
Tags copied from interface: IRiffOutput
Parameters:
upto - the new commit offset

close

public void close()
           throws java.io.IOException
Description copied from interface: IRiffOutput
Closes stream.

Details: This method commits all BYTEs that are currently buffered and releases resources associated with this implementation.

Specified by:
close in interface IRiffOutput

Sharkysoft home