Top Description Inners Fields Constructors Methods
org.jruby

public Class RubyString

extends RubyObject
implements CharSequence, EncodingCapable, MarshalEncoding, CodeRangeable, Appendable
Class Inheritance
All Implemented Interfaces
org.jruby.Appendable, org.jruby.util.CodeRangeable, org.jruby.util.ByteListHolder, org.jruby.runtime.encoding.MarshalEncoding, org.jruby.runtime.encoding.EncodingCapable, java.lang.CharSequence
Known Direct Subclasses
org.jruby.RubyString.DebugFrozenString, org.jruby.RubyString.DebugChilledString, org.jruby.RubyString.FString
Annotations
@JRubyClass
name:String
include:Enumerable, Comparable
Imports
jnr.posix.POSIX, org.jcodings.Config, .Encoding, .IntHolder, org.jcodings.exception.EncodingException, org.jcodings.specific.ASCIIEncoding, .USASCIIEncoding, .UTF16BEEncoding, .UTF16LEEncoding, .UTF32BEEncoding, .UTF32LEEncoding, .UTF8Encoding, org.jcodings.unicode.UnicodeEncoding, org.joni.Matcher, .Option, .Regex, .Region, org.jruby.anno.JRubyClass, .JRubyMethod, org.jruby.api.Create, .JRubyAPI, org.jruby.ast.util.ArgsUtil, org.jruby.exceptions.JumpException, org.jruby.platform.Platform, org.jruby.runtime.Arity, .Block, .BlockCallback, .CallBlock19, .CallSite, .ClassIndex, .Helpers, .JavaSites, .JavaSites.StringSites, .Signature, .ThreadContext, .Visibility, org.jruby.runtime.builtin.IRubyObject, org.jruby.runtime.encoding.EncodingCapable, .MarshalEncoding, org.jruby.runtime.marshal.MarshalLoader, org.jruby.util.ByteList, .CodeRangeSupport, .CodeRangeable, .ConvertBytes, .Numeric, .Pack, .PerlHash, .RegexpOptions, .SipHashInline, .Sprintf, .StringSupport, .TypeConverter, org.jruby.util.io.EncodingUtils, .RubyInputStream, java.nio.charset.Charset, java.util.Arrays, .Locale, java.util.function.Function

Implementation of Ruby String class Concurrency: no synchronization is required among readers, but all users must synchronize externally with writers.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
pack-priv static class
public static class
RubyString.EmptyByteListHolder

Encoding aware String construction routines for 1.9

public static class
RubyString.FString

An FString is a frozen string that is also deduplicated and cached.

private static class

Field Summary

Modifier and TypeField and Description
pack-priv static final ASCIIEncoding
private static final ByteList
private static RubyString.EmptyByteListHolder[]
private static final ByteList
private static final byte[]
private static final ByteList
private static final byte[]
public static RubyString[]
private static final Regex
REPL_MOCK_REGEX

A Regex instance is required to satisfy the type signature of RubyRegexp.regsub In the code paths possible for a string pattern a single instance of a blank regex is enough.

private static final byte[]
private static final byte[]
private static final byte[]
private static final byte[]
private static final byte[]
private static final byte[]
private static final int
private static final int
private static final int
protected volatile int
private static final ByteList
private static final int
private static final ByteList
pack-priv static final UTF8Encoding
private ByteList
Inherited from org.jruby.RubyObject:
IVAR_INSPECTING_OBJECT_ALLOCATOROBJECT_ALLOCATORREIFYING_OBJECT_ALLOCATOR

Constructor Summary

AccessConstructor and Description
public
RubyString(Ruby runtime, RubyClass rubyClass)

public
RubyString(Ruby runtime, RubyClass rubyClass, CharSequence value)

public
RubyString(Ruby runtime, RubyClass rubyClass, CharSequence value, Encoding enc)

private
RubyString(Ruby runtime, RubyClass rubyClass, String value, Encoding enc)

private
RubyString(Ruby runtime, RubyClass rubyClass, String value, Encoding enc, boolean objectspace)

public
RubyString(Ruby runtime, RubyClass rubyClass, byte[] value)

public
RubyString(Ruby runtime, RubyClass rubyClass, ByteList value)

public
RubyString(Ruby runtime, RubyClass rubyClass, ByteList value, boolean objectSpace)

public
RubyString(Ruby runtime, RubyClass rubyClass, ByteList value, Encoding encoding, boolean objectSpace)

protected
RubyString(Ruby runtime, RubyClass rubyClass, ByteList value, Encoding enc, int cr)

protected
RubyString(Ruby runtime, RubyClass rubyClass, ByteList value, Encoding enc)

protected
RubyString(Ruby runtime, RubyClass rubyClass, ByteList value, int cr)

protected
RubyString(Ruby runtime, RubyClass rubyClass, ByteList value, int cr, boolean objectspace)

Method Summary

Modifier and TypeMethod and Description
public RubyString
append(IRubyObject other, Function<IRubyObject, RubyString> convert)

rb_str_append

public RubyString
public RubyString
public RubyString
append19(IRubyObject other)
Deprecated

pack-priv final RubyString
public IRubyObject
public IRubyObject
public IRubyObject
public RubyString
public RubyString
private void
public void
public IRubyObject
pack-priv static int
asciiIndexOf(byte[] source, int sourceOffset, int sourceCount, byte[] target, int targetOffset, int targetCount, int fromIndex)

private RubyArray<T extends IRubyObject>
asciiStringSplit(ThreadContext context, ByteList pattern, boolean limit, int lim)

