Top Inners Fields Constructors Methods
org.jruby.util

public final Class StringSupport

extends Object
Class Inheritance
Static Imports
org.jcodings.Encoding.CHAR_INVALID, org.jruby.RubyEnumerator.enumeratorize, .RubyString.scanForCodeRange, org.jruby.api.Access.encodingService, .Access.globalVariables, .Convert.asSymbol, .Create.newArray, .Create.newString, .Error.argumentError, .Error.indexError, .Warn.warn

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
public static enum
public static class
StringSupport.TR

rb_str_tr / rb_str_tr_bang

public static class
StringSupport.TrTables

tr_setup_table

Field Summary

Modifier and TypeField and Description
private static final VarHandle
private static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
private static final Object
public static final ByteList[]
public static final String[]
private static final int
private static final int
private static final long
private static final int
public static final int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static ByteList
addByteLists(ByteList value1, ByteList value2)

public static boolean
public static boolean
public static Encoding
areCompatible(CodeRangeable str1, CodeRangeable str2)

rb_enc_compatible

public static Encoding
public static Encoding
public static void
asciiOnlyCaseMap(Ruby runtime, ByteList value, IntHolder flags, Encoding enc)
Deprecated since 10.0.

public static void
public static void
public static int
byteindex(CodeRangeable sourceString, CodeRangeable otherString, int offset, Encoding enc)

public static String
public static int
byterindex(ByteList source, int pos, CodeRangeable subStringCodeRangeable, Encoding enc)

private static int
byteRindex(final byte[] strBytes, final int strBeg, final int strLen, final byte[] subBytes, final int subBeg, final int subLen, int pos, final Encoding enc)

public static int
public static int
bytesToFixBrokenTrailingCharacter(byte[] bytes, int begin, int byteSize, Encoding encoding, int usingLength)

public static int
caseCmp(byte[] bytes1, int p1, byte[] bytes2, int p2, int len)

public static ByteList
caseMap(Ruby runtime, ByteList src, IntHolder flags, Encoding enc)
Deprecated since 10.0.

public static ByteList
caseMap(ThreadContext context, ByteList src, IntHolder flags, Encoding enc)

public static int
checkCaseMapOptions(Ruby runtime, IRubyObject arg0, IRubyObject arg1, int flags)
Deprecated since 10.0.

public static int
checkCaseMapOptions(ThreadContext context, IRubyObject arg0, IRubyObject arg1, int flags)

public static int
checkCaseMapOptions(Ruby runtime, IRubyObject arg0, int flags)
Deprecated since 10.0.

public static int
checkCaseMapOptions(ThreadContext context, IRubyObject arg0, int flags)

public static int
public static RubyString
checkEmbeddedNulls(Ruby runtime, IRubyObject ptr)
Deprecated since 10.0.

public static void
checkStringSafety(Ruby runtime, IRubyObject value)

Check whether input object's string value contains a null byte, and if so throw ArgumentError.

public static void
private static int
chomp_newline(byte[] bytes, int p, int e, Encoding enc)

public static int
choppedLength(CodeRangeable str)

MRI: chopped_length

public static int
codeLength(Encoding enc, int c)

public static int
codePoint(Encoding enc, byte[] bytes, int p, int end)

public static int
codePoint(Ruby runtime, Encoding enc, byte[] bytes, int p, int end)
Deprecated since 10.0.

public static int
codePoint(ThreadContext context, Encoding enc, byte[] bytes, int p, int end)

public static int
codePoint(final Ruby runtime, final ByteList value)
Deprecated since 10.0.

public static int
codePoint(ThreadContext context, final ByteList value)

public static String
codeRangeAsString(int codeRange)

public static int
codeRangeScan(Encoding enc, byte[] bytes, int p, int len)

public static int
private static int
codeRangeScanAsciiCompatible(Encoding enc, byte[] bytes, int p, int len)

private static int
codeRangeScanNonAsciiCompatible(Encoding enc, byte[] bytes, int p, int len)

public static long
codeRangeScanRestartable(Encoding enc, byte[] bytes, int s, int end, int cr)

