org.entityfs
Interface DataSink

All Known Subinterfaces:
RandomAccess
All Known Implementing Classes:
ByteArrayRandomAccess, DataInputOutputRandomAccessAdapter, EmptyRandomAccess, InputStreamBackedRandomAccess, LockAwareRandomAccess, OutputStreamToDataSinkAdapter, RandomAccessAdapter, RandomAccessToDataInputOutputAdapter, RangeRandomAccess, TempFileBackedRandomAccess

public interface DataSink

This interface defines a sink for data, i.e. something that data can be written to.

An OutputStream can be adapted to a data sink using the OutputStreamToDataSinkAdapter.

Since:
1.1
Author:
Karl Gustafsson
See Also:
DataSource

Method Summary
 void close()
          Close the sink and free all resources associated with it.
 void flush()
          Flush changes made to the sink to the underlying storage.
 void write(byte[] barr)
          Write the contents of the array to the sink, starting at the current file pointer.
 void write(byte[] barr, int off, int len)
          Write len bytes from the array, starting at the offset off to this sink.
 void write(int b)
          Write a byte to the sink.
 

Method Detail

write

void write(byte[] barr)
           throws ReadOnlyException,
                  IllegalStateException,
                  WrappedIOException
Write the contents of the array to the sink, starting at the current file pointer.

Parameters:
barr - The array to write.
Throws:
ReadOnlyException - If the sink is opened read only.
IllegalStateException - If the sink is closed.
WrappedIOException - On I/O errors.

write

void write(byte[] barr,
           int off,
           int len)
           throws ReadOnlyException,
                  IllegalStateException,
                  WrappedIOException
Write len bytes from the array, starting at the offset off to this sink.

Parameters:
barr - The byte array.
off - The starting offset in the array.
len - The number of bytes to write.
Throws:
ReadOnlyException - If the sink is opened read only.
IllegalStateException - If the sink file is closed.
WrappedIOException - On I/O errors.

write

void write(int b)
           throws ReadOnlyException,
                  IllegalStateException,
                  WrappedIOException
Write a byte to the sink.

Parameters:
b - The byte to write.
Throws:
ReadOnlyException - If the sink is opened read only.
IllegalStateException - If the random access file is closed.
WrappedIOException - On I/O errors.

flush

void flush()
           throws ReadOnlyException,
                  IllegalStateException,
                  WrappedIOException
Flush changes made to the sink to the underlying storage. This is optional to implement, but read only sinks should always throw ReadOnlyException.

Throws:
ReadOnlyException - If the sink is opened read only.
IllegalStateException - If the sink is closed.
WrappedIOException - On I/O errors.

close

void close()
           throws WrappedIOException
Close the sink and free all resources associated with it. If the object is already closed, this method does nothing.

Throws:
WrappedIOException - On I/O errors.