public class StreamReadConstraints extends Object implements Serializable
TokenStreamFactory
(such as
JsonFactory
); if nothing explicitly specified, default
constraints are used.
Currently constrained aspects, with default settings, are:
DEFAULT_MAX_NUM_LEN
)
DEFAULT_MAX_STRING_LEN
)
DEFAULT_MAX_DEPTH
)
Modifier and Type | Class and Description |
---|---|
static class |
StreamReadConstraints.Builder |
Modifier and Type | Field and Description |
---|---|
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. |
Modifier | Constructor and Description |
---|---|
protected |
StreamReadConstraints(int maxNestingDepth,
int maxNumLen,
int maxStringLen) |
Modifier and Type | Method and Description |
---|---|
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.
|
static void |
overrideDefaultStreamReadConstraints(StreamReadConstraints streamReadConstraints)
Override the default StreamReadConstraints.
|
StreamReadConstraints.Builder |
rebuild() |
void |
validateBigIntegerScale(int scale)
Convenience method that can be used to verify that a conversion to
BigInteger
StreamConstraintsException
is thrown. |
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. |
public static final int DEFAULT_MAX_DEPTH
StreamReadConstraints.Builder.maxNestingDepth(int)
for details.public static final int DEFAULT_MAX_NUM_LEN
StreamReadConstraints.Builder.maxNumberLength(int)
for details.public static final int DEFAULT_MAX_STRING_LEN
StreamReadConstraints.Builder.maxStringLength(int)
for details.
NOTE: Jackson 2.15.0 initially used a lower setting (5_000_000).
protected final int _maxNestingDepth
protected final int _maxNumLen
protected final int _maxStringLen
protected StreamReadConstraints(int maxNestingDepth, int maxNumLen, int maxStringLen)
public static void overrideDefaultStreamReadConstraints(StreamReadConstraints streamReadConstraints)
JsonFactory
instances are not configured with their own StreamReadConstraints.
Library maintainers should not set this as it will affect other code that uses Jackson.
Library maintainers who want to configure StreamReadConstraints for the Jackson usage within their
lib should create ObjectMapper
instances that have a JsonFactory
instance with
the required StreamReadConstraints.
This method is meant for users delivering applications. If they use this, they set it when they start their application to avoid having other code initialize their mappers before the defaults are overridden.
streamReadConstraints
- new default for StreamReadConstraints (a null value will reset to built-in default)defaults()
,
builder()
public static StreamReadConstraints.Builder builder()
public static StreamReadConstraints defaults()
StreamReadConstraints
(when none is set on the JsonFactory
explicitly)overrideDefaultStreamReadConstraints(com.fasterxml.jackson.core.StreamReadConstraints)
public StreamReadConstraints.Builder rebuild()
StreamReadConstraints.Builder
initialized with settings of this constraints
instancepublic int getMaxNestingDepth()
StreamReadConstraints.Builder.maxNestingDepth(int)
for details.public int getMaxNumberLength()
StreamReadConstraints.Builder.maxNumberLength(int)
for details.public int getMaxStringLength()
StreamReadConstraints.Builder.maxStringLength(int)
for details.public void validateNestingDepth(int depth) throws StreamConstraintsException
StreamConstraintsException
is thrown.depth
- count of unclosed objects and arraysStreamConstraintsException
- If depth exceeds maximumpublic void validateFPLength(int length) throws StreamConstraintsException
StreamConstraintsException
is thrown.length
- Length of number in input unitsStreamConstraintsException
- If length exceeds maximumpublic void validateIntegerLength(int length) throws StreamConstraintsException
StreamConstraintsException
is thrown.length
- Length of number in input unitsStreamConstraintsException
- If length exceeds maximumpublic void validateStringLength(int length) throws StreamConstraintsException
StreamConstraintsException
is thrown.length
- Length of string in input unitsStreamConstraintsException
- If length exceeds maximumpublic void validateBigIntegerScale(int scale) throws StreamConstraintsException
BigInteger
StreamConstraintsException
is thrown.scale
- Scale (possibly negative) of BigDecimal
to convertStreamConstraintsException
- If magnitude (absolute value) of scale exceeds maximum
allowedCopyright © 2008–2024 FasterXML. All rights reserved.