public static CharSequence
concat(final CharSequence str1, final CharSequence str2)

public static String
concat(final String str1, final String str2)

public static int
public static boolean
contentEquals(final CharSequence str, final int chr)

public static boolean
contentEquals(final CharSequence str, final int chr1, final int chr2)

private static int
copy(final String str, final int soff, final int slen, final char[] dest, int doff)

private static int
public static String
delete(final String str, final char c)

public static ByteList
dumpCommon(Ruby runtime, ByteList bytelist)

rb_str_dump

public static ByteList
dumpCommon(Ruby runtime, ByteList byteList, boolean quoteOnlyIfNeeded)

public static int
private static Encoding
public static int
encFastMBCLen(byte[] bytes, int p, int e, Encoding enc)

public static String
escapedCharFormat(int c, boolean isUnicode)

private static int[]
failure(byte[] p, int pStart, int pLen)

public static long
getAscii(Encoding enc, byte[] bytes, int p, int end)

public static long
getAscii(Encoding enc, byte[] bytes, int p, int end, int len)

public static int
hexLength(byte[] bytes, int p, int len)

public static int
hexLength(byte[] bytes, int p, int len, Encoding enc)

public static int
index(ByteList
string to find index within
source
,
ByteList
string to match in source
other
,
int
in bytes to start looking
offset
,
Encoding
encoding to use to walk the source string.
enc
)

public static int
index(CodeRangeable sourceString, CodeRangeable otherString, int offset, Encoding enc)

public static boolean
private static boolean
isAsciiOnly(Encoding encoding, final int codeRange)

public static boolean
isEVStr(byte[] bytes, int p, int end)

public static boolean
isEVStr(int c)

public static boolean
public static boolean
public static boolean
isUnicode(Encoding enc)
Deprecated

public static int
lastIndexOf(final CharSequence str, final char c, int index)

public static int
length(Encoding enc, byte[] bytes, int p, int end)

public static int
public static boolean
public static boolean
public static int
public static int
public static boolean
public static int
memchr(byte[] ptr, int start, final int find, int len)
Deprecated since 10.0.

public static int
memmem(byte[] aBytes, int aStart, int aLen, byte[] p, int pStart, int pLen)

public static int
memsearch(byte[] xBytes, int x0, int m, byte[] yBytes, int y0, int n, Encoding enc)

public static int
multiByteCasecmp(Encoding enc, ByteList value, ByteList otherValue)

public static boolean
multiByteSqueeze(ByteList value, boolean[] squeeze, StringSupport.TrTables tables, Encoding enc, boolean isArg)

public static boolean
multiByteSqueeze(Ruby runtime, ByteList value, boolean[] squeeze, StringSupport.TrTables tables, Encoding enc, boolean isArg)
Deprecated since 10.0.

public static boolean
multiByteSqueeze(ThreadContext context, ByteList value, boolean[] squeeze, StringSupport.TrTables tables, Encoding enc, boolean isArg)

public static int

Returns:

the byte offset of the requested character, or -1 if the requested character offset is outside the given byte offset range
nth
(Encoding
the encoding of the characters in the byte array
enc
,
byte[]
the byte array
bytes
,
int
starting offset
p
,
int
limit offset
end
,
int
character offset to find
n
)

Return the byte offset of the nth character n in the given byte array between p and n using enc as the encoding.

public static int
nth(Encoding enc, ByteList value, int n)

public static int

Returns:

the offset of the nth character in the string, or -1 if nth is out of the string
nth
(Encoding
encoding to use
enc
,
byte[]
bytes to scan
bytes
,
int
starting byte offset
p
,
int
ending byte offset
end
,
int
index of character for which to find byte offset
n
,
boolean
whether the byte contents are in a single byte encoding
singlebyte
)

Get the position of the nth character in the given byte array, using the given encoding and range.

private static int
nthAsciiCompatible(Encoding enc, byte[] bytes, int p, int end, int n)

private static int
nthNonAsciiCompatible(Encoding enc, byte[] bytes, int p, int end, int n)

public static int
octLength(byte[] bytes, int p, int len)

