org.jruby
Class RubyIO

java.lang.Object
  extended byorg.jruby.RubyObject
      extended byorg.jruby.RubyIO
All Implemented Interfaces:
java.lang.Cloneable, IRubyObject
Direct Known Subclasses:
RubyFile

public class RubyIO
extends RubyObject

Version:
$Revision: 1.13 $
Author:
jpetersen

Field Summary
protected static int fileno
           
protected  IOHandler handler
           
protected static java.util.Hashtable ioHandlers
           
protected  boolean isOpen
           
protected  int lineNumber
           
protected  IOModes modes
           
static int STDERR
           
static int STDIN
           
static int STDOUT
           
 
Fields inherited from class org.jruby.RubyObject
runtime
 
Fields inherited from interface org.jruby.runtime.builtin.IRubyObject
NULL_ARRAY
 
Constructor Summary
  RubyIO(Ruby ruby, int descriptor)
           
  RubyIO(Ruby ruby, java.io.OutputStream outputStream)
           
protected RubyIO(Ruby ruby, RubyClass type)
           
 
Method Summary
 IRubyObject addString(IRubyObject anObject)
          rb_io_addstr
protected  void checkReadable()
           
protected  void checkWriteable()
           
 RubyIO clone_IO()
           
 IRubyObject close()
          Closes all open resources for the IO.
 RubyBoolean closed()
          Closes the IO.
static RubyClass createIOClass(Ruby ruby)
           
 IRubyObject each_byte()
          Invoke a block for each byte.
 RubyIO each_line(IRubyObject[] args)
          Invoke a block for each line.
 RubyBoolean eof()
           
static IRubyObject fdOpen(Ruby ruby, int descriptor)
          Open a file descriptor, unless it is already open, then return it.
 RubyFixnum fileno()
           
 void finalize()
           
 RubyIO flush()
          Flushes the IO output stream.
static IRubyObject foreach(IRubyObject recv, IRubyObject filename, IRubyObject[] args)
          rb_io_s_foreach
 RubyFixnum fsync()
           
 IRubyObject getc()
          Read a byte.
 java.io.InputStream getInStream()
           
static IOHandler getIOHandlerByFileno(int fileno)
           
static int getNewFileno()
           
 java.io.OutputStream getOutStream()
           
 RubyString gets(IRubyObject[] args)
          Read a line.
 IRubyObject initialize(RubyFixnum descriptor, IRubyObject[] args)
          rb_io_initialize
 RubyString internalGets(IRubyObject[] args)
          Read a line.
protected  boolean isOpen()
           
 RubyFixnum lineno_set(RubyFixnum newLineNumber)
          Sets the current line number.
 RubyFixnum lineno()
          Returns the current line number.
static IRubyObject newInstance(IRubyObject recv, IRubyObject[] args)
          rb_io_s_new
 IRubyObject pid()
          Return the process id (pid) of the process this IO object spawned.
 RubyFixnum pos_set(RubyFixnum newPosition)
           
 RubyFixnum pos()
           
static IRubyObject print(IRubyObject recv, IRubyObject[] args)
          Print some objects to the stream.
static IRubyObject printf(IRubyObject recv, IRubyObject[] args)
           
 IRubyObject putc(IRubyObject object)
           
static IRubyObject puts(IRubyObject recv, IRubyObject[] args)
           
 IRubyObject read(IRubyObject[] args)
           
 IRubyObject readchar()
          Read a byte.
 RubyString readline(IRubyObject[] args)
          Read a line.
 RubyArray readlines(IRubyObject[] args)
           
static RubyArray readlines(IRubyObject recv, IRubyObject[] args)
           
static void registerIOHandler(IOHandler handler)
           
 IRubyObject reopen(IRubyObject arg1, IRubyObject[] args)
           
 RubyFixnum rewind()
           
 RubyFixnum seek(IRubyObject[] args)
           
 IRubyObject sync_set(RubyBoolean newSync)
          Sets the current sync mode.
 RubyBoolean sync()
          Returns the current sync mode.
 IRubyObject sysread(RubyFixnum number)
           
 IRubyObject syswrite(IRubyObject obj)
           
 java.lang.String toString()
           
 IRubyObject ungetc(RubyFixnum number)
          Pushes char represented by int back onto IOS.
static void unregisterIOHandler(int fileno)
           
 IRubyObject write(IRubyObject obj)
          io_write
 
Methods inherited from class org.jruby.RubyObject
argCount, asSymbol, callbackFactory, callInit, callMethod, callMethod, callMethod, checkSafeString, convertToString, convertToType, convertType, createObjectClass, defineSingletonMethod, display, dup, equal, equals, eval, eval, evalUnder, extend, extendObject, freeze, frozen, getInstanceVariable, getInstanceVariables, getJavaClass, getMetaClass, getRuntime, getSingletonClass, getType, hash, hashCode, hasInstanceVariable, id, infectBy, inspect, instance_eval, instance_of, instance_variables, instanceVariableNames, isFalse, isFrozen, isKindOf, isNil, isTaint, isTrue, kind_of, makeMetaClass, marshalTo, method_missing, method, methods, nilObject, private_methods, protected_methods, rbClone, removeInstanceVariable, respond_to, respondsTo, send, setFrozen, setInstanceVariable, setInstanceVariable, setInstanceVariables, setMetaClass, setTaint, setupClone, singleton_methods, singletonMethodsAllowed, specificEval, taint, tainted, to_a, to_s, type, untaint
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

