com.fasterxml.jackson.core

## Class StreamReadConstraints

- java.lang.Object
- - com.fasterxml.jackson.core.StreamReadConstraints

All Implemented Interfaces:
  Serializable

    public class StreamReadConstraints
    extends Object
    implements Serializable

The constraints to use for streaming reads: used to guard against malicious input by preventing processing of "too big" input constructs (values, structures). Constraints are registered with `TokenStreamFactory` (such as `JsonFactory`); if nothing explicitly specified, default constraints are used.

Currently constrained aspects, with default settings, are:

- Maximum Number value length: default 1000 (see `DEFAULT_MAX_NUM_LEN`)
- Maximum String value length: default 5_000_000 (see `DEFAULT_MAX_STRING_LEN`)
- Maximum Nesting depth: default 1000 (see `DEFAULT_MAX_DEPTH`)

Since:
  2.15
See Also:
  Serialized Form

### Nested Class Summary

Nested Classes
`static class` `StreamReadConstraints.Builder`

### Field Summary

Fields
`protected int` `_maxNestingDepth`
`protected int` `_maxNumLen`
`protected int` `_maxStringLen`
`static int` `DEFAULT_MAX_DEPTH` Default setting for maximum depth: see `StreamReadConstraints.Builder.maxNestingDepth(int)` for details.
`static int` `DEFAULT_MAX_NUM_LEN` Default setting for maximum number length: see `StreamReadConstraints.Builder.maxNumberLength(int)` for details.
`static int` `DEFAULT_MAX_STRING_LEN` Default setting for maximum string length: see `StreamReadConstraints.Builder.maxStringLength(int)` for details.

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`static StreamReadConstraints.Builder` `builder()`
`static StreamReadConstraints` `defaults()`
`int` `getMaxNestingDepth()` Accessor for maximum depth.
`int` `getMaxNumberLength()` Accessor for maximum length of numbers to decode.
`int` `getMaxStringLength()` Accessor for maximum length of strings to decode.
`StreamReadConstraints.Builder` `rebuild()`
`void` `validateFPLength(int length)` Convenience method that can be used to verify that a floating-point number of specified length does not exceed maximum specified by this constraints object: if it does, a `StreamConstraintsException` is thrown.
`void` `validateIntegerLength(int length)` Convenience method that can be used to verify that an integer number of specified length does not exceed maximum specific by this constraints object: if it does, a `StreamConstraintsException` is thrown.
`void` `validateNestingDepth(int depth)` Convenience method that can be used to verify that the nesting depth does not exceed the maximum specified by this constraints object: if it does, a `StreamConstraintsException` is thrown.
`void` `validateStringLength(int length)` Convenience method that can be used to verify that a String of specified length does not exceed maximum specific by this constraints object: if it does, a `StreamConstraintsException` is thrown.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### DEFAULT_MAX_DEPTH

    public static final int DEFAULT_MAX_DEPTH

Default setting for maximum depth: see `StreamReadConstraints.Builder.maxNestingDepth(int)` for details.

See Also:
  Constant Field Values

#### DEFAULT_MAX_NUM_LEN

    public static final int DEFAULT_MAX_NUM_LEN

Default setting for maximum number length: see `StreamReadConstraints.Builder.maxNumberLength(int)` for details.

See Also:
  Constant Field Values

#### DEFAULT_MAX_STRING_LEN

    public static final int DEFAULT_MAX_STRING_LEN

Default setting for maximum string length: see `StreamReadConstraints.Builder.maxStringLength(int)` for details.

See Also:
  Constant Field Values

#### _maxNestingDepth

    protected final int _maxNestingDepth

#### _maxNumLen

    protected final int _maxNumLen

#### _maxStringLen

    protected final int _maxStringLen

### Method Detail

#### builder

    public static StreamReadConstraints.Builder builder()

#### defaults

    public static StreamReadConstraints defaults()

#### rebuild

    public StreamReadConstraints.Builder rebuild()

Returns:
  New `StreamReadConstraints.Builder` initialized with settings of this constraints instance

#### getMaxNestingDepth

    public int getMaxNestingDepth()

Accessor for maximum depth. see `StreamReadConstraints.Builder.maxNestingDepth(int)` for details.

Returns:
  Maximum allowed depth

#### getMaxNumberLength

    public int getMaxNumberLength()

Accessor for maximum length of numbers to decode. see `StreamReadConstraints.Builder.maxNumberLength(int)` for details.

Returns:
  Maximum allowed number length

#### getMaxStringLength

    public int getMaxStringLength()

Accessor for maximum length of strings to decode. see `StreamReadConstraints.Builder.maxStringLength(int)` for details.

Returns:
  Maximum allowed string length

#### validateFPLength

    public void validateFPLength(int length)
                          throws StreamConstraintsException

Convenience method that can be used to verify that a floating-point number of specified length does not exceed maximum specified by this constraints object: if it does, a `StreamConstraintsException` is thrown.

Parameters:
  `length` - Length of number in input units
Throws:
  `StreamConstraintsException` - If length exceeds maximum

#### validateIntegerLength

    public void validateIntegerLength(int length)
                               throws StreamConstraintsException

Convenience method that can be used to verify that an integer number of specified length does not exceed maximum specific by this constraints object: if it does, a `StreamConstraintsException` is thrown.

Parameters:
  `length` - Length of number in input units
Throws:
  `StreamConstraintsException` - If length exceeds maximum

#### validateStringLength

    public void validateStringLength(int length)
                              throws StreamConstraintsException

Convenience method that can be used to verify that a String of specified length does not exceed maximum specific by this constraints object: if it does, a `StreamConstraintsException` is thrown.

Parameters:
  `length` - Length of string in input units
Throws:
  `StreamConstraintsException` - If length exceeds maximum

#### validateNestingDepth

    public void validateNestingDepth(int depth)
                              throws StreamConstraintsException

Convenience method that can be used to verify that the nesting depth does not exceed the maximum specified by this constraints object: if it does, a `StreamConstraintsException` is thrown.

Parameters:
  `depth` - count of unclosed objects and arrays
Throws:
  `StreamConstraintsException` - If depth exceeds maximum