private RubyArray<T extends IRubyObject>
asciiStringSplitOne(ThreadContext context, byte pat, boolean limit, int lim)

public String
public void
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.

private static boolean
atCharacterBoundary(byte[] bytes, int p, int e, int s, Encoding enc)

private static boolean
atCharBoundary(byte[] bytes, int s, int p, int e, Encoding enc)

private RubyArray<T extends IRubyObject>
awkSplit(final ThreadContext context, boolean limit, int lim)

public IRubyObject
b(ThreadContext context)

private IRubyObject
private static int
public IRubyObject
public IRubyObject
private IRubyObject
byteIndexCommon(ThreadContext context, IRubyObject sub, int pos)

public static String
public IRubyObject
public IRubyObject
private IRubyObject
byterindexCommon(ThreadContext context, final IRubyObject sub, int pos)

public IRubyObject
bytes(ThreadContext context, Block block)

public RubyFixnum
public RubyFixnum
bytesize()
Deprecated

private static IRubyObject
byteSize(ThreadContext context, RubyString recv, IRubyObject[] args)

A byte size method suitable for lambda method reference implementation of SizeFn#size(ThreadContext, IRubyObject, IRubyObject[])

public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
private RubyString
bytespliceCommon(RubyString val, int beg, int len, int vbeg, int vlen)

private RubyString
private RubyString
public static String
bytesToString(byte[] bytes, int beg, int len)

public static String
bytesToString(byte[] bytes)

private IRubyObject
byteSubstr(ThreadContext context, long beg, long len)

public int

Returns:

the amount of capacity in this string's buffer after the begin offset
capacity
()

Determine how much space exists after the begin offset in this string's buffer.

public RubyString
capitalize(ThreadContext context)

rb_str_capitalize / rb_str_capitalize_bang

public RubyString
public RubyString
public IRubyObject
public IRubyObject
public IRubyObject
private IRubyObject
capitalize_bang(ThreadContext context, int flags)

public IRubyObject
public IRubyObject
private int
caseMap(ThreadContext context, int flags, Encoding enc)

public final RubyString
cat(byte[] str)

public final RubyString
cat(byte[] str, int beg, int len)

public final RubyString
cat(ByteList other, int codeRange)

public final RubyString
public final RubyString
public final RubyString
cat(byte ch)

public final RubyString
cat(int ch)

public final RubyString
cat(int code, Encoding enc)

public final int
cat(byte[] bytes, int p, int len, Encoding enc)

public final RubyString
cat19(RubyString str2)
Deprecated

public final int
cat19(ByteList other, int codeRange)
Deprecated

public final RubyString
catAscii(byte[] bytes, int ptr, int ptrLen)

public final RubyString
public final RubyString

Returns:

this string after it has appended str
catStringUnsafe
(String
to be appended
str
)

Append a Java String to this RubyString assuming it will be the encoding of the RubyString.

public final RubyString
public final int
catWithCodeRange(ByteList other, int codeRange)

public IRubyObject
center(IRubyObject arg0)
Deprecated since 10.0.

public IRubyObject
center(ThreadContext context, IRubyObject arg0)

rb_str_center

public IRubyObject
center(IRubyObject arg0, IRubyObject arg1)
Deprecated since 10.0.

public IRubyObject
public char
charAt(int
the index of the char value to be returned
offset
)

Implements java.lang.CharSequence.charAt.

Returns the char value at the specified index.

public IRubyObject
chars(ThreadContext context, Block block)

private void
checkBegLen(ThreadContext context, int[] beglen)

private void
checkBegLenPositions(ThreadContext context, int beg, int len)

private Encoding
public final Encoding
pack-priv final Encoding
checkEncoding(EncodingCapable other)
Deprecated since 10.0.

public final Encoding
public static Encoding
checkEncoding(final Ruby runtime, ByteList str1, ByteList str2)

public void
checkFrozen()

Overrides org.jruby.RubyBasicObject.checkFrozen.

The actual method that checks frozen with the default frozen message from MRI.

private int
checkIndexForRef(ThreadContext context, int beg, int len)

private int
checkLength(ThreadContext context, int len)

private static void
checkNegativeSize(Ruby runtime, int size)

public IRubyObject
checkStringType()

Overrides org.jruby.RubyBasicObject.checkStringType.

Implements org.jruby.runtime.builtin.IRubyObject.checkStringType.

rb_check_string_type Tries to return a coerced string representation of this object, using "to_str".

public RubyString
public RubyString
public RubyString
chomp(ThreadContext context)

rb_str_chomp_bang In the common case, removes CR and LF characters in various ways depending on the value of the optional args[0].

public RubyString
public RubyString
chomp19(ThreadContext context)
Deprecated

public RubyString
chomp19(ThreadContext context, IRubyObject arg0)
Deprecated

public IRubyObject
public IRubyObject
public IRubyObject
chomp_bang19(ThreadContext context)
Deprecated

public IRubyObject
chomp_bang19(ThreadContext context, IRubyObject arg0)
Deprecated

private IRubyObject
public IRubyObject
chop(ThreadContext context)

rb_str_chop / rb_str_chop_bang

public IRubyObject
public IRubyObject
chr(ThreadContext context)

public RubyString
clear()
Deprecated since 10.0.

public RubyString
public final void
private boolean
public IRubyObject
codepoints(ThreadContext context, Block block)

private static IRubyObject
codepointSize(ThreadContext context, RubyString recv, IRubyObject[] args)

