Class ByteListHelper

java.lang.Object
org.jruby.util.ByteListHelper

public class ByteListHelper extends Object
Helpers for working with bytelists.
  • Constructor Details

    • ByteListHelper

      public ByteListHelper()
  • Method Details

    • eachCodePoint

      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 - of the mbc-laden bytes
      each - 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 bytes
      offset - place in bytes to search past begin
      each - 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 form
      This 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 split
      pattern - the pattern to split value with
      bodyVisitor - visitor for all but last segment
      headVisitor - visitor for the last segment (if null if will use bodyVisitor).
      Returns:
      last T from headVisitor