org.jruby.util
Class IOChannel

java.lang.Object
  extended by org.jruby.util.IOChannel
All Implemented Interfaces:
java.io.Closeable, java.nio.channels.Channel
Direct Known Subclasses:
IOChannel.IOReadableByteChannel, IOChannel.IOReadableWritableByteChannel, IOChannel.IOWritableByteChannel

public abstract class IOChannel
extends java.lang.Object
implements java.nio.channels.Channel

This class wraps a IRubyObject in an OutputStream. Depending on which messages the IRubyObject answers to, it will have different functionality. The point is that the IRubyObject could exhibit duck typing, in the style of IO versus StringIO, for example. At the moment, the only functionality supported is writing, and the only requirement on the io-object is that it responds to write() and close() like IO.

Author:
Ola Bini

Nested Class Summary
static class IOChannel.IOReadableByteChannel
           
static class IOChannel.IOReadableWritableByteChannel
           
static class IOChannel.IOWritableByteChannel
           
 
Constructor Summary
protected IOChannel(IRubyObject io)
          Creates a new OutputStream with the object provided.
 
Method Summary
 void close()
           
protected  CallSite initReadSite()
           
protected  CallSite initWriteSite()
           
 boolean isOpen()
           
protected  int read(CallSite read, java.nio.ByteBuffer dst)
           
protected  int write(CallSite write, java.nio.ByteBuffer src)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IOChannel

protected IOChannel(IRubyObject io)
Creates a new OutputStream with the object provided.

Parameters:
io - the ruby object
Method Detail

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Specified by:
close in interface java.nio.channels.Channel
Throws:
java.io.IOException

isOpen

public boolean isOpen()
Specified by:
isOpen in interface java.nio.channels.Channel

read

protected int read(CallSite read,
                   java.nio.ByteBuffer dst)
            throws java.io.IOException
Throws:
java.io.IOException

write

protected int write(CallSite write,
                    java.nio.ByteBuffer src)
             throws java.io.IOException
Throws:
java.io.IOException

initReadSite

protected CallSite initReadSite()

initWriteSite

protected CallSite initWriteSite()


Copyright © 2002-2009 JRuby Team. All Rights Reserved.