A codepoint size method suitable for lambda method reference implementation of SizeFn#size(ThreadContext, IRubyObject, IRubyObject[])

pack-priv int
coderangeAnd(int a, int b)

public final int
compareTo(IRubyObject
another IRubyObject
other
)

Overrides org.jruby.RubyBasicObject.compareTo.

Implements java.lang.Comparable.compareTo.

Compares this Ruby object with another.

public RubyString
concat(ThreadContext context, IRubyObject obj)

rb_str_concat

public RubyString
concat(ThreadContext context, IRubyObject[] objs)

rb_str_concat_multi

public RubyString
private RubyString
concatNumeric(ThreadContext context, int c)

public RubyString
concatSingle(ThreadContext context, IRubyObject other)

rb_str_concat

public RubyString
convertToString()

Overrides org.jruby.RubyBasicObject.convertToString.

Implements org.jruby.runtime.builtin.IRubyObject.convertToString.

Tries to convert this object to a Ruby String using the "to_str" method.

private void
public IRubyObject
public IRubyObject
public IRubyObject
count(ThreadContext context, IRubyObject[] args)

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

public RubyString
crypt(ThreadContext context, IRubyObject other)

rb_str_crypt

public String

Returns:

A decoded Java String, based on this Ruby string's encoding.
decodeString
()

Convert this Ruby string to a Java String.

public IRubyObject
delete(ThreadContext context)

rb_str_delete / rb_str_delete_bang

public IRubyObject
public IRubyObject
delete(ThreadContext context, IRubyObject[] args)

public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
private int
private int
private Object
public IRubyObject
public RubyString
downcase(ThreadContext context)

rb_str_downcase / rb_str_downcase_bang

public RubyString
public RubyString
public IRubyObject
public IRubyObject
public IRubyObject
private IRubyObject
downcase_bang(ThreadContext context, int flags)

private void
dropBytes(int prefixlen)

public IRubyObject
dump()
Deprecated since 10.0.

public IRubyObject
dump(ThreadContext context)

rb_str_dump

public IRubyObject

Returns:

A new RubyString sharing the original backing store.
dup
()

Overrides org.jruby.RubyBasicObject.dup.

Implements org.jruby.runtime.builtin.IRubyObject.dup.

Overridden dup for fast-path logic.

public IRubyObject
dup(ThreadContext
the thread context
context
)

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

RubyMethod dup.

public final RubyString
dupAsChilled(Ruby runtime, RubyClass clazz, String file, int line)

public RubyString.FString
dupAsFString(Ruby runtime)

public IRubyObject
public IRubyObject
each_byte(ThreadContext context, Block block)

rb_str_each_byte

public IRubyObject
each_char(ThreadContext context, Block block)

public IRubyObject
each_codepoint(ThreadContext context, Block block)

rb_str_each_codepoint

public IRubyObject
public IRubyObject
each_line(ThreadContext context, Block block)

rb_str_each_line

public IRubyObject
public IRubyObject
public IRubyObject
each_lineCommon(ThreadContext context, IRubyObject sep, Block block)
Deprecated

private static IRubyObject
eachCharSize(ThreadContext context, RubyString recv, IRubyObject[] args)

A character size method suitable for lambda method reference implementation of SizeFn#size(ThreadContext, IRubyObject, IRubyObject[])

private static IRubyObject
eachGraphemeClusterSize(ThreadContext context, RubyString self, IRubyObject[] args)

A grapheme cluster size method suitable for lambda method reference implementation of SizeFn#size(ThreadContext, IRubyObject, IRubyObject[])

public void
public RubyBoolean
empty_p(ThreadContext context)

rb_str_empty

public IRubyObject
public IRubyObject
public IRubyObject
encode(ThreadContext context, IRubyObject toEncoding, IRubyObject arg)

public IRubyObject
encode(ThreadContext context, IRubyObject toEncoding, IRubyObject forcedEncoding, IRubyObject opts)

public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
encode_bang(ThreadContext context, IRubyObject[] args)
Deprecated

public static ByteList
pack-priv static ByteList
encodeBytelist(String value, Encoding encoding)

public IRubyObject
public IRubyObject
encStrScrub(ThreadContext context, Encoding enc, IRubyObject repl, Block block)

public IRubyObject
encStrScrub(ThreadContext context, Encoding enc, IRubyObject repl, int cr, Block block)

public IRubyObject
public IRubyObject
public IRubyObject
public boolean
protected boolean
public void
ensureAvailable(ThreadContext
the current thread context
context
,
int
the extra length needed
extraLength
)

Ensure the backing store belongs to this string and has enough space to add extraLength bytes.

private void
public final void
ensureInstanceVariablesSettable()

Overrides org.jruby.RubyBasicObject.ensureInstanceVariablesSettable.

Makes sure that instance variables can be set on this object, including information about whether this object is frozen.

private IRubyObject
enumerateBytes(ThreadContext context, String name, Block block, boolean wantarray)

private IRubyObject
enumerateChars(ThreadContext context, String name, Block block, boolean wantarray)

private IRubyObject
enumerateCodepoints(ThreadContext context, String name, Block block, boolean wantarray)

private IRubyObject
enumerateGraphemeClusters(ThreadContext context, String name, Block block, boolean wantarray)

public final boolean
eql(IRubyObject other)

Overrides org.jruby.RubyBasicObject.eql.

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

short circuit for String key comparison

private boolean
eql19(IRubyObject other)
Deprecated

private boolean
public boolean
equals(Object
object to compare
other
)