public static int
octLength(byte[] bytes, int p, int len, Encoding enc)

public static int
offset(Encoding enc, byte[] bytes, int p, int end, int n)

public static int
offset(Encoding enc, byte[] bytes, int p, int end, int n, boolean singlebyte)

public static int
offset(RubyString str, int pos)

public static long
pack(int result, int arg)

public static int
positionEndForScan(ByteList value, Matcher matcher, Encoding enc, int begin, int range)

rb_str_scan

public static int
preciseCodePoint(Encoding enc, byte[] bytes, int p, int end)

public static int
preciseLength(Encoding enc, byte[] bytes, int p, int end)

private static StringSupport.NeighborChar
predChar(Encoding enc, byte[] bytes, int p, int len)

private static int
rb_memsearch_qs(byte[] xsBytes, int xs, int m, byte[] ysBytes, int ys, int n)

private static int
rb_memsearch_qs_utf8(byte[] xsBytes, int xs, int m, byte[] ysBytes, int ys, int n)

private static int
rb_memsearch_qs_utf8_hash(byte[] xBytes, final int x)

private static int
rb_memsearch_ss(byte[] xsBytes, int xs, int m, byte[] ysBytes, int ys, int n)

public static IRubyObject
rbStrEnumerateLines(RubyString str, ThreadContext context, String name, IRubyObject arg, Block block, boolean wantarray)

public static IRubyObject
rbStrEnumerateLines(RubyString str, ThreadContext context, String name, IRubyObject arg, IRubyObject opts, Block block, boolean wantarray)

private static void
rbStrEnumerateLinesEmptySep(RubyString str, ThreadContext context, final boolean chomp, Block block, RubyArray<T extends IRubyObject> ary, final byte[] strBytes, final int ptr, final int len, final int pend, final Encoding enc, int subptr)

public static CharSequence
replaceAll(final String str, final String sub, final String repl)

public static CharSequence
replaceFirst(final String str, final String sub, final String repl)

private static CharSequence
replaceImpl(final String str, String sub, final String repl, int max, final boolean ignoreCase)

public static ByteList
replaceInternal(int beg, int len, ByteListHolder source, CodeRangeable repl)

public static void
replaceInternal19(int beg, int len, CodeRangeable source, CodeRangeable repl)
Deprecated since 9.4.

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

public static int
rindex(ByteList source, int sourceChars, int subChars, int pos, CodeRangeable subStringCodeRangeable, Encoding enc)

public static int
scanHex(byte[] bytes, int p, int len)

public static int
scanHex(byte[] bytes, int p, int len, Encoding enc)

public static int
scanOct(byte[] bytes, int p, int len)

public static int
scanOct(byte[] bytes, int p, int len, Encoding enc)

public static int
searchNonAscii(byte[] bytes, int p, int end)

public static int
public static int
public static boolean
singleByteSqueeze(ByteList value, boolean[] squeeze)

public static List<String>
split(final String
the string
str
,
final char
the separator
sep
)

Split string into sub-parts.

public static List<String>
split(final String
the string
str
,
final char
the separator
sep
,
final int
has same effect as with String#split(String, int)
lim
)

Split string into (limited) sub-parts.

public static boolean
startsWith(final CharSequence str, final String prefix)

public static boolean
startsWith(final CharSequence str, final char c)

public static boolean
startsWith(final CharSequence str, final char c1, final char c2)

public static int
strCount(ByteList str, boolean[] table, StringSupport.TrTables tables, Encoding enc)

rb_str_count

public static int
strCount(ByteList str, Ruby runtime, boolean[] table, StringSupport.TrTables tables, Encoding enc)
Deprecated since 10.0.

public static int
strCount(ThreadContext context, ByteList str, boolean[] table, StringSupport.TrTables tables, Encoding enc)

pack-priv static CodeRangeable
strDeleteBang(CodeRangeable rubyString, boolean[] squeeze, StringSupport.TrTables tables, Encoding enc)

rb_str_delete_bang

public static CodeRangeable
strDeleteBang(CodeRangeable rubyString, Ruby runtime, boolean[] squeeze, StringSupport.TrTables tables, Encoding enc)
Deprecated since 10.0.

