org.entityfs.util.io
Class OutputStreamToDataSinkAdapter

java.lang.Object
  extended by org.entityfs.util.io.OutputStreamToDataSinkAdapter
All Implemented Interfaces:
DataSink

public class OutputStreamToDataSinkAdapter
extends Object
implements DataSink

This object is used to adapt an OutputStream to the DataSink interface.

Since:
1.1
Author:
Karl Gustafsson
See Also:
InputStreamToDataSourceAdapter, DataSinkToOutputStreamAdapter
In_jar:
entityfs-core

Constructor Summary
OutputStreamToDataSinkAdapter(OutputStream out)
           
 
Method Summary
 void close()
          Close the sink and free all resources associated with it.
protected  void finalize()
           
 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.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OutputStreamToDataSinkAdapter

public OutputStreamToDataSinkAdapter(OutputStream out)
Method Detail

flush

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

Specified by:
flush in interface DataSink
Throws:
ReadOnlyException - If the sink is opened read only.
IllegalStateException - If the sink is closed.
WrappedIOException - On I/O errors.

write

public void write(byte[] barr)
           throws ReadOnlyException,
                  IllegalStateException,
                  WrappedIOException
Description copied from interface: DataSink
Write the contents of the array to the sink, starting at the current file pointer.

Specified by:
write in interface DataSink
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

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

Specified by:
write in interface DataSink
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

public void write(int b)
           throws ReadOnlyException,
                  IllegalStateException,
                  WrappedIOException
Description copied from interface: DataSink
Write a byte to the sink.

Specified by:
write in interface DataSink
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.

close

public void close()
           throws WrappedIOException
Description copied from interface: DataSink
Close the sink and free all resources associated with it. If the object is already closed, this method does nothing.

Specified by:
close in interface DataSink
Throws:
WrappedIOException - On I/O errors.

finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable