org.jruby.util
Class IOHandlerNio

java.lang.Object
  extended by org.jruby.util.IOHandler
      extended by org.jruby.util.IOHandlerNio

public class IOHandlerNio
extends IOHandler


Nested Class Summary
 
Nested classes/interfaces inherited from class org.jruby.util.IOHandler
IOHandler.BadDescriptorException, IOHandler.InvalidValueException, IOHandler.PipeException
 
Field Summary
 
Fields inherited from class org.jruby.util.IOHandler
fileno, isOpen, isSync, modes, PARAGRAPH_DELIMETER, SEEK_CUR, SEEK_END, SEEK_SET
 
Constructor Summary
IOHandlerNio(Ruby runtime, java.nio.channels.Channel channel)
           
 
Method Summary
 IOHandler cloneIOHandler()
           
 void close()
           
 void flush()
           
 boolean getBlocking()
           
 int getc()
           
 java.nio.channels.Channel getChannel()
           
 java.nio.channels.FileChannel getFileChannel()
           
 ByteList gets(ByteList separator)
           
 ByteList getsEntireStream()
           
 boolean hasPendingBuffered()
           
 boolean isEOF()
          Return true when at end of file (EOF).
 int pid()
          Get the process ID associated with this handler.
 long pos()
          Get the current position within the file associated with this handler.
 void putc(int c)
           
 ByteList read(int length)
           
 ByteList readpartial(int length)
           
 int ready()
          Implement IO#ready? as per io/wait in MRI.
 ByteList recv(int length)
           
 void resetByModes(IOModes newModes)
           
 void rewind()
           
 void seek(long offset, int type)
          Perform a seek based on pos().
 void setBlocking(boolean block)
           
 void sync()
          Flush and sync all writes to the filesystem.
 ByteList sysread(int length)
           
 int syswrite(ByteList string)
           
 int syswrite(int c)
           
 void truncate(long length)
           
 void ungetc(int c)
           
 int write(ByteList string)
           
 
Methods inherited from class org.jruby.util.IOHandler
checkOpen, checkPermissionsSubsetOf, checkReadable, checkWritable, checkWriteable, getFileno, getModes, getRuntime, isOpen, isReadable, isSync, isWriteable, reset, setFileno, setIsSync, waitUntilReady
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IOHandlerNio

public IOHandlerNio(Ruby runtime,
                    java.nio.channels.Channel channel)
             throws java.io.IOException
Throws:
java.io.IOException
Method Detail

getChannel

public java.nio.channels.Channel getChannel()

cloneIOHandler

public IOHandler cloneIOHandler()
                         throws java.io.IOException
Specified by:
cloneIOHandler in class IOHandler
Throws:
java.io.IOException

setBlocking

public void setBlocking(boolean block)
                 throws java.io.IOException
Throws:
java.io.IOException

getBlocking

public boolean getBlocking()

sysread

public ByteList sysread(int length)
                 throws java.io.EOFException,
                        IOHandler.BadDescriptorException,
                        java.io.IOException
Specified by:
sysread in class IOHandler
Throws:
java.io.EOFException
IOHandler.BadDescriptorException
java.io.IOException

syswrite

public int syswrite(ByteList string)
             throws IOHandler.BadDescriptorException,
                    java.io.IOException
Specified by:
syswrite in class IOHandler
Throws:
IOHandler.BadDescriptorException
java.io.IOException

syswrite

public int syswrite(int c)
             throws IOHandler.BadDescriptorException,
                    java.io.IOException
Specified by:
syswrite in class IOHandler
Throws:
IOHandler.BadDescriptorException
java.io.IOException

recv

public ByteList recv(int length)
              throws java.io.EOFException,
                     IOHandler.BadDescriptorException,
                     java.io.IOException
Throws:
java.io.EOFException
IOHandler.BadDescriptorException
java.io.IOException

readpartial

public ByteList readpartial(int length)
                     throws java.io.IOException,
                            IOHandler.BadDescriptorException,
                            java.io.EOFException
Throws:
java.io.IOException
IOHandler.BadDescriptorException
java.io.EOFException

read

public ByteList read(int length)
              throws java.io.IOException,
                     IOHandler.BadDescriptorException,
                     java.io.EOFException
Specified by:
read in class IOHandler
Throws:
java.io.IOException
IOHandler.BadDescriptorException
java.io.EOFException