Overrides org.jruby.RubyObject.equals.

This override does not do a "checked" dispatch.

pack-priv final boolean
public RubyString
public IRubyObject
private IRubyObject
public IRubyObject
protected void
public IRubyObject
public ByteList

Returns:

The byte list
getByteList
()

Implements org.jruby.util.ByteListHolder.getByteList.

Get the ByteList which backs this Ruby String

public byte[]
public final int
public static RubyString.EmptyByteListHolder
public Encoding
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
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.

private static RubyRegexp
getPattern(ThreadContext context, IRubyObject obj)

get_pat (used by match/match19)

private static IRubyObject
private static Object
private static RubyString
public String
getUnicodeValue()

used by ar-jdbc

public CharSequence
public IRubyObject
public IRubyObject
gsub(ThreadContext context, IRubyObject arg0, Block block)

public IRubyObject
gsub(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Block block)

public IRubyObject
gsub_bang(ThreadContext context, IRubyObject arg0, Block block)

public IRubyObject
gsub_bang(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Block block)

private IRubyObject
gsubCommon(ThreadContext context, Block block, RubyString repl, RubyHash hash, IRubyObject arg0, final boolean bang, int tuFlags)

private IRubyObject
gsubCommon(ThreadContext context, Block block, RubyString repl, RubyHash hash, IRubyObject arg0, final boolean bang, int tuFlags, boolean useBackref)

private IRubyObject
gsubCommon(ThreadContext context, Block block, RubyString repl, RubyHash hash, RubyString pattern, final boolean bang, int tuFlags, boolean useBackref)

private IRubyObject
gsubCommon(ThreadContext context, Block block, RubyString repl, RubyHash hash, RubyRegexp regexp, final boolean bang, int tuFlags, boolean useBackref)

public RubyString
gsubFast(ThreadContext context, RubyRegexp regexp, RubyString repl, Block block)

private IRubyObject
gsubImpl(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Block block, final boolean bang)

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 boolean

Returns:

true if it does
hasNul
()

Does this string contain \0 anywhere (per byte search).

public IRubyObject
hex(ThreadContext context)

rb_str_hex

public RubyBoolean
include_p(ThreadContext context, IRubyObject obj)

rb_str_include

public static IRubyObject
includeRange(ThreadContext context, RubyString _beg, RubyString _end, IRubyObject _val, boolean exclusive)

public final boolean
public IRubyObject
index(ThreadContext context, IRubyObject arg0)

rb_str_index_m

public IRubyObject
private IRubyObject
indexCommon(ThreadContext context, IRubyObject sub, int pos)

pack-priv static int
indexOf(byte[] source, int sourceOffset, int sourceCount, byte[] target, int targetOffset, int targetCount, int fromIndex, Encoding enc)

public IRubyObject
public IRubyObject
public IRubyObject
private IRubyObject
public RubyString
initialize_copy(IRubyObject
object
other
)

Overrides org.jruby.RubyBasicObject.initialize_copy.

Deprecated since 10.0.

public RubyString
initialize_copy(ThreadContext
the thread context
context
,
IRubyObject
the original
other
)

Overrides org.jruby.RubyBasicObject.initialize_copy.

Initializes this object as a copy of the original, that is the parameter to this object.

public IRubyObject
insert(ThreadContext context, IRubyObject indexArg, IRubyObject arg)

public RubyString
inspect()

Overrides org.jruby.RubyBasicObject.inspect.

Implements org.jruby.runtime.builtin.IRubyObject.inspect.

Deprecated since 10.0.

RubyMethod inspect.

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

public static RubyString
inspect(final Ruby runtime, ByteList byteList)
Deprecated since 10.0.

public static RubyString
inspect(ThreadContext context, ByteList byteList)

public RubySymbol
intern()
Deprecated since 10.0.

public RubySymbol
private static IRubyObject
public final boolean
public boolean
isBare(Ruby runtime)
Deprecated since 10.0.

public boolean
isBare(ThreadContext context)

Is this a "bare" string, i.e. has no instance vars, and class == String.

public final boolean
protected boolean
protected boolean
public final boolean
public final boolean
public final boolean
pack-priv final Encoding
public boolean
isEmpty()

Overrides default java.lang.CharSequence.isEmpty.

Returns true if this character sequence is empty.

private IRubyObject
justify(ThreadContext context, IRubyObject arg0, int jflag)

private IRubyObject
justify(ThreadContext context, IRubyObject arg0, IRubyObject arg1, int jflag)

private RubyString
justifyCommon(ThreadContext context, ByteList pad, int padCharLen, boolean padSinglebyte, Encoding enc, int width, int jflag)

public final void
public int
length()

Implements java.lang.CharSequence.length.

Returns the length of this character sequence.

public IRubyObject
lines(ThreadContext context, Block block)

public IRubyObject
lines(ThreadContext context, IRubyObject arg, Block block)

public IRubyObject
lines(ThreadContext context, IRubyObject arg, IRubyObject opts, Block block)

public IRubyObject
ljust(IRubyObject arg0)
Deprecated since 10.0.

public IRubyObject
ljust(ThreadContext context, IRubyObject arg0)

rb_str_ljust

public IRubyObject
ljust(IRubyObject arg0, IRubyObject arg1)
Deprecated since 10.0.

public IRubyObject
public IRubyObject
lstrip(ThreadContext context)

rb_str_lstrip / rb_str_lstrip_bang

public IRubyObject
public final RubyString
public final RubyString
makeIndependent(final int length)

public final RubyString
makeShared(Ruby runtime, int index, int len)

public final RubyString
makeShared(Ruby runtime, RubyClass meta, int index, int len)

private RubyString
makeShared(Ruby runtime, ByteList value, int index, int len)

private RubyString
makeShared(Ruby runtime, RubyClass meta, ByteList value, int index, int len)

public final RubyString
makeSharedString(Ruby runtime, int index, int len)

public IRubyObject
match(ThreadContext context, IRubyObject
Regexp or String
pattern
)
Deprecated since 10.0.

String#match(pattern) rb_str_match_m

public IRubyObject
match(ThreadContext context, IRubyObject pattern, Block block)

public IRubyObject
match(ThreadContext context, IRubyObject pattern, IRubyObject pos, Block block)

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

public IRubyObject
match19(ThreadContext context, IRubyObject pattern)
Deprecated

public IRubyObject
match19(ThreadContext context, IRubyObject pattern, IRubyObject pos, Block block)
Deprecated

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

public IRubyObject
match_p(ThreadContext context, IRubyObject pattern)

public IRubyObject
public final IRubyObject
public final void
public final void
modify(int length)

Implements org.jruby.util.ByteListHolder.modify.

rb_str_modify (with length bytes ensured)

public final void
modify19()
Deprecated since 9.4.

public final void
public void
public final void
modifyCheck()

Check that the string can be modified, raising error otherwise.

public void
modifyCheck(byte[] b, int len)

private void
modifyCheck(byte[] b, int len, Encoding enc)

public final void
modifyExpand(int length)

rb_str_modify_expand

private char
multibyteCharAt(Encoding enc, int beg, int length)

private IRubyObject
multiByteLStrip(ThreadContext context, Encoding enc, byte[] bytes, int s, int end)

private IRubyObject
private IRubyObject
multibyteSubstr(Ruby runtime, Encoding enc, int len, int beg, int length)

private RubyString
private void
protected void
public static RubyString
newAllocatedString(Ruby runtime, RubyClass metaClass)

public static RubyString
newBinaryString(Ruby runtime, String str)

public static RubyString
public static RubyString
newChilledString(Ruby runtime, ByteList bytes, int coderange, String file, int line)

public static RubyString
newDebugChilledString(Ruby runtime, RubyClass rubyClass, ByteList value, int cr, String file, int line)

public static RubyString
newDebugFrozenString(Ruby runtime, RubyClass rubyClass, ByteList value, int cr, String file, int line)

public static RubyString
public static RubyString
public static RubyString
newEmptyString(Ruby runtime, RubyClass metaClass)

public static RubyString
newEmptyString(Ruby runtime, RubyClass metaClass, Encoding enc)

public static RubyString
public static RubyString
newExternalStringWithEncoding(Ruby runtime, String string, Encoding encoding)
Deprecated

public RubyString
public static RubyString

Returns:

a frozen, deduplicated RubyString hosting the given content
newFString
(Ruby
the JRuby runtime
runtime
,
String
the Java String content
content
)

Create anew or deduplicate a RubyString based on the given Java String content.

public static RubyString
newInstance(IRubyObject recv, IRubyObject[] args, Block block)

rb_str_s_new

public static RubyString
newInternalFromJavaExternal(Ruby runtime, String str)

Return a new Ruby String encoded as the default internal encoding given a Java String that has come from an external source.

public RubyString
newString(CharSequence s)
Deprecated

public RubyString
newString(ByteList s)
Deprecated

public static RubyString
newString(Ruby runtime, RubyClass clazz, CharSequence str)
Deprecated

public static RubyString
newString(Ruby runtime, CharSequence str)

public static RubyString
newString(Ruby runtime, CharSequence str, Encoding encoding)

public static RubyString
newString(Ruby runtime, String str)

public static RubyString
newString(Ruby runtime, String str, Encoding encoding)

public static RubyString
newString(Ruby runtime, byte[] bytes)

public static RubyString
newString(Ruby runtime, byte[] bytes, int start, int length)

public static RubyString
newString(Ruby runtime, byte[] bytes, int start, int length, Encoding encoding)

public static RubyString
newString(Ruby runtime, ByteList bytes)

public static RubyString
newString(Ruby runtime, ByteList bytes, int coderange)

public static RubyString
newString(Ruby runtime, ByteList bytes, Encoding encoding)

pack-priv static RubyString
newString(Ruby runtime, byte b)

public static RubyString
newStringLight(Ruby runtime, ByteList bytes)

public static RubyString
newStringLight(Ruby runtime, int size)

public static RubyString
newStringLight(Ruby runtime, int size, Encoding encoding)

public static RubyString
newStringNoCopy(Ruby runtime, byte[] bytes, int start, int length, Encoding encoding)

public static RubyString
newStringNoCopy(Ruby runtime, ByteList bytes)

public static RubyString
newStringNoCopy(Ruby runtime, RubyClass clazz, ByteList bytes)

public static RubyString
newStringNoCopy(Ruby runtime, byte[] bytes, int start, int length)

public static RubyString
newStringNoCopy(Ruby runtime, byte[] bytes)

public static RubyString
newStringNoCopy(Ruby runtime, RubyClass clazz, ByteList bytes, Encoding enc, int cr)

public static RubyString
newStringNoCopy(Ruby runtime, ByteList bytes, Encoding enc, int cr)

public static RubyString
public static RubyString
newStringShared(Ruby runtime, ByteList bytes)

public static RubyString
newStringShared(Ruby runtime, ByteList bytes, Encoding encoding)

