org.jruby
Class RubyFile

java.lang.Object
  extended by org.jruby.RubyObject
      extended by org.jruby.RubyIO
          extended by org.jruby.RubyFile
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, InstanceVariables, InternalVariables, IRubyObject, CoreObjectType

public class RubyFile
extends RubyIO

Ruby File class equivalent in java.

See Also:
Serialized Form

Nested Class Summary
static class RubyFile.Constants
           
 
Nested classes/interfaces inherited from class org.jruby.RubyObject
RubyObject.Finalizer, RubyObject.ObjectMethods, RubyObject.VariableTableEntry
 
Field Summary
static int LOCK_EX
           
static int LOCK_NB
           
static int LOCK_SH
           
static int LOCK_UN
           
protected  java.lang.String path
           
 
Fields inherited from class org.jruby.RubyIO
filenoIndex, openFile
 
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
 
Fields inherited from interface org.jruby.runtime.builtin.IRubyObject
NULL_ARRAY
 
Constructor Summary
RubyFile(Ruby runtime, RubyClass type)
           
RubyFile(Ruby runtime, java.lang.String path, java.io.InputStream in)
           
RubyFile(Ruby runtime, java.lang.String path, java.io.Reader reader)
           
 
Method Summary
 IRubyObject atime()
           
static IRubyObject atime(IRubyObject recv, IRubyObject filename)
           
static IRubyObject basename(IRubyObject recv, IRubyObject[] args)
           
 IRubyObject chmod(IRubyObject arg)
           
static IRubyObject chmod(IRubyObject recv, IRubyObject[] args)
           
 IRubyObject chown(IRubyObject arg1, IRubyObject arg2)
           
static IRubyObject chown(IRubyObject recv, IRubyObject[] args)
           
 IRubyObject close()
          Closes all open resources for the IO.
static RubyClass createFileClass(Ruby runtime)
           
 IRubyObject ctime()
           
static IRubyObject ctime(IRubyObject recv, IRubyObject filename)
           
static IRubyObject dirname(IRubyObject recv, IRubyObject arg)
           
static IRubyObject expand_path(ThreadContext context, IRubyObject recv, IRubyObject[] args)
          Converts a pathname to an absolute pathname.
static java.lang.String expandUserPath(ThreadContext context, java.lang.String path)
          This method checks a path, and if it starts with ~, then it expands the path to the absolute path of the user's home directory.
static IRubyObject extname(IRubyObject recv, IRubyObject arg)
          Returns the extension name of the file.
 IRubyObject flock(IRubyObject lockingConstant)
           
static IRubyObject fnmatch(IRubyObject recv, IRubyObject[] args)
          Returns true if path matches against pattern The pattern is not a regular expression; instead it follows rules similar to shell filename globbing.
static IRubyObject ftype(IRubyObject recv, IRubyObject filename)
           
 IRubyObject initialize(IRubyObject[] args, Block block)
           
 IRubyObject inspect()
          rb_obj_inspect call-seq: obj.inspect => string Returns a string containing a human-readable representation of obj.
static RubyString join(IRubyObject recv, IRubyObject[] args)
           
 IRubyObject lchmod(IRubyObject arg)
           
static IRubyObject lchmod(IRubyObject recv, IRubyObject[] args)
           
 IRubyObject lchown(IRubyObject arg1, IRubyObject arg2)
           
static IRubyObject lchown(IRubyObject recv, IRubyObject[] args)
           
static IRubyObject link(IRubyObject recv, IRubyObject from, IRubyObject to)
           
 IRubyObject lstat()
           
static IRubyObject lstat(IRubyObject recv, IRubyObject filename)
           
 IRubyObject mtime()
           
static IRubyObject mtime(IRubyObject recv, IRubyObject filename)
           
 RubyString path()
           
static IRubyObject readlink(IRubyObject recv, IRubyObject path)
           
static IRubyObject rename(IRubyObject recv, IRubyObject oldName, IRubyObject newName)
           
static RubyArray split(IRubyObject recv, IRubyObject arg)
           
 IRubyObject stat()
           
static IRubyObject stat(IRubyObject recv, IRubyObject filename)
           
static IRubyObject symlink(IRubyObject recv, IRubyObject from, IRubyObject to)
           
 java.lang.String toString()
          The default toString method is just a wrapper that calls the Ruby "to_s" method.
 IRubyObject truncate(IRubyObject arg)
           
static IRubyObject truncate(ThreadContext context, IRubyObject recv, IRubyObject arg1, IRubyObject arg2)
           
static IRubyObject umask(IRubyObject recv, IRubyObject[] args)
           
static IRubyObject unlink(IRubyObject recv, IRubyObject[] args)
           
static IRubyObject utime(IRubyObject recv, IRubyObject[] args)
          This method does NOT set atime, only mtime, since Java doesn't support anything else.
 
Methods inherited from class org.jruby.RubyIO
binmode, checkClosed, checkInitialized, close_read, close_write, close2, closed_p, copy_stream, createIOClass, ctl, each_byte, each_line, eof_p, fcntl, fdopen, fileno, flush, foreach, fsync, fwrite, getBlocking, getc, getChannel, getDescriptorByFileno, getHandler, getInStream, getIOModes, getIOModesIntFromString, getline, getlineFast, getNewFileno, getOpenFile, getOpenFileChecked, getOutStream, gets, initialize_copy, ioctl, lineno_set, lineno, newInstance, op_append, open, pid, pipe, popen, pos_set, pos, print, printf, putc, puts, read_nonblock, read, read, readAll, readchar, readline, readlines, readlines, readpartial, registerDescriptor, reopen, rewind, seek, select_static, select, swallow, sync_set, sync, sysread, sysseek, syswrite, to_io, tty_p, ungetc, unregisterDescriptor, waitReadable, waitWritable, write_nonblock, write, write, writeDataBuffered
 
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, 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
 

