org.jruby
Class RubyIO
java.lang.Object
org.jruby.RubyObject
org.jruby.RubyIO
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, InstanceVariables, InternalVariables, IRubyObject, CoreObjectType
- Direct Known Subclasses:
- RubyBasicSocket, RubyFile
public class RubyIO
- extends RubyObject
- Author:
- jpetersen
- See Also:
- Serialized Form
Fields inherited from class org.jruby.RubyObject |
ALL_F, ERR_INSECURE_SET_INST_VAR, FALSE_F, FL_USHIFT, flags, FROZEN_F, metaClass, metaClassName, NEVER, NIL_F, OBJECT_ALLOCATOR, TAINTED_F, UNDEF, USER0_F, USER1_F, USER2_F, USER3_F, USER4_F, USER5_F, USER6_F, USER7_F, VARIABLE_TABLE_DEFAULT_CAPACITY, VARIABLE_TABLE_EMPTY_TABLE, VARIABLE_TABLE_LOAD_FACTOR, VARIABLE_TABLE_MAXIMUM_CAPACITY, variableTable, variableTableSize, variableTableThreshold |
Method Summary |
IRubyObject |
binmode()
|
protected void |
checkClosed()
|
protected void |
checkInitialized()
|
IRubyObject |
close_read()
|
IRubyObject |
close_write()
|
IRubyObject |
close()
Closes all open resources for the IO. |
protected IRubyObject |
close2()
|
RubyBoolean |
closed_p()
Closes the IO. |
static IRubyObject |
copy_stream(IRubyObject recv,
IRubyObject stream1,
IRubyObject stream2)
|
static RubyClass |
createIOClass(Ruby runtime)
|
IRubyObject |
ctl(IRubyObject cmd,
IRubyObject arg)
|
IRubyObject |
each_byte(ThreadContext context,
Block block)
Invoke a block for each byte. |
RubyIO |
each_line(ThreadContext context,
IRubyObject[] args,
Block block)
Invoke a block for each line. |
RubyBoolean |
eof_p()
|
IRubyObject |
fcntl(IRubyObject cmd,
IRubyObject arg)
|
protected Stream |
fdopen(ChannelDescriptor existingDescriptor,
ModeFlags modes)
|
RubyFixnum |
fileno()
|
RubyIO |
flush()
Flushes the IO output stream. |
static IRubyObject |
foreach(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
rb_io_s_foreach |
RubyFixnum |
fsync()
|
protected int |
fwrite(org.jruby.util.ByteList buffer)
|
boolean |
getBlocking()
|
IRubyObject |
getc()
Read a byte. |
java.nio.channels.Channel |
getChannel()
|
ChannelDescriptor |
getDescriptorByFileno(int aFileno)
|
Stream |
getHandler()
|
java.io.InputStream |
getInStream()
|
static ModeFlags |
getIOModes(Ruby runtime,
java.lang.String modesString)
|
static int |
getIOModesIntFromString(Ruby runtime,
java.lang.String modesString)
|
IRubyObject |
getline(org.jruby.util.ByteList separator)
|
IRubyObject |
getlineFast(int delim)
|
static int |
getNewFileno()
|
OpenFile |
getOpenFile()
|
protected OpenFile |
getOpenFileChecked()
|
java.io.OutputStream |
getOutStream()
|
IRubyObject |
gets(ThreadContext context,
IRubyObject[] args)
Read a line. |
IRubyObject |
initialize_copy(IRubyObject original)
rb_obj_init_copy
Initializes this object as a copy of the original, that is the
parameter to this object. |
IRubyObject |
initialize(IRubyObject[] args,
Block unusedBlock)
|
IRubyObject |
ioctl(IRubyObject[] args)
|
RubyFixnum |
lineno_set(IRubyObject newLineNumber)
Sets the current line number. |
RubyFixnum |
lineno()
Returns the current line number. |
static IRubyObject |
newInstance(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
|
IRubyObject |
op_append(ThreadContext context,
IRubyObject anObject)
rb_io_addstr |
static IRubyObject |
open(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
|
IRubyObject |
pid()
Return the process id (pid) of the process this IO object
spawned. |
static IRubyObject |
pipe(IRubyObject recv)
|
static IRubyObject |
popen(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
|
RubyFixnum |
pos_set(IRubyObject newPosition)
|
RubyFixnum |
pos()
|
IRubyObject |
print(ThreadContext context,
IRubyObject[] args)
Print some objects to the stream. |
IRubyObject |
printf(ThreadContext context,
IRubyObject[] args)
|
IRubyObject |
putc(ThreadContext context,
IRubyObject object)
|
IRubyObject |
puts(ThreadContext context,
IRubyObject[] args)
|
IRubyObject |
read_nonblock(IRubyObject[] args)
|
IRubyObject |
read(IRubyObject[] args)
|
static IRubyObject |
read(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
|
protected IRubyObject |
readAll(IRubyObject buffer)
|
IRubyObject |
readchar()
Read a byte. |
IRubyObject |
readline(ThreadContext context,
IRubyObject[] args)
Read a line. |
RubyArray |
readlines(IRubyObject[] args)
|
static RubyArray |
readlines(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
|
IRubyObject |
readpartial(ThreadContext context,
IRubyObject[] args)
|
void |
registerDescriptor(ChannelDescriptor descriptor)
|
IRubyObject |
reopen(IRubyObject[] args)
|
RubyFixnum |
rewind()
|
RubyFixnum |
seek(IRubyObject[] args)
|
static IRubyObject |
select_static(ThreadContext context,
Ruby runtime,
IRubyObject[] args)
|
static IRubyObject |
select(ThreadContext context,
IRubyObject recv,
IRubyObject[] args)
|
IRubyObject |
stat()
|
protected boolean |
swallow(int term)
|
IRubyObject |
sync_set(IRubyObject newSync)
Sets the current sync mode. |
RubyBoolean |
sync()
Returns the current sync mode. |
IRubyObject |
sysread(ThreadContext context,
IRubyObject[] args)
|
RubyFixnum |
sysseek(IRubyObject[] args)
|
IRubyObject |
syswrite(IRubyObject obj)
|
RubyIO |
to_io()
|
java.lang.String |
toString()
The default toString method is just a wrapper that calls the
Ruby "to_s" method. |
RubyBoolean |
tty_p()
|
IRubyObject |
ungetc(IRubyObject number)
Pushes char represented by int back onto IOS. |
void |
unregisterDescriptor(int aFileno)
|
protected boolean |
waitReadable(ChannelDescriptor descriptor)
|
protected boolean |
waitWritable(ChannelDescriptor descriptor)
|
IRubyObject |
write_nonblock(IRubyObject obj)
|
IRubyObject |
write(IRubyObject obj)
io_write |
protected void |
write(ThreadContext context,
org.jruby.util.ByteList byteList)
|
boolean |
writeDataBuffered()
Deprecated. |
Methods inherited from class org.jruby.RubyObject |
addFinalizer, anyToString, asJavaString, asString, attachToObjectSpace, callInit, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callSuper, checkArrayType, checkFrozen, checkStringType, convertToArray, convertToFloat, convertToHash, convertToInteger, convertToInteger, convertToString, convertToType, copySpecialInstanceVariables, createObjectClass, dataGetStruct, dataWrapStruct, display, dup, ensureInstanceVariablesSettable, eql_p, eql, eqlInternal, equal_p, equalInternal, equals, evalUnder, extend, fastGetInstanceVariable, fastGetInternalVariable, fastHasInstanceVariable, fastHasInternalVariable, fastSetInstanceVariable, fastSetInternalVariable, freeze, frozen_p, getFlag, getInstanceVariable, getInstanceVariableList, getInstanceVariableNameList, getInstanceVariables, getInternalVariable, getInternalVariableList, getInternalVariables, getJavaClass, getMetaClass, getNativeTypeIndex, getRuntime, getSingletonClass, getSingletonClassClone, getType, getVariableCount, getVariableList, getVariableMap, getVariableNameList, hash, hashCode, hasInstanceVariable, hasInternalVariable, hasVariables, id_deprecated, id, infectBy, initialize, inspect, instance_eval, instance_exec, instance_of_p, instance_variable_defined_p, instance_variable_get, instance_variable_set, instance_variables, isClass, isFalse, isFrozen, isImmediate, isModule, isNil, isRubyVariable, isTaint, isTrue, kind_of_p, makeMetaClass, method, methods, nil_p, op_eqq, op_equal, op_match, private_methods, protected_methods, public_methods, puts, rbClone, remove_instance_variable, removeFinalizers, removeInstanceVariable, removeInternalVariable, respond_to_p, respond_to_p, respondsTo, send, setFlag, setFrozen, setInstanceVariable, setInternalVariable, setMetaClass, setTaint, singleton_methods, specificEval, syncVariables, taint, tainted_p, testFrozen, to_a, to_s, type_deprecated, type, untaint, validateInstanceVariable, variableTableContains, variableTableFastContains, variableTableFastFetch, variableTableFastStore, variableTableFetch, variableTableGetMap, variableTableGetMap, variableTableGetSize, variableTableGetTable, variableTableReadLocked, variableTableRehash, variableTableRemove, variableTableStore, variableTableSync |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
openFile
protected OpenFile openFile
filenoIndex
protected static int filenoIndex
RubyIO
public RubyIO(Ruby runtime,
RubyClass type)
RubyIO
public RubyIO(Ruby runtime,
java.io.OutputStream outputStream)
RubyIO
public RubyIO(Ruby runtime,
java.io.InputStream inputStream)
RubyIO
public RubyIO(Ruby runtime,
java.nio.channels.Channel channel)
RubyIO
public RubyIO(Ruby runtime,
java.lang.Process process,
ModeFlags modes)
RubyIO
public RubyIO(Ruby runtime,
STDIO stdio)
registerDescriptor
public void registerDescriptor(ChannelDescriptor descriptor)
unregisterDescriptor
public void unregisterDescriptor(int aFileno)
getDescriptorByFileno
public ChannelDescriptor getDescriptorByFileno(int aFileno)
getNewFileno
public static int getNewFileno()
getOpenFile
public OpenFile getOpenFile()
getOpenFileChecked
protected OpenFile getOpenFileChecked()
createIOClass
public static RubyClass createIOClass(Ruby runtime)
getOutStream
public java.io.OutputStream getOutStream()
getInStream
public java.io.InputStream getInStream()
getChannel
public java.nio.channels.Channel getChannel()
getHandler
public Stream getHandler()
reopen
public IRubyObject reopen(IRubyObject[] args)
throws InvalidValueException
- Throws:
InvalidValueException
getIOModes
public static ModeFlags getIOModes(Ruby runtime,
java.lang.String modesString)
throws InvalidValueException
- Throws:
InvalidValueException
getIOModesIntFromString
public static int getIOModesIntFromString(Ruby runtime,
java.lang.String modesString)
getline
public IRubyObject getline(org.jruby.util.ByteList separator)
swallow
protected boolean swallow(int term)
throws java.io.IOException,
BadDescriptorException
- Throws:
java.io.IOException
BadDescriptorException
getlineFast
public IRubyObject getlineFast(int delim)
throws java.io.IOException,
BadDescriptorException
- Throws:
java.io.IOException
BadDescriptorException
newInstance
public static IRubyObject newInstance(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
initialize
public IRubyObject initialize(IRubyObject[] args,
Block unusedBlock)
fdopen
protected Stream fdopen(ChannelDescriptor existingDescriptor,
ModeFlags modes)
throws InvalidValueException
- Throws:
InvalidValueException
open
public static IRubyObject open(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
binmode
public IRubyObject binmode()
checkInitialized
protected void checkInitialized()
checkClosed
protected void checkClosed()
syswrite
public IRubyObject syswrite(IRubyObject obj)
write_nonblock
public IRubyObject write_nonblock(IRubyObject obj)
write
public IRubyObject write(IRubyObject obj)
- io_write
waitWritable
protected boolean waitWritable(ChannelDescriptor descriptor)
throws java.io.IOException
- Throws:
java.io.IOException
waitReadable
protected boolean waitReadable(ChannelDescriptor descriptor)
throws java.io.IOException
- Throws:
java.io.IOException
fwrite
protected int fwrite(org.jruby.util.ByteList buffer)
op_append
public IRubyObject op_append(ThreadContext context,
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(IRubyObject 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
writeDataBuffered
public boolean writeDataBuffered()
- Deprecated.
- Returns:
pos
public RubyFixnum pos()
pos_set
public RubyFixnum pos_set(IRubyObject newPosition)
print
public IRubyObject print(ThreadContext context,
IRubyObject[] args)
- Print some objects to the stream.
printf
public IRubyObject printf(ThreadContext context,
IRubyObject[] args)
putc
public IRubyObject putc(ThreadContext context,
IRubyObject object)
seek
public RubyFixnum seek(IRubyObject[] args)
sysseek
public RubyFixnum sysseek(IRubyObject[] args)
rewind
public RubyFixnum rewind()
fsync
public RubyFixnum fsync()
sync_set
public IRubyObject sync_set(IRubyObject newSync)
- Sets the current sync mode.
- Parameters:
newSync
- The new sync mode.
eof_p
public RubyBoolean eof_p()
tty_p
public RubyBoolean tty_p()
initialize_copy
public IRubyObject initialize_copy(IRubyObject original)
- Description copied from class:
RubyObject
- rb_obj_init_copy
Initializes this object as a copy of the original, that is the
parameter to this object. Will make sure that the argument
actually has the same real class as this object. It shouldn't
be possible to initialize an object with something totally
different.
- Overrides:
initialize_copy
in class RubyObject
closed_p
public RubyBoolean closed_p()
- 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.
close2
protected IRubyObject close2()
close_write
public IRubyObject close_write()
throws BadDescriptorException
- Throws:
BadDescriptorException
close_read
public IRubyObject close_read()
throws BadDescriptorException
- Throws:
BadDescriptorException
flush
public RubyIO flush()
- Flushes the IO output stream.
- Returns:
- The IO.
gets
public IRubyObject gets(ThreadContext context,
IRubyObject[] args)
- Read a line.
getBlocking
public boolean getBlocking()
fcntl
public IRubyObject fcntl(IRubyObject cmd,
IRubyObject arg)
ioctl
public IRubyObject ioctl(IRubyObject[] args)
ctl
public IRubyObject ctl(IRubyObject cmd,
IRubyObject arg)
puts
public IRubyObject puts(ThreadContext context,
IRubyObject[] args)
write
protected void write(ThreadContext context,
org.jruby.util.ByteList byteList)
readline
public IRubyObject readline(ThreadContext context,
IRubyObject[] args)
- Read a line.
getc
public IRubyObject getc()
- Read a byte. On EOF returns nil.
ungetc
public IRubyObject ungetc(IRubyObject number)
Pushes char represented by int back onto IOS.
- Parameters:
number
- to push back
readpartial
public IRubyObject readpartial(ThreadContext context,
IRubyObject[] args)
sysread
public IRubyObject sysread(ThreadContext context,
IRubyObject[] args)
read_nonblock
public IRubyObject read_nonblock(IRubyObject[] args)
read
public IRubyObject read(IRubyObject[] args)
readAll
protected IRubyObject readAll(IRubyObject buffer)
throws BadDescriptorException,
java.io.EOFException,
java.io.IOException
- Throws:
BadDescriptorException
java.io.EOFException
java.io.IOException
readchar
public IRubyObject readchar()
- Read a byte. On EOF throw EOFError.
stat
public IRubyObject stat()
each_byte
public IRubyObject each_byte(ThreadContext context,
Block block)
Invoke a block for each byte.
each_line
public RubyIO each_line(ThreadContext context,
IRubyObject[] args,
Block block)
Invoke a block for each line.
readlines
public RubyArray readlines(IRubyObject[] args)
to_io
public RubyIO to_io()
toString
public java.lang.String toString()
- Description copied from class:
RubyObject
- The default toString method is just a wrapper that calls the
Ruby "to_s" method.
- Overrides:
toString
in class RubyObject
foreach
public static IRubyObject foreach(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
- rb_io_s_foreach
select
public static IRubyObject select(ThreadContext context,
IRubyObject recv,
IRubyObject[] args)
select_static
public static IRubyObject select_static(ThreadContext context,
Ruby runtime,
IRubyObject[] args)
read
public static IRubyObject read(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
readlines
public static RubyArray readlines(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
popen
public static IRubyObject popen(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
pipe
public static IRubyObject pipe(IRubyObject recv)
throws java.lang.Exception
- Throws:
java.lang.Exception
copy_stream
public static IRubyObject copy_stream(IRubyObject recv,
IRubyObject stream1,
IRubyObject stream2)
throws java.io.IOException
- Throws:
java.io.IOException
Copyright © 2002-2007 JRuby Team. All Rights Reserved.