org.jruby
Class RubySymbol

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

public class RubySymbol
extends RubyObject

Represents a Ruby symbol (e.g. :bar)

See Also:
Serialized Form

Nested Class Summary
static class RubySymbol.SymbolTable
           
 
Nested classes/interfaces inherited from class org.jruby.RubyObject
RubyObject.ObjectMethods
 
Nested classes/interfaces inherited from class org.jruby.RubyBasicObject
RubyBasicObject.BasicObjectMethods, RubyBasicObject.Finalizer, RubyBasicObject.VariableTableEntry
 
Field Summary
 
Fields inherited from class org.jruby.RubyObject
OBJECT_ALLOCATOR
 
Fields inherited from class org.jruby.RubyBasicObject
ALL_F, dataStruct, ERR_INSECURE_SET_INST_VAR, FALSE_F, FL_USHIFT, flags, FROZEN_F, metaClass, NEVER, NIL_F, 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
 
Method Summary
static IRubyObject all_symbols(IRubyObject recv)
           
 java.lang.String asJavaString()
          rb_to_id
 IRubyObject capitalize(ThreadContext context)
           
 IRubyObject casecmp(ThreadContext context, IRubyObject other)
           
static RubyClass createSymbolClass(Ruby runtime)
           
 IRubyObject downcase(ThreadContext context)
           
 IRubyObject empty_p(ThreadContext context)
           
 IRubyObject encoding(ThreadContext context)
           
 boolean eql(IRubyObject other)
          short circuit for Symbol key comparison
 boolean equals(java.lang.Object other)
          This method is just a wrapper around the Ruby "==" method, provided so that RubyObjects can be used as keys in the Java HashMap object underlying RubyHash.
 IRubyObject freeze(ThreadContext context)
          rb_obj_freeze call-seq: obj.freeze => obj Prevents further modifications to obj.
 int getId()
           
 int getNativeTypeIndex()
          This is overridden in the other concrete Java builtins to provide a fast way to determine what type they are.
 RubyClass getSingletonClass()
          rb_singleton_class Note: this method is specialized for RubyFixnum, RubySymbol, RubyNil and RubyBoolean Will either return the existing singleton class for this object, or create a new one and return that.
static RubySymbol getSymbolLong(Ruby runtime, long id)
           
 RubyFixnum hash()
          rb_obj_id Will return the hash code of this object.
 int hashCode()
          Override the Object#hashCode method to make sure that the Ruby hash is actually used as the hashcode for Ruby objects.
 IRubyObject id2name()
           
 IRubyObject inspect()
          rb_obj_inspect call-seq: obj.inspect => string Returns a string containing a human-readable representation of obj.
 boolean isImmediate()
          Is object immediate (def: Fixnum, Symbol, true, false, nil?).
 IRubyObject length()
           
static RubySymbol newSymbol(Ruby runtime, java.lang.String name)
           
 IRubyObject op_aref(ThreadContext context, IRubyObject arg)
           
 IRubyObject op_aref(ThreadContext context, IRubyObject arg1, IRubyObject arg2)
           
 IRubyObject op_cmp(ThreadContext context, IRubyObject other)
           
 IRubyObject op_eqq(ThreadContext context, IRubyObject other)
          rb_equal The Ruby "===" method is used by default in case/when statements.
 IRubyObject op_match19(ThreadContext context, IRubyObject other)
           
 IRubyObject succ(ThreadContext context)
           
 IRubyObject swapcase(ThreadContext context)
           
 IRubyObject taint(ThreadContext context)
          rb_obj_taint call-seq: obj.taint -> obj Marks obj as tainted---if the $SAFE level is set appropriately, many method calls which might alter the running programs environment will refuse to accept tainted strings.
 RubyFixnum to_i()
           
 RubyFixnum to_int()
           
 IRubyObject to_s()
          rb_any_to_s call-seq: obj.to_s => string Returns a string representing obj.
 IRubyObject to_sym()
           
static RubySymbol unmarshalFrom(UnmarshalStream input)
           
 IRubyObject upcase(ThreadContext context)
           
 
