Top Description Inners Constructors Methods
org.jruby.util

public Class ByteListHelper

extends Object
Class Inheritance
Imports
org.jcodings.Encoding, org.jcodings.specific.USASCIIEncoding, org.jruby.Ruby

Helpers for working with bytelists.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
public static interface

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static boolean

Returns:

true if it walks the whole bytelist or false if it stops.
eachCodePoint
(ByteList
of the mbc-laden bytes
bytelist
,
ByteListHelper.CodePoint
the closure which walks the codepoints
each
)

This method assumes the ByteList will be a valid string for the encoding which it is marked as.

public static int

Returns:

length if all codepoints match. index (ignoring begin) if not.
eachCodePointWhile
(Ruby runtime, ByteList
of the mbc-laden bytes
bytelist
,
int
place in bytes to search past begin
offset
,
ByteListHelper.CodePoint
the closure which walks the codepoints
each
)

If you know you have an ASCII ByteList you should do something else.

private static int
public static <
Return type of visitor
T
>
T

Returns:

last T from headVisitor
split
(ByteList
to be split
value
,
ByteList
the pattern to split value with
pattern
,
ByteListHelper.Visit<ByteList, T>
visitor for all but last segment
bodyVisitor
,
ByteListHelper.Visit<ByteList, T>
visitor for the last segment (if null if will use bodyVisitor).
headVisitor
)
Deprecated since 9.4-. This was only used by Module#const_defined, but was difficult to match MRI's equivalent in this form

This method will split a string and call a visitor for each segment between the split pattern.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ByteListHelperback to summary
public ByteListHelper()

Method Detail

eachCodePointback to summary
public static 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. It also assumes slow path mbc walking. If you know you have an ASCII ByteList you should do something else.

Parameters
bytelist:ByteList

of the mbc-laden bytes

each:ByteListHelper.CodePoint

the closure which walks the codepoints

Returns:boolean

true if it walks the whole bytelist or false if it stops.

eachCodePointWhileback to summary
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:ByteList

of the mbc-laden bytes

offset:int

place in bytes to search past begin

each:ByteListHelper.CodePoint

the closure which walks the codepoints

Returns:int

length if all codepoints match. index (ignoring begin) if not.

eachMBCCodePointWhileback to summary
private static int eachMBCCodePointWhile(ByteList bytelist, int offset, ByteListHelper.CodePoint each)
splitback to summary
public static <T> T split(ByteList value, ByteList pattern, ByteListHelper.Visit<ByteList, T> bodyVisitor, ByteListHelper.Visit<ByteList, T> headVisitor)

Deprecated

since 9.4-.

This was only used by Module#const_defined, but was difficult to match MRI's equivalent in this form

This method will split a string and call a visitor for each segment between the split pattern.

Parameters
<T>
Return type of visitor
value:ByteList

to be split

pattern:ByteList

the pattern to split value with

bodyVisitor:ByteListHelper.Visit<ByteList, T>

visitor for all but last segment

headVisitor:ByteListHelper.Visit<ByteList, T>

visitor for the last segment (if null if will use bodyVisitor).

Returns:T

last T from headVisitor

Annotations
@Deprecated
since:9.4-
org.jruby.util back to summary

public Interface ByteListHelper.CodePoint


Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true to continue walking and false to stop.
call
(int
the index of which codepoint we are visiting.
index
,
int
we are visiting.
codepoint
,
Encoding encoding)

call a command pattern caller with index of and actual codepoint.

Method Detail

callback to summary
public boolean call(int index, int codepoint, Encoding encoding)

call a command pattern caller with index of and actual codepoint. If false is returned it will let users of this interface to stop walking the codepoints.

Parameters
index:int

the index of which codepoint we are visiting.

codepoint:int

we are visiting.

Returns:boolean

true to continue walking and false to stop.

org.jruby.util back to summary

public Interface ByteListHelper.Visit<T, U>


Method Summary

Modifier and TypeMethod and Description
public U
call(int index, T value, U module)

Method Detail

callback to summary
public U call(int index, T value, U module)