Package org.jruby.util
Class ByteListHelper
java.lang.Object
org.jruby.util.ByteListHelper
Helpers for working with bytelists.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
static interface
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
eachCodePoint
(ByteList bytelist, ByteListHelper.CodePoint each) This method assumes the ByteList will be a valid string for the encoding which it is marked as.static int
eachCodePointWhile
(Ruby runtime, ByteList bytelist, int offset, ByteListHelper.CodePoint each) If you know you have an ASCII ByteList you should do something else.static <T> T
split
(ByteList value, ByteList pattern, ByteListHelper.Visit<ByteList, T> bodyVisitor, ByteListHelper.Visit<ByteList, T> headVisitor) Deprecated.This was only used by Module#const_defined, but was difficult to match MRI's equivalent in this form
-
Constructor Details
-
ByteListHelper
public ByteListHelper()
-
-
Method Details
-
eachCodePoint
This method assumes the ByteList will be a valid string for the encoding which it is marked as. It also assumes slow path mbc walking. If you know you have an ASCII ByteList you should do something else.- Parameters:
bytelist
- of the mbc-laden byteseach
- the closure which walks the codepoints- Returns:
- true if it walks the whole bytelist or false if it stops.
-
eachCodePointWhile
public static int eachCodePointWhile(Ruby runtime, ByteList bytelist, int offset, ByteListHelper.CodePoint each) If you know you have an ASCII ByteList you should do something else. This will continue walking the bytelist 'while' as long as each continues to be true. When it stops being true it will return the last byte index processed (on full walk it will be length otherwise the beginning of the codepoint which did not satisfy each).- Parameters:
bytelist
- of the mbc-laden bytesoffset
- place in bytes to search past begineach
- the closure which walks the codepoints- Returns:
- length if all codepoints match. index (ignoring begin) if not.
-
split
@Deprecated(since="9.4-") public static <T> T split(ByteList value, ByteList pattern, ByteListHelper.Visit<ByteList, T> bodyVisitor, ByteListHelper.Visit<ByteList, T> headVisitor) Deprecated.This was only used by Module#const_defined, but was difficult to match MRI's equivalent in this formThis method will split a string and call a visitor for each segment between the split pattern.- Type Parameters:
T
- Return type of visitor- Parameters:
value
- to be splitpattern
- the pattern to split value withbodyVisitor
- visitor for all but last segmentheadVisitor
- visitor for the last segment (if null if will use bodyVisitor).- Returns:
- last T from headVisitor
-