org.jruby.util
Class IOHandler

java.lang.Object
  extended by org.jruby.util.IOHandler
Direct Known Subclasses:
IOHandlerJavaIO, IOHandlerNio, IOHandlerNull

public abstract class IOHandler
extends java.lang.Object


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

Field Detail

SEEK_SET

public static final int SEEK_SET
See Also:
Constant Field Values

SEEK_CUR

public static final int SEEK_CUR
See Also:
Constant Field Values

SEEK_END

public static final int SEEK_END
See Also:
Constant Field Values

PARAGRAPH_DELIMETER

public static final ByteList PARAGRAPH_DELIMETER

modes

protected IOModes modes

fileno

protected int fileno

isOpen

protected boolean isOpen

isSync

protected boolean isSync
Constructor Detail

IOHandler

protected IOHandler(Ruby runtime)
Method Detail

getFileno

public int getFileno()

setFileno

public void setFileno(int fileno)

getRuntime

protected Ruby getRuntime()

getFileChannel

public abstract java.nio.channels.FileChannel getFileChannel()

isReadable

public boolean isReadable()

isOpen

public boolean isOpen()

isWriteable

public boolean isWriteable()

checkOpen

protected void checkOpen()
                  throws java.io.IOException
Throws:
java.io.IOException

checkReadable

protected void checkReadable()
                      throws java.io.IOException,
                             IOHandler.BadDescriptorException
Throws:
java.io.IOException
IOHandler.BadDescriptorException

checkWriteable

protected void checkWriteable()
                       throws java.io.IOException,
                              IOHandler.BadDescriptorException
Throws:
java.io.IOException
IOHandler.BadDescriptorException

checkWritable

protected void checkWritable()
                      throws java.io.IOException,
                             IOHandler.BadDescriptorException
Throws:
java.io.IOException
IOHandler.BadDescriptorException

checkPermissionsSubsetOf

public void checkPermissionsSubsetOf(IOModes subsetModes)

getModes

public IOModes getModes()

isSync

public boolean isSync()

setIsSync

public void setIsSync(boolean isSync)

reset

public void reset(IOModes subsetModes)
           throws java.io.IOException,
                  IOHandler.InvalidValueException
Throws:
java.io.IOException
IOHandler.InvalidValueException

gets

public abstract ByteList gets(ByteList separatorString)
                       throws java.io.IOException,
                              IOHandler.BadDescriptorException,
                              java.io.EOFException
Throws:
java.io.IOException
IOHandler.BadDescriptorException
java.io.EOFException

getsEntireStream

public abstract ByteList getsEntireStream()
                                   throws java.io.IOException,
                                          IOHandler.BadDescriptorException,
                                          java.io.EOFException
Throws:
java.io.IOException
IOHandler.BadDescriptorException
java.io.EOFException

read

public abstract ByteList read(int number)
                       throws java.io.IOException,
                              IOHandler.BadDescriptorException,
                              java.io.EOFException
Throws:
java.io.IOException
IOHandler.BadDescriptorException
java.io.EOFException

write

public abstract int write(ByteList string)
                   throws java.io.IOException,
                          IOHandler.BadDescriptorException
Throws:
java.io.IOException
IOHandler.BadDescriptorException

getc

public abstract int getc()
                  throws java.io.IOException,
                         IOHandler.BadDescriptorException,
                         java.io.EOFException
Throws:
java.io.IOException
IOHandler.BadDescriptorException
java.io.EOFException

ungetc

public abstract void ungetc(int c)

putc

public abstract void putc(int c)
                   throws java.io.IOException,
                          IOHandler.BadDescriptorException
Throws:
java.io.IOException
IOHandler.BadDescriptorException

sysread

public abstract ByteList sysread(int number)
                          throws java.io.IOException,
                                 IOHandler.BadDescriptorException,
                                 java.io.EOFException
Throws:
java.io.IOException
IOHandler.BadDescriptorException
java.io.EOFException

syswrite

public abstract int syswrite(ByteList buf)
                      throws java.io.IOException,
                             IOHandler.BadDescriptorException
Throws:
java.io.IOException
IOHandler.BadDescriptorException

syswrite

public abstract int syswrite(int ch)
                      throws java.io.IOException,
                             IOHandler.BadDescriptorException
Throws:
java.io.IOException
IOHandler.BadDescriptorException

cloneIOHandler

public abstract IOHandler cloneIOHandler()
                                  throws java.io.IOException,
                                         IOHandler.PipeException,
                                         IOHandler.InvalidValueException
Throws:
java.io.IOException
IOHandler.PipeException
IOHandler.InvalidValueException

close

public abstract void close()
                    throws java.io.IOException,
                           IOHandler.BadDescriptorException
Throws:
java.io.IOException
IOHandler.BadDescriptorException

flush

public abstract void flush()
                    throws java.io.IOException,
                           IOHandler.BadDescriptorException
Throws:
java.io.IOException
IOHandler.BadDescriptorException

sync

public abstract void sync()
                   throws java.io.IOException,
                          IOHandler.BadDescriptorException

Flush and sync all writes to the filesystem.

Throws:
java.io.IOException - if the sync does not work
IOHandler.BadDescriptorException

isEOF

public abstract boolean isEOF()
                       throws java.io.IOException,
                              IOHandler.BadDescriptorException

Return true when at end of file (EOF).

Returns:
true if at EOF; false otherwise
Throws:
java.io.IOException
IOHandler.BadDescriptorException

pid

public abstract int pid()

Get the process ID associated with this handler.

Returns:
the pid if the IOHandler represents a process; otherwise -1

pos

public abstract long pos()
                  throws java.io.IOException,
                         IOHandler.PipeException

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

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

resetByModes

protected abstract void resetByModes(IOModes newModes)
                              throws java.io.IOException,
                                     IOHandler.InvalidValueException
Throws:
java.io.IOException
IOHandler.InvalidValueException

rewind

public abstract void rewind()
                     throws java.io.IOException,
                            IOHandler.PipeException,
                            IOHandler.InvalidValueException
Throws:
java.io.IOException
IOHandler.PipeException
IOHandler.InvalidValueException

seek

public abstract void seek(long offset,
                          int type)
                   throws java.io.IOException,
                          IOHandler.PipeException,
                          IOHandler.InvalidValueException

Perform a seek based on pos().

Throws:
java.io.IOException
IOHandler.PipeException
IOHandler.InvalidValueException

truncate

public abstract void truncate(long newLength)
                       throws java.io.IOException,
                              IOHandler.PipeException
Throws:
java.io.IOException
IOHandler.PipeException

ready

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

Throws:
java.io.IOException

waitUntilReady

public void waitUntilReady()
                    throws java.io.IOException,
                           java.lang.InterruptedException
Implement IO#wait as per io/wait in MRI. waits until input available or timed out and returns self, or nil when EOF reached. The default implementation loops while ready returns 0.

Throws:
java.io.IOException
java.lang.InterruptedException

hasPendingBuffered

public boolean hasPendingBuffered()


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