STDIN

public static final int STDIN
See Also:
Constant Field Values

STDOUT

public static final int STDOUT
See Also:
Constant Field Values

STDERR

public static final int STDERR
See Also:
Constant Field Values

handler

protected IOHandler handler

modes

protected IOModes modes

lineNumber

protected int lineNumber

isOpen

protected boolean isOpen

ioHandlers

protected static java.util.Hashtable ioHandlers

fileno

protected static int fileno
Constructor Detail

RubyIO

protected RubyIO(Ruby ruby,
                 RubyClass type)

RubyIO

public RubyIO(Ruby ruby,
              java.io.OutputStream outputStream)

RubyIO

public RubyIO(Ruby ruby,
              int descriptor)
Method Detail

registerIOHandler

public static void registerIOHandler(IOHandler handler)

unregisterIOHandler

public static void unregisterIOHandler(int fileno)

getIOHandlerByFileno

public static IOHandler getIOHandlerByFileno(int fileno)

getNewFileno

public static int getNewFileno()

createIOClass

public static RubyClass createIOClass(Ruby ruby)

fdOpen

public static IRubyObject fdOpen(Ruby ruby,
                                 int descriptor)

Open a file descriptor, unless it is already open, then return it.


checkWriteable

protected void checkWriteable()

checkReadable

protected void checkReadable()

isOpen

protected boolean isOpen()

getOutStream

public java.io.OutputStream getOutStream()

getInStream

public java.io.InputStream getInStream()

reopen

public IRubyObject reopen(IRubyObject arg1,
                          IRubyObject[] args)

internalGets

public RubyString internalGets(IRubyObject[] args)
Read a line.


newInstance

public static IRubyObject newInstance(IRubyObject recv,
                                      IRubyObject[] args)
rb_io_s_new


foreach

public static IRubyObject foreach(IRubyObject recv,
                                  IRubyObject filename,
                                  IRubyObject[] args)
rb_io_s_foreach


initialize

public IRubyObject initialize(RubyFixnum descriptor,
                              IRubyObject[] args)
rb_io_initialize


syswrite

public IRubyObject syswrite(IRubyObject obj)

write

public IRubyObject write(IRubyObject obj)
io_write


addString

public IRubyObject addString(IRubyObject anObject)
rb_io_addstr


fileno

public RubyFixnum fileno()

lineno

public RubyFixnum lineno()
Returns the current line number.

Returns:
the current line number.

lineno_set

public RubyFixnum lineno_set(RubyFixnum newLineNumber)
Sets the current line number.

Parameters:
newLineNumber - The new line number.

sync

public RubyBoolean sync()
Returns the current sync mode.

Returns:
the current sync mode.

pid

public IRubyObject pid()

Return the process id (pid) of the process this IO object spawned. If no process exists (popen was not called), then nil is returned. This is not how it appears to be defined but ruby 1.8 works this way.

Returns:
the pid or nil

pos

public RubyFixnum pos()

pos_set

public RubyFixnum pos_set(RubyFixnum newPosition)

putc

public IRubyObject putc(IRubyObject object)

seek

public RubyFixnum seek(IRubyObject[] args)

rewind

public RubyFixnum rewind()

fsync

public RubyFixnum fsync()

sync_set

public IRubyObject sync_set(RubyBoolean newSync)
Sets the current sync mode.

Parameters:
newSync - The new sync mode.

eof

public RubyBoolean eof()

clone_IO

public RubyIO clone_IO()

closed

public RubyBoolean closed()
Closes the IO.

Returns:
The IO.

close

public IRubyObject close()

Closes all open resources for the IO. It also removes it from our magical all open file descriptor pool.

Returns:
The IO.

flush

public RubyIO flush()
Flushes the IO output stream.

Returns:
The IO.

gets

public RubyString gets(IRubyObject[] args)
Read a line.


readline

public RubyString readline(IRubyObject[] args)
Read a line.


getc

public IRubyObject getc()
Read a byte. On EOF returns nil.


ungetc

public IRubyObject ungetc(RubyFixnum number)

Pushes char represented by int back onto IOS.

Parameters:
number - to push back

sysread

public IRubyObject sysread(RubyFixnum number)

read

public IRubyObject read(IRubyObject[] args)

readchar

public IRubyObject readchar()
Read a byte. On EOF throw EOFError.


each_byte

public IRubyObject each_byte()

Invoke a block for each byte.


each_line

public RubyIO each_line(IRubyObject[] args)

Invoke a block for each line.


puts

public static IRubyObject puts(IRubyObject recv,
                               IRubyObject[] args)

print

public static IRubyObject print(IRubyObject recv,
                                IRubyObject[] args)
Print some objects to the stream.


printf

public static IRubyObject printf(IRubyObject recv,
                                 IRubyObject[] args)

readlines

public RubyArray readlines(IRubyObject[] args)

readlines

public static RubyArray readlines(IRubyObject recv,
                                  IRubyObject[] args)

toString

public java.lang.String toString()
Overrides:
toString in class RubyObject

finalize

public void finalize()
              throws java.lang.Throwable
Throws:
java.lang.Throwable


Copyright © 2002 Jan Arne Petersen. All Rights Reserved.