org.umber.catalan.process.workers.io
Class IOAdapter

java.lang.Object
  extended byorg.umber.catalan.process.workers.io.IOAdapter

public class IOAdapter
extends java.lang.Object

Convenience class for converting I/O classes from one interface to another, for example a Reader into an InputStream.

Author:
jsheets

Constructor Summary
IOAdapter(java.lang.Object io)
          Creates a new instance of IOAdapter.
 
Method Summary
 java.io.File asFile()
          Converts the wrapped object into an File object.
 java.io.InputStream asInputStream()
          Converts the wrapped object into an InputStream object.
 java.io.OutputStream asOutputStream()
          Converts the wrapped object into an OutputStream object.
 java.io.OutputStream asOutputStream(boolean append)
          Converts the wrapped object into an OutputStream object with appending preference.
 java.io.Reader asReader()
          Converts the wrapped object into a Reader object.
 java.io.Writer asWriter()
          Converts the wrapped object into a Writer object.
 java.io.Writer asWriter(boolean append)
          Converts the wrapped object into a Writer object with appending preference.
 boolean delete()
          Deletes the backing file of the wrapped object, if possible.
 boolean isReader()
          Determines if the wrapped object is suitable for reading from.
 boolean isWriter()
          Determines if the wrapped object is suitable for writing to.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IOAdapter

public IOAdapter(java.lang.Object io)
Creates a new instance of IOAdapter.

Parameters:
io - IO object to wrap
Method Detail

isReader

public boolean isReader()
Determines if the wrapped object is suitable for reading from.

Returns:
true if wrapped object is readable

isWriter

public boolean isWriter()
Determines if the wrapped object is suitable for writing to.

Returns:
true if wrapped object is writable

asReader

public java.io.Reader asReader()
Converts the wrapped object into a Reader object.

Returns:
a Reader or null if not adaptable

asInputStream

public java.io.InputStream asInputStream()
Converts the wrapped object into an InputStream object.

Returns:
a InputStream or null if not adaptable

asWriter

public java.io.Writer asWriter()
Converts the wrapped object into a Writer object.

Returns:
a Writer or null if not adaptable

asWriter

public java.io.Writer asWriter(boolean append)
Converts the wrapped object into a Writer object with appending preference.

Parameters:
append - true to append data to the output stream, if possible
Returns:
a Writer or null if not adaptable

asOutputStream

public java.io.OutputStream asOutputStream()
Converts the wrapped object into an OutputStream object.

Returns:
an OutputStream or null if not adaptable

asOutputStream

public java.io.OutputStream asOutputStream(boolean append)
Converts the wrapped object into an OutputStream object with appending preference.

Parameters:
append - true to append data to the output stream, if possible
Returns:
an OutputStream or null if not adaptable

asFile

public java.io.File asFile()
Converts the wrapped object into an File object.

Returns:
a File or null if not adaptable

delete

public boolean delete()
Deletes the backing file of the wrapped object, if possible. If no file is associated with the object, returns true.

Returns:
true if backing file no longer exists