public class RubyIO extends RubyObject
RubyObject.Data
RubyBasicObject.Finalizer
Modifier and Type | Field and Description |
---|---|
protected java.util.List<RubyThread> |
blockingThreads |
protected org.jcodings.Encoding |
externalEncoding |
protected org.jcodings.Encoding |
internalEncoding |
protected OpenFile |
openFile |
OBJECT_ALLOCATOR, REIFYING_OBJECT_ALLOCATOR
ALL_F, BASICOBJECT_ALLOCATOR, COMPARE_BY_IDENTITY_F, ERR_INSECURE_SET_INST_VAR, FALSE_F, FL_USHIFT, flags, FROZEN_F, metaClass, NEVER, NIL_F, TAINTED_F, UNDEF, UNTRUSTED_F, USER0_F, USER1_F, USER2_F, USER3_F, USER4_F, USER5_F, USER6_F, USER7_F, USER8_F
NULL_ARRAY
Constructor and Description |
---|
RubyIO(Ruby runtime,
java.nio.channels.Channel channel) |
RubyIO(Ruby runtime,
java.io.InputStream inputStream) |
RubyIO(Ruby runtime,
java.io.OutputStream outputStream) |
RubyIO(Ruby runtime,
RubyClass type) |
RubyIO(Ruby runtime,
ShellLauncher.POpenProcess process,
ModeFlags modes) |
RubyIO(Ruby runtime,
STDIO stdio) |
attachToObjectSpace, callInit, callInit, callInit, callInit, callInit, convertToType, createObjectClass, eqlInternal, equalInternal, equals, hashCode, initialize, op_eqq, puts, specificEval
addFinalizer, anyToString, asJavaString, asString, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callSuper, checkArrayType, checkCallMethod, checkFrozen, checkStringType, checkStringType19, compareTo, convertToArray, convertToFloat, convertToHash, convertToInteger, convertToInteger, convertToInteger, convertToString, copyInstanceVariablesInto, copySpecialInstanceVariables, createBasicObjectClass, dataGetStruct, dataGetStructChecked, dataWrapStruct, display, dup, ensureInstanceVariablesSettable, eql_p, eql, equal_p, equal_p19, evalUnder, extend, fastGetInstanceVariable, fastGetInternalVariable, fastHasInstanceVariable, fastHasInternalVariable, fastSetInstanceVariable, fastSetInternalVariable, freeze, frozen_p, getFlag, getInstanceEvalClass, getInstanceVariable, getInstanceVariableList, getInstanceVariableNameList, getInstanceVariables, getInternalVariable, getInternalVariables, getJavaClass, getMetaClass, getObjectId, getRuntime, getSingletonClass, getSingletonClassClone, getType, getVariable, getVariableCount, getVariableList, getVariableNameList, hash, hashyInspect, hasInstanceVariable, hasInternalVariable, hasVariables, id_deprecated, id, infectBy, initialize19, initialize19, initialize19, initialize19, initialize19, initObjectId, inspect, inspectHashCode, instance_eval, instance_eval, instance_eval, instance_eval, instance_eval19, instance_eval19, instance_eval19, instance_eval19, instance_exec, instance_exec19, instance_of_p, instance_variable_defined_p, instance_variable_get, instance_variable_set, instance_variables, instance_variables19, isBuiltin, isClass, isFalse, isFrozen, isImmediate, isModule, isNil, isTaint, isTrue, isUntrusted, kind_of_p, makeMetaClass, method_missing19, method, method19, methods, methods, methods19, nil_p, op_cmp, op_equal_19, op_equal, op_match, op_match19, op_not_equal, op_not_match, op_not, private_methods, private_methods19, protected_methods, protected_methods19, public_methods, public_methods19, rbClone, remove_instance_variable, removeFinalizers, removeInstanceVariable, removeInternalVariable, respond_to_p, respond_to_p, respond_to_p19, respond_to_p19, respondsTo, respondsToMissing, respondsToMissing, send, send, send, send, send, send19, send19, send19, send19, send19, setFlag, setFrozen, setInstanceVariable, setInternalVariable, setMetaClass, setTaint, setUntrusted, setVariable, singleton_method_added19, singleton_method_removed19, singleton_method_undefined19, singleton_methods, singleton_methods19, specificEval, specificEval, specificEval, specificEval, syncVariables, syncVariables, taint, taint, tainted_p, testFrozen, testFrozen, to_a, to_s, toJava, trust, type_deprecated, type, untaint, untrust, untrusted_p, validateInstanceVariable, variableTableContains, variableTableFastContains, variableTableFastFetch, variableTableFastStore, variableTableFetch, variableTableRemove, variableTableStore, variableTableSync, yieldUnder, yieldUnder
protected OpenFile openFile
protected java.util.List<RubyThread> blockingThreads
protected org.jcodings.Encoding externalEncoding
protected org.jcodings.Encoding internalEncoding
public RubyIO(Ruby runtime, java.io.OutputStream outputStream)
public RubyIO(Ruby runtime, java.io.InputStream inputStream)
public RubyIO(Ruby runtime, java.nio.channels.Channel channel)
public RubyIO(Ruby runtime, ShellLauncher.POpenProcess process, ModeFlags modes)
public OpenFile getOpenFile()
protected OpenFile getOpenFileChecked()
public int getNativeTypeIndex()
RubyObject
getNativeTypeIndex
in interface CoreObjectType
getNativeTypeIndex
in class RubyObject
org.jruby.runtime.ClassInde
public java.io.OutputStream getOutStream()
public java.io.InputStream getInStream()
public java.nio.channels.Channel getChannel()
@Deprecated public Stream getHandler() throws BadDescriptorException
BadDescriptorException
protected void reopenPath(Ruby runtime, IRubyObject[] args)
public IRubyObject reopen(ThreadContext context, IRubyObject[] args)
public static ModeFlags getIOModes(Ruby runtime, java.lang.String modesString) throws InvalidValueException
InvalidValueException
public static int getIOModesIntFromString(Ruby runtime, java.lang.String modesString)
public IRubyObject getline(Ruby runtime, org.jruby.util.ByteList separator)
public IRubyObject getline(Ruby runtime, org.jruby.util.ByteList separator, long limit)
protected boolean swallow(int term) throws java.io.IOException, BadDescriptorException
java.io.IOException
BadDescriptorException
public static boolean restartSystemCall(java.lang.Exception e)
public static IRubyObject newInstance(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block)
public IRubyObject initialize19(ThreadContext context, IRubyObject fileNumber, Block unusedBlock)
public IRubyObject initialize19(ThreadContext context, IRubyObject fileNumber, IRubyObject second, Block unusedBlock)
public IRubyObject initialize19(ThreadContext context, IRubyObject fileNumber, IRubyObject modeValue, IRubyObject options, Block unusedBlock)
protected ModeFlags parseModes(IRubyObject arg)
protected ModeFlags parseModes19(ThreadContext context, IRubyObject arg)
public IRubyObject initialize(IRubyObject[] args, Block unusedBlock)
protected Stream fdopen(ChannelDescriptor existingDescriptor, ModeFlags modes) throws InvalidValueException
InvalidValueException
public IRubyObject external_encoding(ThreadContext context)
public IRubyObject internal_encoding(ThreadContext context)
public IRubyObject set_encoding(ThreadContext context, IRubyObject encodingString)
public IRubyObject set_encoding(ThreadContext context, IRubyObject encodingString, IRubyObject internalEncoding)
public IRubyObject set_encoding(ThreadContext context, IRubyObject encodingString, IRubyObject internalEncoding, IRubyObject options)
public static IRubyObject open(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block)
public static IRubyObject sysopen(IRubyObject recv, IRubyObject[] args, Block block)
public static IRubyObject sysopen19(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block)
public boolean isAutoclose()
public void setAutoclose(boolean autoclose)
public IRubyObject autoclose(ThreadContext context)
public IRubyObject autoclose_set(ThreadContext context, IRubyObject autoclose)
public IRubyObject binmode()
public IRubyObject op_binmode(ThreadContext context)
public IRubyObject syswrite(ThreadContext context, IRubyObject obj)
public IRubyObject write_nonblock(ThreadContext context, IRubyObject obj)
public IRubyObject write(ThreadContext context, IRubyObject obj)
protected int fwrite(org.jruby.util.ByteList buffer)
public IRubyObject op_append(ThreadContext context, IRubyObject anObject)
public RubyFixnum fileno(ThreadContext context)
public RubyFixnum lineno(ThreadContext context)
public RubyFixnum lineno_set(ThreadContext context, IRubyObject newLineNumber)
newLineNumber
- The new line number.public RubyBoolean sync(ThreadContext context)
public IRubyObject pid(ThreadContext context)
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.
public RubyFixnum pos(ThreadContext context)
public RubyFixnum pos_set(ThreadContext context, IRubyObject newPosition)
public IRubyObject print(ThreadContext context, IRubyObject[] args)
public static IRubyObject print(ThreadContext context, IRubyObject maybeIO, IRubyObject[] args)
public IRubyObject printf(ThreadContext context, IRubyObject[] args)
public IRubyObject putc(ThreadContext context, IRubyObject object)
public static IRubyObject putc(ThreadContext context, IRubyObject maybeIO, IRubyObject object)
public RubyFixnum seek(ThreadContext context, IRubyObject[] args)
public RubyFixnum seek(ThreadContext context, IRubyObject arg0)
public RubyFixnum seek(ThreadContext context, IRubyObject arg0, IRubyObject arg1)
public RubyFixnum sysseek(ThreadContext context, IRubyObject[] args)
public RubyFixnum rewind(ThreadContext context)
public RubyFixnum fsync(ThreadContext context)
public IRubyObject sync_set(IRubyObject newSync)
newSync
- The new sync mode.public RubyBoolean eof_p(ThreadContext context)
public RubyBoolean tty_p(ThreadContext context)
public IRubyObject initialize_copy(IRubyObject original)
RubyBasicObject
initialize_copy
in class RubyBasicObject
public RubyBoolean closed_p(ThreadContext context)
public boolean isClosed()
public IRubyObject close()
Closes all open resources for the IO. It also removes it from our magical all open file descriptor pool.
protected IRubyObject close2(Ruby runtime)
public IRubyObject close_write(ThreadContext context)
public IRubyObject close_read(ThreadContext context)
public RubyIO flush()
public IRubyObject gets(ThreadContext context)
public IRubyObject gets(ThreadContext context, IRubyObject separatorArg)
public IRubyObject gets19(ThreadContext context)
public IRubyObject gets19(ThreadContext context, IRubyObject arg)
public IRubyObject gets19(ThreadContext context, IRubyObject separator, IRubyObject limit_arg)
public boolean getBlocking()
public IRubyObject fcntl(ThreadContext context, IRubyObject cmd)
public IRubyObject fcntl(ThreadContext context, IRubyObject cmd, IRubyObject arg)
public IRubyObject ioctl(ThreadContext context, IRubyObject[] args)
public IRubyObject ctl(Ruby runtime, IRubyObject cmd, IRubyObject arg)
public IRubyObject puts(ThreadContext context, IRubyObject[] args)
public static IRubyObject puts(ThreadContext context, IRubyObject maybeIO, IRubyObject[] args)
protected void write(ThreadContext context, org.jruby.util.ByteList byteList)
protected static void write(ThreadContext context, IRubyObject maybeIO, org.jruby.util.ByteList byteList)
public IRubyObject readline(ThreadContext context)
public IRubyObject readline(ThreadContext context, IRubyObject separator)
public IRubyObject getc()
public IRubyObject readchar19(ThreadContext context)
public IRubyObject getbyte19(ThreadContext context)
public IRubyObject readbyte(ThreadContext context)
public IRubyObject getc19(ThreadContext context)
public int getcCommon()
public IRubyObject ungetc(IRubyObject number)
Pushes char represented by int back onto IOS.
number
- to push backpublic IRubyObject ungetc19(IRubyObject number)
public IRubyObject read_nonblock(ThreadContext context, IRubyObject[] args)
public IRubyObject readpartial(ThreadContext context, IRubyObject[] args)
public IRubyObject sysread(ThreadContext context, IRubyObject[] args)
public IRubyObject read(IRubyObject[] args)
public IRubyObject read(ThreadContext context)
public IRubyObject read(ThreadContext context, IRubyObject arg0)
public IRubyObject read(ThreadContext context, IRubyObject arg0, IRubyObject arg1)
protected static boolean emptyBufferOrEOF(org.jruby.util.ByteList buffer, OpenFile myOpenFile) throws BadDescriptorException, java.io.IOException
BadDescriptorException
java.io.IOException
protected RubyString readAll(RubyString str) throws BadDescriptorException, java.io.EOFException, java.io.IOException
BadDescriptorException
java.io.EOFException
java.io.IOException
protected RubyString readAll() throws BadDescriptorException, java.io.EOFException, java.io.IOException
BadDescriptorException
java.io.EOFException
java.io.IOException
protected org.jruby.util.ByteList readAllCommon(Ruby runtime) throws BadDescriptorException, java.io.EOFException, java.io.IOException
BadDescriptorException
java.io.EOFException
java.io.IOException
public IRubyObject readchar()
public IRubyObject stat(ThreadContext context)
public IRubyObject each_byteInternal(ThreadContext context, Block block)
Invoke a block for each byte.
public IRubyObject each_byte(ThreadContext context, Block block)
public IRubyObject bytes(ThreadContext context)
public IRubyObject lines(ThreadContext context, Block block)
public IRubyObject lines19(ThreadContext context, Block block)
public IRubyObject each_charInternal(ThreadContext context, Block block)
public IRubyObject each_char(ThreadContext context, Block block)
public IRubyObject chars(ThreadContext context, Block block)
public IRubyObject codepoints(ThreadContext context, Block block)
public IRubyObject each_codepoint(ThreadContext context, Block block)
public RubyIO each_lineInternal(ThreadContext context, IRubyObject[] args, Block block)
Invoke a block for each line.
public IRubyObject each(ThreadContext context, IRubyObject[] args, Block block)
public IRubyObject each_line(ThreadContext context, IRubyObject[] args, Block block)
public RubyArray readlines(ThreadContext context, IRubyObject[] args)
public RubyIO to_io()
public java.lang.String toString()
RubyObject
toString
in class RubyObject
public static IRubyObject foreachInternal(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block)
public static IRubyObject foreachInternal19(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block)
public static IRubyObject foreach(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block)
public static IRubyObject foreach19(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block)
public static RubyIO convertToIO(ThreadContext context, IRubyObject obj)
public static IRubyObject select(ThreadContext context, IRubyObject recv, IRubyObject[] args)
public static IRubyObject select_static(ThreadContext context, Ruby runtime, IRubyObject[] args)
public static IRubyObject read(ThreadContext context, IRubyObject recv, IRubyObject[] args)
public static void failIfDirectory(Ruby runtime, RubyString pathStr)
@Deprecated public static IRubyObject read(ThreadContext context, IRubyObject recv, IRubyObject path, Block unusedBlock)
@Deprecated public static IRubyObject read(ThreadContext context, IRubyObject recv, IRubyObject path, IRubyObject length)
@Deprecated public static IRubyObject read(ThreadContext context, IRubyObject recv, IRubyObject path, IRubyObject length, IRubyObject offset)
public static IRubyObject readStatic(ThreadContext context, IRubyObject recv, IRubyObject path)
public static IRubyObject readStatic(ThreadContext context, IRubyObject recv, IRubyObject path, IRubyObject length)
public static IRubyObject readStatic(ThreadContext context, IRubyObject recv, IRubyObject path, IRubyObject length, IRubyObject offset)
public static IRubyObject binread(ThreadContext context, IRubyObject recv, IRubyObject[] args)
context
- the current ThreadContextrecv
- the target of the call (IO or a subclass)args
- arguments; path [, length [, offset]]public static IRubyObject read19(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block unusedBlock)
public static RubyArray readlines(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block unusedBlock)
public static IRubyObject popen(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block)
public static IRubyObject popen19(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block)
public static IRubyObject popen3(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block)
public static IRubyObject popen4(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block)
public static org.jruby.RubyIO.POpenTuple popenSpecial(ThreadContext context, IRubyObject[] args)
public static IRubyObject pipe(ThreadContext context, IRubyObject recv)
public static IRubyObject copy_stream(ThreadContext context, IRubyObject recv, IRubyObject arg1, IRubyObject arg2)
public static IRubyObject tryConvert(ThreadContext context, IRubyObject recv, IRubyObject arg)
public void addBlockingThread(RubyThread thread)
thread
- A thread blocking on this IOpublic void removeBlockingThread(RubyThread thread)
thread
- A thread blocking on this IOprotected void interruptBlockingThreads()
protected ModeFlags parseOptions(ThreadContext context, IRubyObject options, ModeFlags modes)
opt
can have the following keys
:mode ::
same as mode
parameter
:external_encoding ::
external encoding for the IO. "-" is a
synonym for the default external encoding.
:internal_encoding ::
internal encoding for the IO.
"-" is a synonym for the default internal encoding.
If the value is nil no conversion occurs.
:encoding ::
specifies external and internal encodings as "extern:intern".
:textmode ::
If the value is truth value, same as "b" in argument mode
.
:binmode ::
If the value is truth value, same as "t" in argument mode
.
Also opt
can have same keys in String#encode
for
controlling conversion between the external encoding and the internal encoding.public static void obliterateProcess(java.lang.Process process)
runtime
- The Ruby runtime, for raising an errorprocess
- The process to obliterate@Deprecated public void registerDescriptor(ChannelDescriptor descriptor, boolean isRetained)
@Deprecated public void registerDescriptor(ChannelDescriptor descriptor)
@Deprecated public void unregisterDescriptor(int aFileno)
@Deprecated public ChannelDescriptor getDescriptorByFileno(int aFileno)
@Deprecated public static int getNewFileno()
@Deprecated public boolean writeDataBuffered()
@Deprecated public IRubyObject gets(ThreadContext context, IRubyObject[] args)
@Deprecated public IRubyObject readline(ThreadContext context, IRubyObject[] args)
Copyright © 2002-2009 JRuby Team. All Rights Reserved.