public static CodeRangeable
strDeleteBang(ThreadContext context, CodeRangeable rubyString, boolean[] squeeze, StringSupport.TrTables tables, Encoding enc)

private static RubyString
strFillTerm(RubyString str, byte[] sBytes, int beg, int len, int termlen)

public static int
strLength(Encoding enc, byte[] bytes, int p, int end)

public static int
strLength(Encoding enc, byte[] bytes, int p, int e, int cr)

public static int
public static int
public static int
public static int
strLengthFromRubyString(CodeRangeable string, final ByteList bytes, final Encoding enc)

private static int
public static long
strLengthWithCodeRange(Encoding enc, byte[] bytes, int p, int end)

public static long
public static long
public static long
strLengthWithCodeRangeAsciiCompatible(Encoding enc, byte[] bytes, int p, int end)

public static long
strLengthWithCodeRangeNonAsciiCompatible(Encoding enc, byte[] bytes, int p, int end)

private static int
strNullChar(byte[] sBytes, int s, int len, final int minlen, Encoding enc)

public static Object[]
private static int
strRindex(final byte[] strBytes, final int strBeg, final int strLen, final byte[] subBytes, final int subBeg, final int subLen, int s, int pos, final Encoding enc)

public static void
strUpdate(int beg, int len, CodeRangeable source, CodeRangeable repl)

public static void
strUpdate(Ruby runtime, int beg, int len, RubyString source, RubyString repl)
Deprecated since 10.0.

public static void
strUpdate(ThreadContext context, int beg, int len, RubyString source, RubyString repl)

private static StringSupport.NeighborChar
succAlnumChar(Encoding enc, byte[] bytes, int p, int len, byte[] carry, int carryP)

public static StringSupport.NeighborChar
succChar(Encoding enc, byte[] bytes, int p, int len)

public static StringSupport.NeighborChar
succChar(Ruby runtime, Encoding enc, byte[] bytes, int p, int len)

public static ByteList
succCommon(ByteList original)

public static ByteList
succCommon(Ruby runtime, ByteList original)
Deprecated since 10.0.

public static ByteList
succCommon(ThreadContext context, ByteList original)

private static void
TERM_FILL(byte[] ptr, final int beg, final int len, final int termlen)

public static int
toLower(Encoding enc, int c)
Deprecated

public static int
toUpper(Encoding enc, int c)
Deprecated

private static int
trCode(int c, int[] trans, IntHash<Integer> hash, boolean cflag, int last, boolean set)

public static boolean
trFind(final int c, final boolean[] table, final StringSupport.TrTables tables)

public static int
public static int
trNext(final StringSupport.TR tr, Ruby runtime, Encoding enc)

private static int
public static StringSupport.TrTables
trSetupTable(final ByteList str, final boolean[] stable, StringSupport.TrTables tables, final boolean first, final Encoding enc)

public static StringSupport.TrTables
trSetupTable(final ByteList str, final Ruby runtime, final boolean[] stable, StringSupport.TrTables tables, final boolean first, final Encoding enc)
Deprecated since 10.0.

public static StringSupport.TrTables
trSetupTable(ThreadContext context, final ByteList str, final boolean[] stable, StringSupport.TrTables tables, final boolean first, final Encoding enc)

public static CodeRangeable
trTransHelper(CodeRangeable self, CodeRangeable srcStr, CodeRangeable replStr, boolean sflag)

rb_str_tr / rb_str_tr_bang

public static CodeRangeable
trTransHelper(Ruby runtime, CodeRangeable self, CodeRangeable srcStr, CodeRangeable replStr, boolean sflag)
Deprecated since 10.0.

public static int
unpackArg(long cr)

public static int
unpackResult(long len)

public static int
utf8Length(byte[] bytes, int p, int end)

public static int
public static int
utf8Nth(byte[] bytes, int p, int e, int nth)

public static int
utf8Offset(byte[] bytes, int p, int end, int n)

private static boolean
zeroFilled(byte[] sBytes, int s, int n)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait