Top Description Inners Fields Constructors Methods
org.jruby

public Class RubySymbol

extends RubyObject
implements MarshalEncoding, EncodingCapable, Constantizable, Appendable
Class Inheritance
All Implemented Interfaces
org.jruby.Appendable, org.jruby.compiler.Constantizable, org.jruby.runtime.encoding.EncodingCapable, org.jruby.runtime.encoding.MarshalEncoding
Annotations
@JRubyClass
name:Symbol
include:Enumerable
Imports
org.jcodings.Encoding, org.jcodings.specific.ASCIIEncoding, .USASCIIEncoding, org.jruby.anno.JRubyClass, .JRubyMethod, org.jruby.api.Create, org.jruby.ast.util.ArgsUtil, org.jruby.compiler.Constantizable, org.jruby.parser.StaticScope, org.jruby.runtime.ArgumentDescriptor, .Block, .BlockBody, .CallSite, .CallType, .ClassIndex, .ContextAwareBlockBody, .Helpers, .JavaSites, .MethodIndex, .Signature, .ThreadContext, org.jruby.runtime.builtin.IRubyObject, org.jruby.runtime.callsite.RefinedCachingCallSite, org.jruby.runtime.encoding.EncodingCapable, .MarshalEncoding, org.jruby.runtime.marshal.MarshalCommon, org.jruby.runtime.opto.OptoFactory, org.jruby.util.ByteList, .IdUtil, .PerlHash, .SipHashInline, .SymbolNameType, .TypeConverter, java.lang.ref.WeakReference, java.util.Map, java.util.concurrent.ConcurrentHashMap, java.util.concurrent.atomic.AtomicReferenceFieldUpdater, java.util.concurrent.locks.ReentrantLock

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

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
public static class
public static class

Field Summary

Modifier and TypeField and Description
private transient Object
private String
private final RubyString
private final int
private final int
private static final AtomicReferenceFieldUpdater<RubySymbol, RubyString>
private volatile RubyString
private final String
private final ByteList
public static final long
symbolHashSeedK0

Deprecated
private final SymbolNameType
Inherited from org.jruby.RubyObject:
IVAR_INSPECTING_OBJECT_ALLOCATOROBJECT_ALLOCATORREIFYING_OBJECT_ALLOCATOR

Constructor Summary

AccessConstructor and Description
private
RubySymbol(Ruby runtime, String
the String value of the new Symbol. This must have been previously interned
internedSymbol
,
ByteList
the ByteList of the symbol's string representation
symbolBytes
)

private
RubySymbol(Ruby runtime, String internedSymbol)

Method Summary

Modifier and TypeMethod and Description
public static IRubyObject
public static IRubyObject
all_symbols(IRubyObject recv)
Deprecated

public void
public RubySymbol
public final String

Returns:

a String representation of the symbol
asJavaString
()

Overrides org.jruby.RubyBasicObject.asJavaString.

Implements org.jruby.runtime.builtin.IRubyObject.asJavaString.

rb_to_id

public void
associateEncoding(Encoding encoding)

RubySymbol is created by passing in a String and bytes are extracted from that.

public RubyString
asString()

Overrides org.jruby.RubyBasicObject.asString.

Implements org.jruby.runtime.builtin.IRubyObject.asString.

rb_obj_as_string First converts this object into a String using the "to_s" method and returns it.

public RubySymbol

Returns:

the new symbol
asWriter
()

Make an instance variable out of this symbol (e.g. :foo will generate :foo=).

private RubyString
public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public static String
checkID(IRubyObject object)
Deprecated

public int
compareTo(final IRubyObject
another IRubyObject
that
)

Overrides org.jruby.RubyBasicObject.compareTo.

Implements java.lang.Comparable.compareTo.

Compares this Ruby object with another.

public Object
public static RubyClass
createSymbolClass(ThreadContext context, RubyClass Object, RubyModule Comparable)

public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public final boolean
eql(IRubyObject other)

Overrides org.jruby.RubyBasicObject.eql.

Implements org.jruby.runtime.builtin.IRubyObject.eql.

short circuit for Symbol key comparison

public boolean
equals(Object
object to compare
other
)

Overrides org.jruby.RubyObject.equals.

This override does not do a "checked" dispatch.

public RubyString
public final ByteList
public Encoding
public int
public Class<T>
getJavaClass()

Overrides org.jruby.RubyBasicObject.getJavaClass.