Methods inherited from class org.jruby.RubyObject
as, attachToObjectSpace, callInit, checkFrozen, convertToType, createObjectClass, display, dup, eql_p, eqlInternal, equal_p, equalInternal, evalUnder, evalUnder, extend, frozen_p, id_deprecated, id, initialize_copy, initialize, instance_eval, instance_eval, instance_eval, instance_eval, instance_eval, instance_exec, instance_of_p, instance_variable_defined_p, instance_variable_get, instance_variable_set, instance_variables, kind_of_p, method, methods, nil_p, op_equal, op_match, private_methods, protected_methods, public_methods, puts, rbClone, remove_instance_variable, respond_to_p, respond_to_p, send, send, send, send, send, singleton_methods, singleton_methods19, singletonMethods, specificEval, specificEval, specificEval, specificEval, specificEval, tainted_p, to_a, to_java, toString, type_deprecated, type, untaint, validateInstanceVariable
 
Methods inherited from class org.jruby.RubyBasicObject
addFinalizer, anyToString, asString, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callSuper, checkArrayType, checkStringType, convertToArray, convertToFloat, convertToHash, convertToInteger, convertToInteger, convertToInteger, convertToString, copyInstanceVariablesInto, copySpecialInstanceVariables, createBasicObjectClass, dataGetStruct, dataWrapStruct, ensureInstanceVariablesSettable, fastGetInstanceVariable, fastGetInternalVariable, fastHasInstanceVariable, fastHasInternalVariable, fastSetInstanceVariable, fastSetInternalVariable, getFlag, getInstanceVariable, getInstanceVariableList, getInstanceVariableNameList, getInstanceVariables, getInternalVariable, getInternalVariableList, getInternalVariables, getJavaClass, getMetaClass, getRuntime, getSingletonClassClone, getType, getVariableCount, getVariableList, getVariableMap, getVariableNameList, hasInstanceVariable, hasInternalVariable, hasVariables, infectBy, isClass, isFalse, isFrozen, isModule, isNil, isRubyVariable, isTaint, isTrue, makeMetaClass, op_not_equal, op_not, removeFinalizers, removeInstanceVariable, removeInternalVariable, respondsTo, setFlag, setFrozen, setInstanceVariable, setInternalVariable, setMetaClass, setTaint, syncVariables, taint, testFrozen, 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
 

Method Detail

createSymbolClass

public static RubyClass createSymbolClass(Ruby runtime)

getNativeTypeIndex

public int getNativeTypeIndex()
Description copied from class: RubyObject
This is overridden in the other concrete Java builtins to provide a fast way to determine what type they are. Will generally return a value from org.jruby.runtime.ClassIndex

Specified by:
getNativeTypeIndex in interface CoreObjectType
Overrides:
getNativeTypeIndex in class RubyObject
Returns:
the ClassIndex of the native type this object was constructed from
See Also:
org.jruby.runtime.ClassInde

asJavaString

public java.lang.String asJavaString()
rb_to_id

Specified by:
asJavaString in interface IRubyObject
Overrides:
asJavaString in class RubyBasicObject
Returns:
a String representation of the symbol

eql

public final boolean eql(IRubyObject other)
short circuit for Symbol key comparison

Specified by:
eql in interface IRubyObject
Overrides:
eql in class RubyBasicObject

isImmediate

public boolean isImmediate()
Description copied from class: RubyBasicObject
Is object immediate (def: Fixnum, Symbol, true, false, nil?).

Specified by:
isImmediate in interface IRubyObject
Overrides:
isImmediate in class RubyBasicObject
Returns:

getSingletonClass

public RubyClass getSingletonClass()
Description copied from class: RubyBasicObject
rb_singleton_class Note: this method is specialized for RubyFixnum, RubySymbol, RubyNil and RubyBoolean Will either return the existing singleton class for this object, or create a new one and return that.

Specified by:
getSingletonClass in interface IRubyObject
Overrides:
getSingletonClass in class RubyBasicObject
Returns:
RubyClass