write

public int write(ByteList string)
          throws java.io.IOException,
                 IOHandler.BadDescriptorException
Specified by:
write in class IOHandler
Throws:
java.io.IOException
IOHandler.BadDescriptorException

gets

public ByteList gets(ByteList separator)
              throws java.io.IOException,
                     IOHandler.BadDescriptorException,
                     java.io.EOFException
Specified by:
gets in class IOHandler
Throws:
java.io.IOException
IOHandler.BadDescriptorException
java.io.EOFException

getsEntireStream

public ByteList getsEntireStream()
                          throws java.io.IOException,
                                 IOHandler.BadDescriptorException,
                                 java.io.EOFException
Specified by:
getsEntireStream in class IOHandler
Throws:
java.io.IOException
IOHandler.BadDescriptorException
java.io.EOFException

getc

public int getc()
         throws java.io.IOException,
                IOHandler.BadDescriptorException,
                java.io.EOFException
Specified by:
getc in class IOHandler
Throws:
java.io.IOException
IOHandler.BadDescriptorException
java.io.EOFException

ungetc

public void ungetc(int c)
Specified by:
ungetc in class IOHandler

putc

public void putc(int c)
          throws java.io.IOException,
                 IOHandler.BadDescriptorException
Specified by:
putc in class IOHandler
Throws:
java.io.IOException
IOHandler.BadDescriptorException

flush

public void flush()
           throws java.io.IOException,
                  IOHandler.BadDescriptorException
Specified by:
flush in class IOHandler
Throws:
java.io.IOException
IOHandler.BadDescriptorException

sync

public void sync()
          throws java.io.IOException,
                 IOHandler.BadDescriptorException
Description copied from class: IOHandler

Flush and sync all writes to the filesystem.

Specified by:
sync in class IOHandler
Throws:
java.io.IOException - if the sync does not work
IOHandler.BadDescriptorException

isEOF

public boolean isEOF()
              throws java.io.IOException,
                     IOHandler.BadDescriptorException
Description copied from class: IOHandler

Return true when at end of file (EOF).

Specified by:
isEOF in class IOHandler
Returns:
true if at EOF; false otherwise
Throws:
java.io.IOException
IOHandler.BadDescriptorException

close

public void close()
           throws java.io.IOException
Specified by:
close in class IOHandler
Throws:
java.io.IOException

pos

public long pos()
         throws IOHandler.PipeException,
                java.io.IOException
Description copied from class: IOHandler

Get the current position within the file associated with this handler.

Specified by:
pos in class IOHandler
Returns:
the current position in the file.
Throws:
IOHandler.PipeException - ESPIPE (illegal seek) when not a file
java.io.IOException

seek

public void seek(long offset,
                 int type)
          throws java.io.IOException,
                 IOHandler.InvalidValueException,
                 IOHandler.PipeException
Description copied from class: IOHandler

Perform a seek based on pos().

Specified by:
seek in class IOHandler
Throws:
java.io.IOException
IOHandler.InvalidValueException
IOHandler.PipeException

resetByModes

public void resetByModes(IOModes newModes)
                  throws java.io.IOException,
                         IOHandler.InvalidValueException
Specified by:
resetByModes in class IOHandler
Throws:
java.io.IOException
IOHandler.InvalidValueException

rewind

public void rewind()
            throws java.io.IOException,
                   IOHandler.PipeException
Specified by:
rewind in class IOHandler
Throws:
java.io.IOException
IOHandler.PipeException

truncate

public void truncate(long length)
              throws java.io.IOException,
                     IOHandler.PipeException
Specified by:
truncate in class IOHandler
Throws:
java.io.IOException
IOHandler.PipeException

pid

public int pid()
Description copied from class: IOHandler

Get the process ID associated with this handler.

Specified by:
pid in class IOHandler
Returns:
the pid if the IOHandler represents a process; otherwise -1

getFileChannel

public java.nio.channels.FileChannel getFileChannel()
Specified by:
getFileChannel in class IOHandler

hasPendingBuffered

public boolean hasPendingBuffered()
Overrides:
hasPendingBuffered in class IOHandler

ready

public int ready()
          throws java.io.IOException
Description copied from class: IOHandler
Implement IO#ready? as per io/wait in MRI. returns non-nil if input available without blocking, or nil.

Specified by:
ready in class IOHandler
Throws:
java.io.IOException


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