Implements org.jruby.runtime.builtin.IRubyObject.getJavaClass.

Will return the Java interface that most closely can represent this object, when working through Java integration translations.

public Encoding
private RubyString
public ClassIndex
getNativeClassIndex()

Overrides org.jruby.RubyObject.getNativeClassIndex.

Implements org.jruby.runtime.marshal.CoreObjectType.getNativeClassIndex.

This is overridden in the other concrete Java builtins to provide a fast way to determine what type they are.

public static RubySymbol
getSymbolLong(Ruby runtime, long id)

public RubyFixnum
hash(ThreadContext
the current thread context
context
)

Overrides org.jruby.RubyBasicObject.hash.

Will return the hash code of this object.

public int
hashCode()

Overrides org.jruby.RubyObject.hashCode.

This override does not do "checked" dispatch since Object usually has #hash defined.

public IRubyObject
id2name()
Deprecated since 9.4-.

public IRubyObject
public String
idString()

Return an id string (e.g. raw ISO-8859_1 charset String) for use with our method tables etc.

public static String
public static RubySymbol
pack-priv final RubyString
inspect(final Ruby runtime)
Deprecated

public IRubyObject
inspect(ThreadContext context)

Overrides org.jruby.RubyBasicObject.inspect.

Overrides default org.jruby.runtime.builtin.IRubyObject.inspect.

Returns a string containing a human-readable representation of obj.

private static boolean
isIdentChar(char c)

private static boolean
private static boolean
isIdentStart(char c)

public boolean
isImmediate()

Overrides org.jruby.RubyBasicObject.isImmediate.

Implements org.jruby.runtime.builtin.IRubyObject.isImmediate.

Is object immediate (def: Fixnum, Symbol, true, false, nil?).

private boolean
private static boolean
isSpecialGlobalName(String s)

is_special_global_name from parse.c.

private static boolean
isSymbolLocal(final String str, final char first, final int length)

private static boolean
isSymbolName(final String str)

private static boolean
isSymbolNameCommon(final String str, final char first, final int length)

private static int
public static int
public IRubyObject

Returns:

""
length
()
Deprecated since 10.0. Use RubySymbol#length(ThreadContext) instead.

public IRubyObject
public IRubyObject
match_m(ThreadContext context, IRubyObject other, Block block)

public IRubyObject
match_m(ThreadContext context, IRubyObject other, IRubyObject pos, Block block)

public IRubyObject
match_m(ThreadContext context, IRubyObject[] args, Block block)

public IRubyObject
public IRubyObject
public IRubyObject
public static RubySymbol
newCalleeSymbolFromCompound(Ruby runtime, String compoundName)

public static RubySymbol
newConstantSymbol(Ruby runtime, IRubyObject fqn, ByteList bytes)
Deprecated since 10.0.

public static RubySymbol

Returns:

a new or existing symbol
newConstantSymbol
(ThreadContext
the current thread context
context
,
IRubyObject
if this constant symbol is part of a broader chain this is used for full name error reporting.
fqn
,
ByteList
to be made into a symbol (or to help retreive existing symbol)
bytes
)

Create a symbol whose intention is to be used as a constant.

public static RubySymbol
public static RubySymbol
newHardSymbol(Ruby runtime, ByteList bytes)

public static RubySymbol
public static RubySymbol
newHardSymbol(Ruby runtime, String name)

public static RubySymbol
newHardSymbol(Ruby runtime, String name, Encoding encoding)

public static RubySymbol

Returns:

a new or existing symbol
newIDSymbol
(Ruby
of this Ruby instance.
runtime
,
ByteList
to be made into a symbol (or to help retreive existing symbol)
bytes
)

Generic identifier symbol creation (or retrieval) method.

public static RubySymbol

Returns:

a new or existing symbol
newIDSymbol
(Ruby
of this Ruby instance.
runtime
,
ByteList
to be made into a symbol (or to help retreive existing symbol)
bytes
,
RubySymbol.ObjBooleanConsumer<RubySymbol> handler)

Generic identifier symbol creation (or retrieval) method that invokes a handler before storing new symbols.

public static RubySymbol
newMethodSymbolFromCompound(Ruby runtime, String compoundName)

private RubyString
public static RubySymbol
newSymbol(Ruby runtime, IRubyObject name)
Deprecated

public static RubySymbol
newSymbol(Ruby runtime, String name)