getSymbolLong

public static RubySymbol getSymbolLong(Ruby runtime,
                                       long id)

newSymbol

public static RubySymbol newSymbol(Ruby runtime,
                                   java.lang.String name)

to_i

public RubyFixnum to_i()

to_int

public RubyFixnum to_int()

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

to_s

public IRubyObject to_s()
Description copied from class: RubyObject
rb_any_to_s call-seq: obj.to_s => string Returns a string representing obj. The default to_s prints the object's class and an encoding of the object id. As a special case, the top-level object that is the initial execution context of Ruby programs returns ``main.''

Overrides:
to_s in class RubyObject

id2name

public IRubyObject id2name()

op_eqq

public IRubyObject op_eqq(ThreadContext context,
                          IRubyObject other)
Description copied from class: RubyObject
rb_equal The Ruby "===" method is used by default in case/when statements. The Object implementation first checks Java identity equality and then calls the "==" method too.

Specified by:
op_eqq in interface IRubyObject
Overrides:
op_eqq in class RubyObject

hash

public RubyFixnum hash()
Description copied from class: RubyObject
rb_obj_id Will return the hash code of this object. In comparison to MRI, this method will use the Java identity hash code instead of using rb_obj_id, since the usage of id in JRuby will incur the cost of some. ObjectSpace maintenance.

Overrides:
hash in class RubyObject

hashCode

public int hashCode()
Description copied from class: RubyObject
Override the Object#hashCode method to make sure that the Ruby hash is actually used as the hashcode for Ruby objects. If the Ruby "hash" method doesn't return a number, the Object#hashCode implementation will be used instead.

Overrides:
hashCode in class RubyObject

getId

public int getId()

equals

public boolean equals(java.lang.Object other)
Description copied from class: RubyObject
This method is just a wrapper around the Ruby "==" method, provided so that RubyObjects can be used as keys in the Java HashMap object underlying RubyHash.

Overrides:
equals in class RubyObject

to_sym

public IRubyObject to_sym()

freeze

public IRubyObject freeze(ThreadContext context)
Description copied from class: RubyObject
rb_obj_freeze call-seq: obj.freeze => obj Prevents further modifications to obj. A TypeError will be raised if modification is attempted. There is no way to unfreeze a frozen object. See also Object#frozen?. a = [ "a", "b", "c" ] a.freeze a << "z" produces: prog.rb:3:in `<<': can't modify frozen array (TypeError) from prog.rb:3

Overrides:
freeze in class RubyObject

taint

public IRubyObject taint(ThreadContext context)
Description copied from class: RubyObject
rb_obj_taint call-seq: obj.taint -> obj Marks obj as tainted---if the $SAFE level is set appropriately, many method calls which might alter the running programs environment will refuse to accept tainted strings.

Overrides:
taint in class RubyObject

succ

public IRubyObject succ(ThreadContext context)

op_cmp

public IRubyObject op_cmp(ThreadContext context,
                          IRubyObject other)

casecmp

public IRubyObject casecmp(ThreadContext context,
                           IRubyObject other)

op_match19

public IRubyObject op_match19(ThreadContext context,
                              IRubyObject other)

op_aref

public IRubyObject op_aref(ThreadContext context,
                           IRubyObject arg)

op_aref

public IRubyObject op_aref(ThreadContext context,
                           IRubyObject arg1,
                           IRubyObject arg2)

length

public IRubyObject length()

empty_p

public IRubyObject empty_p(ThreadContext context)

upcase

public IRubyObject upcase(ThreadContext context)

downcase

public IRubyObject downcase(ThreadContext context)

capitalize

public IRubyObject capitalize(ThreadContext context)

swapcase

public IRubyObject swapcase(ThreadContext context)

encoding

public IRubyObject encoding(ThreadContext context)

all_symbols

public static IRubyObject all_symbols(IRubyObject recv)

unmarshalFrom

public static RubySymbol unmarshalFrom(UnmarshalStream input)
                                throws java.io.IOException
Throws:
java.io.IOException


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