Field Detail

LOCK_SH

public static final int LOCK_SH
See Also:
Constant Field Values

LOCK_EX

public static final int LOCK_EX
See Also:
Constant Field Values

LOCK_NB

public static final int LOCK_NB
See Also:
Constant Field Values

LOCK_UN

public static final int LOCK_UN
See Also:
Constant Field Values

path

protected java.lang.String path
Constructor Detail

RubyFile

public RubyFile(Ruby runtime,
                RubyClass type)

RubyFile

public RubyFile(Ruby runtime,
                java.lang.String path,
                java.io.Reader reader)

RubyFile

public RubyFile(Ruby runtime,
                java.lang.String path,
                java.io.InputStream in)
Method Detail

createFileClass

public static RubyClass createFileClass(Ruby runtime)

close

public IRubyObject close()
Description copied from class: RubyIO

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

Overrides:
close in class RubyIO
Returns:
The IO.

flock

public IRubyObject flock(IRubyObject lockingConstant)

initialize

public IRubyObject initialize(IRubyObject[] args,
                              Block block)
Overrides:
initialize in class RubyIO

chmod

public IRubyObject chmod(IRubyObject arg)

chown

public IRubyObject chown(IRubyObject arg1,
                         IRubyObject arg2)

atime

public IRubyObject atime()

ctime

public IRubyObject ctime()

lchmod

public IRubyObject lchmod(IRubyObject arg)

lchown

public IRubyObject lchown(IRubyObject arg1,
                          IRubyObject arg2)

lstat

public IRubyObject lstat()

mtime

public IRubyObject mtime()

path

public RubyString path()

stat

public IRubyObject stat()
Overrides:
stat in class RubyIO

truncate

public IRubyObject truncate(IRubyObject arg)

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 RubyIO

inspect

public IRubyObject inspect()
Description copied from class: RubyObject
rb_obj_inspect call-seq: obj.inspect => string Returns a string containing a human-readable representation of obj. If not overridden, uses the to_s method to generate the string. [ 1, 2, 3..4, 'five' ].inspect #=> "[1, 2, 3..4, \"five\"]" Time.new.inspect #=> "Wed Apr 09 08:54:39 CDT 2003"

Specified by:
inspect in interface IRubyObject
Overrides:
inspect in class RubyObject
Returns:
String

basename

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

chmod

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

chown

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

dirname

public static IRubyObject dirname(IRubyObject recv,
                                  IRubyObject arg)

extname

public static IRubyObject extname(IRubyObject recv,
                                  IRubyObject arg)
Returns the extension name of the file. An empty string is returned if the filename (not the entire path) starts or ends with a dot.

Parameters:
recv -
arg - Path to get extension name of
Returns:
Extension, including the dot, or an empty string

expand_path

public static IRubyObject expand_path(ThreadContext context,
                                      IRubyObject recv,
                                      IRubyObject[] args)
Converts a pathname to an absolute pathname. Relative paths are referenced from the current working directory of the process unless a second argument is given, in which case it will be used as the starting point. If the second argument is also relative, it will first be converted to an absolute pathname.

Parameters:
recv -
args -
Returns:
Resulting absolute path as a String

expandUserPath

public static java.lang.String expandUserPath(ThreadContext context,
                                              java.lang.String path)
This method checks a path, and if it starts with ~, then it expands the path to the absolute path of the user's home directory. If the string does not begin with ~, then the string is simply returned. unaltered.

Parameters:
recv -
path - Path to check
Returns:
Expanded path

fnmatch

public static IRubyObject fnmatch(IRubyObject recv,
                                  IRubyObject[] args)
Returns true if path matches against pattern The pattern is not a regular expression; instead it follows rules similar to shell filename globbing. It may contain the following metacharacters: *: Glob - match any sequence chars (re: .*). If like begins with '.' then it doesn't. ?: Matches a single char (re: .). [set]: Matches a single char in a set (re: [...]).


ftype

public static IRubyObject ftype(IRubyObject recv,
                                IRubyObject filename)

join

public static RubyString join(IRubyObject recv,
                              IRubyObject[] args)

lstat

public static IRubyObject lstat(IRubyObject recv,
                                IRubyObject filename)

stat

public static IRubyObject stat(IRubyObject recv,
                               IRubyObject filename)

atime

public static IRubyObject atime(IRubyObject recv,
                                IRubyObject filename)

ctime

public static IRubyObject ctime(IRubyObject recv,
                                IRubyObject filename)

lchmod

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

lchown

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

link

public static IRubyObject link(IRubyObject recv,
                               IRubyObject from,
                               IRubyObject to)

mtime

public static IRubyObject mtime(IRubyObject recv,
                                IRubyObject filename)

rename

public static IRubyObject rename(IRubyObject recv,
                                 IRubyObject oldName,
                                 IRubyObject newName)

split

public static RubyArray split(IRubyObject recv,
                              IRubyObject arg)

symlink

public static IRubyObject symlink(IRubyObject recv,
                                  IRubyObject from,
                                  IRubyObject to)

readlink

public static IRubyObject readlink(IRubyObject recv,
                                   IRubyObject path)

truncate

public static IRubyObject truncate(ThreadContext context,
                                   IRubyObject recv,
                                   IRubyObject arg1,
                                   IRubyObject arg2)

umask

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

utime

public static IRubyObject utime(IRubyObject recv,
                                IRubyObject[] args)
This method does NOT set atime, only mtime, since Java doesn't support anything else.


unlink

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


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