public static RubyString
newStringShared(Ruby runtime, ByteList bytes, int codeRange)

public static RubyString
newStringShared(Ruby runtime, RubyClass clazz, ByteList bytes)

public static RubyString
newStringShared(Ruby runtime, RubyClass clazz, ByteList bytes, Encoding encoding)

private static RubyString
newStringShared(Ruby runtime, ByteList bytes, Encoding encoding, int cr)

public static RubyString
newStringShared(Ruby runtime, byte[] bytes)
Deprecated since 10.0.

public static RubyString
newStringShared(Ruby runtime, byte[] bytes, Encoding encoding)
Deprecated since 10.0.

public static RubyString
newStringShared(Ruby runtime, byte[] bytes, int start, int length)
Deprecated since 10.0.

public static RubyString
newStringShared(Ruby runtime, byte[] bytes, int start, int length, Encoding encoding)

public static RubyString
public static RubyString
public static RubyString
public static RubyString
public static RubyString
public static RubyString
newUsAsciiStringShared(Ruby runtime, byte[] bytes, int start, int length)

public static RubyString
newUTF16String(Ruby runtime, String str)

public static RubyString
public static RubyString
newUTF8String(Ruby runtime, String str)

public static RubyString
public static RubyString
objAsString(ThreadContext context, IRubyObject obj)

rb_obj_as_string

public IRubyObject
oct(ThreadContext context)

rb_str_oct

public IRubyObject
op_aref(ThreadContext context, IRubyObject arg)

rb_str_aref, rb_str_aref_m

public IRubyObject
private IRubyObject
op_aref(ThreadContext context, int idx)

public IRubyObject
op_aset(ThreadContext context, IRubyObject arg0, IRubyObject arg1)

rb_str_aset, rb_str_aset_m

private IRubyObject
op_aset(ThreadContext context, int idx, IRubyObject arg1)

public IRubyObject
public IRubyObject
public final int
op_cmp(RubyString other)

rb_str_cmp

public IRubyObject
private IRubyObject
public RubyString
public IRubyObject
public IRubyObject
op_ge19(ThreadContext context, IRubyObject other)
Deprecated

public IRubyObject
public IRubyObject
op_gt19(ThreadContext context, IRubyObject other)
Deprecated

public IRubyObject
public IRubyObject
op_le19(ThreadContext context, IRubyObject other)
Deprecated

public IRubyObject
public IRubyObject
op_lt19(ThreadContext context, IRubyObject other)
Deprecated

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

Overrides org.jruby.RubyBasicObject.op_match.

rb_str_match

public IRubyObject
public IRubyObject
op_mul19(ThreadContext context, IRubyObject other)
Deprecated

public IRubyObject
public IRubyObject
op_plus19(ThreadContext context, IRubyObject arg)
Deprecated

public IRubyObject
ord(ThreadContext context)

public IRubyObject
partition(ThreadContext context, Block block)

public IRubyObject
private RubyArray<T extends IRubyObject>
private static int
patternSearch(ThreadContext context, final IRubyObject pattern, RubyString str, final int pos)

public final IRubyObject
plus_at()
Deprecated since 10.0.

public final IRubyObject
private void
private static RubyString.EmptyByteListHolder
public IRubyObject
prepend(ThreadContext context, IRubyObject other)

rb_str_prepend

public IRubyObject
prepend(ThreadContext context, IRubyObject[] objs)

rb_str_prepend

public final RubyString
prepend(byte ch)

public final RubyString
prepend(int ch)

private void
public static IRubyObject
public int
rbStrOffset(int pos)

private RubyArray<T extends IRubyObject>
regexSplit(ThreadContext context, RubyRegexp pattern, boolean limit, int lim)

Call regexpSplit using a thread-local backref holder to avoid cross-thread pollution.

public IRubyObject
replace(IRubyObject other)
Deprecated since 10.0.

public RubyString
replace(ThreadContext context, IRubyObject other)

rb_str_replace_m

public RubyString
replace19(IRubyObject other)
Deprecated

private RubyString
private IRubyObject
replaceInternal(int beg, int len, RubyString repl)

private void
replaceInternal19(Ruby runtime, int beg, int len, RubyString repl)
Deprecated since 9.4.

public final void
resize(final int size)

rb_str_resize

public IRubyObject
public IRubyObject
reverse19(ThreadContext context)
Deprecated

public RubyString
public RubyString
reverse_bang19(ThreadContext context)
Deprecated

public IRubyObject
rindex(ThreadContext context, IRubyObject arg0)

rb_str_rindex_m

public IRubyObject
private IRubyObject
rindexCommon(ThreadContext context, final IRubyObject sub, int pos)

public IRubyObject
rjust(IRubyObject arg0)
Deprecated since 10.0.

public IRubyObject
rjust(ThreadContext context, IRubyObject arg0)

rb_str_rjust

public IRubyObject
rjust(IRubyObject arg0, IRubyObject arg1)
Deprecated since 10.0.

public IRubyObject
public IRubyObject
private IRubyObject
public IRubyObject
rstrip(ThreadContext context)

rb_str_rstrip / rb_str_rstrip_bang

public IRubyObject
public RubyFixnum
rubyLength(final ThreadContext context)

public IRubyObject
scan(ThreadContext context, IRubyObject pat, Block block)

rb_str_scan

public final int
public static int
private static long
scanHex(byte[] bytes, int start, int len, int[] retlen)

private static IRubyObject
scanOnce(ThreadContext context, RubyString str, IRubyObject pat, int[] startp)

