Class ReadCursor

java.lang.Object
com.hypixel.hytale.protocol.io.ReadCursor

public final class ReadCursor extends Object
Receives the end position of a decode. toObject reports through this where the encoding of the value it decoded ends, so a caller reading a sequence of variable-size values can advance to the next one without measuring the decoded value a second time.

One cursor serves a whole decode, so it also counts how deep that decode has walked. A polymorphic value may hold further values of its own base type, and the decode of such a chain recurses once per link. The count bounds the chain, which bounds the stack the decode needs.

  • Field Details

    • MAX_NESTING_DEPTH

      public static final int MAX_NESTING_DEPTH
      Longest chain of nested polymorphic values one decode may walk. Well above what the protocol uses, and far below the depth that would exhaust the stack of the thread doing the decode. This is a wire limit, so the C# reader (see NestingDepth.Max) uses the same value.
      See Also:
    • position

      public int position
      Absolute segment position of the first byte after the decoded value.
  • Constructor Details

    • ReadCursor

      public ReadCursor()
  • Method Details

    • enterNested

      public void enterNested(@Nonnull String typeName)
      Counts entry into a nested value. Rejects a value nested past MAX_NESTING_DEPTH. Every call that returns must be paired with exitNested().
    • exitNested

      public void exitNested()
      Counts the end of the nested value that the matching enterNested(String) started.