Class MemorySegmentUtil

java.lang.Object
com.hypixel.hytale.server.core.util.io.MemorySegmentUtil

public class MemorySegmentUtil extends Object
  • Field Details

  • Constructor Details

    • MemorySegmentUtil

      public MemorySegmentUtil()
  • Method Details

    • utf8Size

      public static int utf8Size(@Nonnull String string)
      Returns the number of bytes a UTF-8 string will occupy when serialized with a 2-byte length header.
    • utf8Size

      public static int utf8Size(@Nonnull MemorySegment segment, long offset)
      Returns the number of bytes a serialized UTF-8 string occupies at the given offset, including the 2-byte length header.
    • writeUTF

      public static int writeUTF(@Nonnull MemorySegment segment, long offset, @Nonnull String string)
      Writes a UTF-8 string with a big-endian unsigned short length header.
      Returns:
      the number of bytes written (length header + encoded string)
    • readUTF

      @Nonnull public static String readUTF(@Nonnull MemorySegment segment, long offset)
      Reads a UTF-8 string with a big-endian unsigned short length header.
    • writeNumber

      public static void writeNumber(@Nonnull MemorySegment data, int offset, int bytes, int value)
    • readNumber

      public static int readNumber(@Nonnull MemorySegment data, int offset, int bytes)