public IRubyObject
scrub(ThreadContext context, Block block)

public IRubyObject
scrub(ThreadContext context, IRubyObject repl, Block block)

public IRubyObject
scrub_bang(ThreadContext context, Block block)

public IRubyObject
scrub_bang(ThreadContext context, IRubyObject repl, Block block)

private static RubyMatchData
setBackRefString(ThreadContext context, RubyString str, int pos, RubyString pattern)

pack-priv final void
public IRubyObject
public final void
public final void
public void
public final void
public void
setReadLength(int length)

public void
setValue(CharSequence value)
Deprecated since 10.0.

public void
public boolean
private IRubyObject
singleByteLStrip(ThreadContext context, byte[] bytes, int s, int end)

pack-priv final boolean
pack-priv final boolean
private IRubyObject
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.StringSites
sites(ThreadContext context)

Hides org.jruby.RubyObject.sites.

Retrieve the call sites for this class.

public int
size()

public IRubyObject
slice_bang(ThreadContext context, IRubyObject arg0)

rb_str_slice_bang

public IRubyObject
private IRubyObject
public RubyArray<T extends IRubyObject>
public RubyArray<T extends IRubyObject>
public RubyArray<T extends IRubyObject>
split(ThreadContext context, IRubyObject pattern, IRubyObject limit)

public RubyArray<T extends IRubyObject>

Returns:

splited entries
split
(RubyRegexp delimiter)
Deprecated since 10.0.

Split for ext (Java) callers (does not write $~).

public RubyArray<T extends IRubyObject>
split(RubyRegexp delimiter, int limit)
Deprecated since 10.0.

public RubyArray<T extends IRubyObject>

Returns:

splited entries
split
(ThreadContext
the thread context
context
,
RubyRegexp delimiter, int limit)

Split for ext (Java) callers (does not write $~).

public RubyArray<T extends IRubyObject>
split(RubyString delimiter)
Deprecated since 10.0.

public RubyArray<T extends IRubyObject>
split(RubyString delimiter, int limit)
Deprecated since 10.0.

public RubyArray<T extends IRubyObject>

Returns:

splited entries
split
(ThreadContext
the thread context
context
,
RubyString delimiter, int limit)

Split for ext (Java) callers (does not write $~).

private RubyArray<T extends IRubyObject>
splitCommon(ThreadContext context, IRubyObject pat, int lim)

public IRubyObject
splitWithBlock(ThreadContext context, Block block)

rb_str_split_m

public IRubyObject
public IRubyObject
splitWithBlock(ThreadContext context, IRubyObject pattern, IRubyObject limit, Block block)

public IRubyObject
squeeze(ThreadContext context)

rb_str_squeeze / rb_str_squeeze_bang

public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public boolean
public IRubyObject
public IRubyObject
str_eql_p19(ThreadContext context, IRubyObject other)
Deprecated

public final RubyString
strDup(Ruby runtime)

public final RubyString
strDup(Ruby runtime, RubyClass clazz)

public final RubyString
strDup()
Deprecated

public int

Returns:

calculated hash
strHashCode
(Ruby
the runtime
runtime
)

Generate a hash for the String, using its associated Ruby instance's hash seed.

private RubyArray<T extends IRubyObject>
stringSplit(ThreadContext context, RubyString spat, boolean limit, int lim)

public static byte[]
public IRubyObject
stringToInum(int base, boolean badcheck)

rb_str_to_inum

public final IRubyObject
stringToInum(int base)

public static RubyString
public IRubyObject
strip(ThreadContext context)

rb_str_strip / rb_str_strip_bang

public IRubyObject
public final int
pack-priv final int
strLength(final ByteList bytes, final Encoding enc)

private int
strOffset(int nth, boolean singlebyte)

public IRubyObject
strScrub(ThreadContext context, IRubyObject repl, Block block)

Scrub the contents of this string, replacing invalid characters as appropriate.

private int
strseqIndex(final RubyString sub, int offset, boolean inBytes)

private void
strUpdate1(int beg, int len, RubyString val, int vbeg, int vlen)

public IRubyObject
sub(ThreadContext context, IRubyObject arg0, Block block)

rb_str_sub / rb_str_sub_bang

public IRubyObject
sub(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Block block)

public IRubyObject
sub_bang(ThreadContext context, IRubyObject arg0, Block block)

public IRubyObject
sub_bang(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Block block)

private RubyString
subBangCommon(ThreadContext context, final int beg, final int end, final RubyString repl, int tuFlags)

public final IRubyObject

Returns:

sub result
subBangFast
(ThreadContext
current context
context
,
RubyRegexp
the regular expression
regexp
,
RubyString
replacement string value
repl
)

sub!

private IRubyObject
subBangIter(ThreadContext context, IRubyObject arg0, RubyHash hash, Block block)

private IRubyObject
subBangIter(ThreadContext context, RubyString pattern, RubyHash hash, Block block)

private IRubyObject
subBangIter(ThreadContext context, RubyRegexp regexp, RubyHash hash, Block block)

private RubyMatchData
private IRubyObject
private IRubyObject
private IRubyObject
private Encoding
subBangVerifyEncoding(ThreadContext context, final RubyString repl, final int beg, final int end)

pack-priv final int
subLength(int pos)

private IRubyObject
subpat(ThreadContext context, RubyRegexp regex, IRubyObject backref)

private IRubyObject
private void
subpatSet(ThreadContext context, RubyRegexp regexp, IRubyObject backref, IRubyObject repl)

