Record Class Limits

java.lang.Object
java.lang.Record
dev.omnist.document.Limits
Record Components:
maxDepth - maximum nesting depth (reference default: 200)
maxNodeCount - maximum materialized node count (reference default: 1 000 000)
maxIntegerDigits - maximum decimal digits in an integer literal (reference default: 4 300)
maxInputBytes - maximum input size in bytes, counted before a byte-order mark is stripped and before decoding (default: DEFAULT_MAX_INPUT_BYTES, 64 MiB)

public record Limits(int maxDepth, int maxNodeCount, int maxIntegerDigits, int maxInputBytes) extends Record
Safety limits bounding Document nesting depth, node count, integer literal digits and input size (omnist-spec section 2.4 and 2.4.2).

Enforced by every untrusted-input entry point: OmlLexer, OsdReader, and each format codec's reader. Not by Node/Edge construction itself, which stays unconditionally trusting (a document already built in memory has no "input" left to bound).

Every reader that accepts a Limits applies all four bounds (D-9, D-23, E-4a): the OML reader through OmlReader.read(String, Limits), and the JSON, TOML and XML codecs through their readWithLimits methods (YAML through YamlCodec.readWithLimits(String, dev.omnist.codec.YamlLimits, Limits)). An over-limit input is refused with the OML reader's diagnostic whatever the format: document.limit.depth and document.limit.nodes at $, document.limit.int-digits at the Document path of the integer, which counts the decimal digits of the value (D-28), not of a hexadecimal, octal or binary spelling.

A value that is not positive is refused with IllegalArgumentException, never quietly replaced by the default or read as "no limit" (D-10: every bound is finite). maxInputBytes is also refused above MAX_INPUT_BYTES_CEILING.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Limits
    Normative reference default limits per omnist-spec §2.4, plus this port's input-size default.
    static final int
    This implementation's default maximum input size (D-23, D-24): 64 MiB.
    static final int
    Largest accepted maxInputBytes: 1 GiB, well inside a Java String and a heap.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Limits(int maxDepth, int maxNodeCount, int maxIntegerDigits)
    The limits of releases before the input-size bound existed: the given three, and the default DEFAULT_MAX_INPUT_BYTES input size.
    Limits(int maxDepth, int maxNodeCount, int maxIntegerDigits, int maxInputBytes)
    Creates an instance, validating its components.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    int
    Returns the value of the maxDepth record component.
    int
    Returns the value of the maxInputBytes record component.
    int
    Returns the value of the maxIntegerDigits record component.
    int
    Returns the value of the maxNodeCount record component.
    final String
    Returns a string representation of this record class.
    withMaxInputBytes(int bytes)
    Returns these limits with another input-size maximum.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • DEFAULT_MAX_INPUT_BYTES

      public static final int DEFAULT_MAX_INPUT_BYTES
      This implementation's default maximum input size (D-23, D-24): 64 MiB. The spec names no reference number; see docs/limitations.md for what was measured behind this one.
      See Also:
    • MAX_INPUT_BYTES_CEILING

      public static final int MAX_INPUT_BYTES_CEILING
      Largest accepted maxInputBytes: 1 GiB, well inside a Java String and a heap.
      See Also:
    • DEFAULT

      public static final Limits DEFAULT
      Normative reference default limits per omnist-spec §2.4, plus this port's input-size default.
  • Constructor Details

    • Limits

      public Limits(int maxDepth, int maxNodeCount, int maxIntegerDigits)
      The limits of releases before the input-size bound existed: the given three, and the default DEFAULT_MAX_INPUT_BYTES input size.
      Parameters:
      maxDepth - maximum nesting depth
      maxNodeCount - maximum materialized node count
      maxIntegerDigits - maximum decimal digits in an integer literal
      Throws:
      IllegalArgumentException - if any limit is not positive
    • Limits

      public Limits(int maxDepth, int maxNodeCount, int maxIntegerDigits, int maxInputBytes)
      Creates an instance, validating its components.
      Throws:
      IllegalArgumentException - if any limit is not positive, or maxInputBytes is above MAX_INPUT_BYTES_CEILING
  • Method Details

    • withMaxInputBytes

      public Limits withMaxInputBytes(int bytes)
      Returns these limits with another input-size maximum.
      Parameters:
      bytes - the new maxInputBytes
      Returns:
      a copy with maxInputBytes replaced
      Throws:
      IllegalArgumentException - if bytes is not positive or is above the ceiling
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • maxDepth

      public int maxDepth()
      Returns the value of the maxDepth record component.
      Returns:
      the value of the maxDepth record component
    • maxNodeCount

      public int maxNodeCount()
      Returns the value of the maxNodeCount record component.
      Returns:
      the value of the maxNodeCount record component
    • maxIntegerDigits

      public int maxIntegerDigits()
      Returns the value of the maxIntegerDigits record component.
      Returns:
      the value of the maxIntegerDigits record component
    • maxInputBytes

      public int maxInputBytes()
      Returns the value of the maxInputBytes record component.
      Returns:
      the value of the maxInputBytes record component