Interface TagLimiter


public interface TagLimiter
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final int
     
    static final int
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the amount of currently read bytes.
    void
    checkLevel(int nestedLevel)
    Checks the current level of nesting and throws an exception if it exceeds the max levels.
    default void
     
    void
    countBytes(int bytes)
    Counts the given number of bytes and throws an exception if the max bytes count is exceeded.
    default void
     
    default void
     
    default void
     
    default void
     
    default void
     
    void
    Counts a single created tag and throws an exception if the max tag count is exceeded.
    static TagLimiter
    create(int maxBytes, int maxLevels)
    Returns a new tag limiter with the given max bytes, nesting levels and the default max tag count.
    static TagLimiter
    create(int maxBytes, int maxLevels, int maxTags)
    Returns a new tag limiter with the given max bytes, nesting levels and tag count.
    int
    Returns the max number of bytes to be read before an exception is thrown when reading nbt.
    int
    Returns the max number of levels of nesting before an exception is thrown when reading nbt.
    int
    Returns the max number of tags to be created before an exception is thrown when reading nbt.
    static TagLimiter
    Returns a noop tag limiter.
    void
    Resets the current byte and tag counts.
    int
    Returns the number of tags created so far.
  • Field Details

  • Method Details

    • create

      static TagLimiter create(int maxBytes, int maxLevels)
      Returns a new tag limiter with the given max bytes, nesting levels and the default max tag count.
      Parameters:
      maxBytes - max amount of bytes to be read before an exception is thrown when reading nbt
      maxLevels - max levels of nesting before an exception is thrown when reading nbt
      Returns:
      tag limiter
      See Also:
    • create

      static TagLimiter create(int maxBytes, int maxLevels, int maxTags)
      Returns a new tag limiter with the given max bytes, nesting levels and tag count.
      Parameters:
      maxBytes - max amount of bytes to be read before an exception is thrown when reading nbt
      maxLevels - max levels of nesting before an exception is thrown when reading nbt
      maxTags - max amount of tags to be created before an exception is thrown when reading nbt
      Returns:
      tag limiter
    • noop

      static TagLimiter noop()
      Returns a noop tag limiter.
      Returns:
      noop tag limiter
    • countBytes

      void countBytes(int bytes)
      Counts the given number of bytes and throws an exception if the max bytes count is exceeded.
      Parameters:
      bytes - bytes to count
      Throws:
      IllegalArgumentException - if max bytes count is exceeded
    • countTag

      void countTag()
      Counts a single created tag and throws an exception if the max tag count is exceeded.

      Called once per tag produced while reading, regardless of the tag's wire size, to bound the number of heap objects a single read can allocate.

      Throws:
      IllegalArgumentException - if the max tag count is exceeded
    • checkLevel

      void checkLevel(int nestedLevel)
      Checks the current level of nesting and throws an exception if it exceeds the max levels.
      Parameters:
      nestedLevel - current level of nesting
      Throws:
      IllegalArgumentException - if max level count is exceeded
    • countByte

      default void countByte()
    • countShort

      default void countShort()
    • countInt

      default void countInt()
    • countFloat

      default void countFloat()
    • countLong

      default void countLong()
    • countDouble

      default void countDouble()
    • maxBytes

      int maxBytes()
      Returns the max number of bytes to be read before an exception is thrown when reading nbt.
      Returns:
      max bytes
    • maxLevels

      int maxLevels()
      Returns the max number of levels of nesting before an exception is thrown when reading nbt.
      Returns:
      max nesting levels
    • maxTags

      int maxTags()
      Returns the max number of tags to be created before an exception is thrown when reading nbt.
      Returns:
      max tags
    • bytes

      int bytes()
      Returns the amount of currently read bytes.
      Returns:
      currently read bytes
    • tags

      int tags()
      Returns the number of tags created so far.
      Returns:
      currently created tag count
    • reset

      void reset()
      Resets the current byte and tag counts.