public static RubySymbol
newSymbol(Ruby runtime, ByteList bytes)

public static RubySymbol
newSymbol(Ruby runtime, ByteList bytes, RubySymbol.ObjBooleanConsumer<RubySymbol> handler)

Return the symbol in the symbol table if it exists, null otherwise.

public static RubySymbol
newSymbol(Ruby runtime, String name, Encoding encoding)

public static String

Returns:

the symbol string associated with the object's string representation
objectToSymbolString
(IRubyObject
the object to symbolify
object
)

Properly stringify an object for the current "raw bytes" representation of a symbol.

public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
op_eqq(ThreadContext context, IRubyObject other)

Overrides org.jruby.RubyObject.op_eqq.

Implements org.jruby.runtime.builtin.IRubyObject.op_eqq.

rb_equal The Ruby "===" method is used by default in case/when statements.

public IRubyObject
op_equal(ThreadContext context, IRubyObject other)

Overrides org.jruby.RubyBasicObject.op_equal.

Implements org.jruby.runtime.builtin.IRubyObject.op_equal.

rb_obj_equal Will by default use identity equality to compare objects.

public IRubyObject
op_match(ThreadContext
the thread context
context
,
IRubyObject
arg
other
)

Overrides org.jruby.RubyBasicObject.op_match.

rb_obj_pattern_match call-seq: obj =~ other => nil Pattern Match---Overridden by descendents (notably Regexp and String) to provide meaningful pattern-match semantics.

public static IRubyObject

Returns:

the object, if it is a Symbol or String, or a String produced by calling #to_str on the object.
prepareID
(ThreadContext
the current context
context
,
IRubyObject
the object
object
)

Return the given object if it is a Symbol or String, or convert it to a String.

public static RubySymbol

Returns:

the symbol table entry.
retrieveIDSymbol
(IRubyObject
to get symbol table entry for (it may be a symbol already)
name
)

When we know we need an entry in the symbol table because the provided name will be needed to be accessed as a valid identifier later we can call this.

public static RubySymbol

Returns:

the symbol table entry.
retrieveIDSymbol
(IRubyObject
to get symbol table entry for (it may be a symbol already)
name
,
RubySymbol.ObjBooleanConsumer<RubySymbol> handler)

Retrieve an ID symbol but call the handler to verify the symbol is valid.

public void
public boolean
public RubyClass
singletonClass(ThreadContext
the current thread context
context
)

Overrides org.jruby.RubyBasicObject.singletonClass.

Overrides default org.jruby.runtime.builtin.IRubyObject.singletonClass.

Will either return the existing singleton class for this object, or create a new one and return that.

private static JavaSites.SymbolSites
sites(ThreadContext context)

Hides org.jruby.RubyObject.sites.

Retrieve the call sites for this class.

public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public static ByteList
symbolBytesFromString(Ruby runtime, String internedSymbol)

public IRubyObject
taint(ThreadContext context)

Overrides org.jruby.RubyBasicObject.taint.

Deprecated

public IRubyObject
public IRubyObject
pack-priv final RubyString
to_s(Ruby runtime)

public IRubyObject
public <T> T
toJava(Class<T>
The target type to which the object should be converted.
target
)

Overrides org.jruby.RubyBasicObject.toJava.

Implements org.jruby.runtime.builtin.IRubyObject.toJava.

Convert the object to the specified Java class, if possible.

public IRubyObject
public final String

Returns:

a String
toString
()

Overrides org.jruby.RubyObject.toString.

Print a string for internal debugging purposes.

public static RubySymbol
public static RubySymbol
unmarshalFrom(UnmarshalStream input, UnmarshalStream.MarshalState state)
Deprecated for removal since 10.0.

public IRubyObject
public IRubyObject
public IRubyObject
public boolean
validAttrsetName()

Is the string this symbol represents a valid attribute setter name.

public boolean
validClassVariableName()

Is the string this symbol represents a valid constant identifier name.

public boolean
validConstantName()

Is the string this symbol represents a valid constant identifier name.

public boolean
validInstanceVariableName()

Is the string this symbol represents a valid constant identifier name.

public boolean
Inherited from org.jruby.RubyObject:
attachToObjectSpacecallInitcallInitcallInitcallInitcallInitcallInitcallInitcallInitcallInitcallInitconvertToTypedigdig1dig2eqlInternalequalInternalfinishObjectClassinspectputsspecificEvaltoRubyString