private int
subpatSetCheck(ThreadContext context, int nth, Region regs)

public CharSequence
subSequence(int
the start index, inclusive
start
,
int
the end index, exclusive
end
)

Implements java.lang.CharSequence.subSequence.

Returns a CharSequence that is a subsequence of this sequence.

public final IRubyObject
substr(int beg, int len)
Deprecated since 9.4-.

public final IRubyObject
substr(Ruby runtime, int beg, int len)
Deprecated since 10.0.

public final IRubyObject
substr(ThreadContext context, int beg, int len)

public final IRubyObject
substr19(Ruby runtime, int beg, int len)
Deprecated since 9.4.

public final IRubyObject
substrEnc(Ruby runtime, int beg, int len)
Deprecated since 10.0.

public final IRubyObject
substrEnc(ThreadContext context, int beg, int len)

public IRubyObject
public IRubyObject
succ_bang()
Deprecated since 10.0.

public IRubyObject
public IRubyObject
sum(ThreadContext context)

public IRubyObject
public IRubyObject
sumCommon(ThreadContext context, long bits)

public RubyString
swapcase(ThreadContext context)

rb_str_swapcase / rb_str_swapcase_bang

public RubyString
public RubyString
public IRubyObject
public IRubyObject
public IRubyObject
private IRubyObject
swapcase_bang(ThreadContext context, int flags)

public IRubyObject
to_c(ThreadContext context)

string_to_c

public IRubyObject
to_f()
Deprecated since 10.0.

public IRubyObject
public IRubyObject
to_i()
Deprecated since 10.0.

public IRubyObject
public IRubyObject
to_i(IRubyObject arg0)
Deprecated since 10.0.

public IRubyObject
to_i(ThreadContext context, IRubyObject arg0)

rb_str_to_i

public IRubyObject
to_r(ThreadContext context)

string_to_r

public RubyString
public final Encoding
toEncoding(Ruby runtime)
Deprecated since 10.0.

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 String
toString()

Overrides org.jruby.RubyObject.toString.

Implements java.lang.CharSequence.toString.

Returns a string containing the characters in this sequence in the same order as this sequence.

public IRubyObject
tr(ThreadContext context, IRubyObject src, IRubyObject repl)

rb_str_tr / rb_str_tr_bang

public IRubyObject
tr19(ThreadContext context, IRubyObject src, IRubyObject repl)
Deprecated

public IRubyObject
public IRubyObject
tr_bang19(ThreadContext context, IRubyObject src, IRubyObject repl)
Deprecated

public IRubyObject
tr_s(ThreadContext context, IRubyObject src, IRubyObject repl)

rb_str_tr_s / rb_str_tr_s_bang

public IRubyObject
tr_s19(ThreadContext context, IRubyObject src, IRubyObject repl)
Deprecated

public IRubyObject
public IRubyObject
tr_s_bang19(ThreadContext context, IRubyObject src, IRubyObject repl)
Deprecated

private IRubyObject
trTrans(ThreadContext context, IRubyObject src, IRubyObject repl, boolean sflag)

private CodeRangeable
trTransHelper(ThreadContext context, CodeRangeable srcStr, CodeRangeable replStr, boolean sflag)

public static IRubyObject
public IRubyObject
private void
undumpAfterBackslash(ThreadContext context, byte[] ssBytes, int[] ss, int s_end, Encoding[] penc, boolean[] utf8, boolean[] binary)

private static byte
unescapeAscii(byte c)

public static RubyString
unmarshalFrom(UnmarshalStream input)
Deprecated for removal since 10.0.

public static RubyString
public RubyArray<T extends IRubyObject>
unpack(ThreadContext context, IRubyObject obj, Block block)

public RubyArray<T extends IRubyObject>
unpack(ThreadContext context, IRubyObject obj, IRubyObject opt, Block block)

public RubyArray<T extends IRubyObject>
unpack(IRubyObject obj)
Deprecated

public IRubyObject
unpack1(ThreadContext context, IRubyObject obj, Block block)

public IRubyObject
private static long
public int

Returns:

calculated hash
unseededStrHashCode
(Ruby
the runtime
runtime
)

Generate a hash for the String, without a seed.

public RubyString
upcase(ThreadContext context)

rb_str_upcase / rb_str_upcase_bang

public RubyString
public RubyString
public IRubyObject
public IRubyObject
public IRubyObject
private IRubyObject
upcase_bang(ThreadContext context, int flags)

private static RubyString
public final IRubyObject
upto(ThreadContext context, IRubyObject end, Block block)

rb_str_upto_m

public final IRubyObject
upto(ThreadContext context, IRubyObject end, IRubyObject excl, Block block)

pack-priv final IRubyObject
uptoCommon(ThreadContext context, IRubyObject arg, boolean excl, Block block)

pack-priv final IRubyObject
uptoCommon(ThreadContext context, RubyString end, boolean excl, Block block, boolean asSymbol)

private IRubyObject
uptoCommonNoDigits(ThreadContext context, RubyString end, boolean excl, Block block, boolean asSymbol)

pack-priv final IRubyObject
public IRubyObject
public void
public final void
view(ByteList bytes)

private void
view(byte[] bytes, boolean copy)

private void
view(int index, int len)

Inherited from org.jruby.RubyObject:
attachToObjectSpacecallInitcallInitcallInitcallInitcallInitcallInitcallInitcallInitcallInitcallInitconvertToTypedigdig1dig2eqlInternalequalInternalfinishObjectClassinspectop_eqqputsspecificEvaltoRubyString