Top Description Inners Fields Constructors Methods
com.fasterxml.jackson.core

public Class StreamWriteConstraints

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Imports
com.fasterxml.jackson.core.exc.StreamConstraintsException

The constraints to use for streaming writes: used to guard against problematic output by preventing processing of "too big" output 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:

Since
2.16

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
protected final int
private static StreamWriteConstraints
public static final int
DEFAULT_MAX_DEPTH

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

private static final long

Constructor Summary

AccessConstructor and Description
protected
StreamWriteConstraints(final int maxNestingDepth)

Method Summary

Modifier and TypeMethod and Description
protected String
protected StreamConstraintsException
_constructException(String msgTemplate, Object... args)

public static StreamWriteConstraints.Builder
public static StreamWriteConstraints

Returns:

the default StreamWriteConstraints (when none is set on the JsonFactory explicitly)
defaults
()

public int

Returns:

Maximum allowed depth
getMaxNestingDepth
()

Accessor for maximum depth.

public static void
overrideDefaultStreamWriteConstraints(final StreamWriteConstraints
new default for StreamWriteConstraints (a null value will reset to built-in default)
streamWriteConstraints
)

Override the default StreamWriteConstraints.

public StreamWriteConstraints.Builder

Returns:

New Builder initialized with settings of this constraints instance
rebuild
()

public void
validateNestingDepth(int
count of unclosed objects and arrays
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.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_maxNestingDepthback to summary
protected final int _maxNestingDepth
DEFAULTback to summary
private static StreamWriteConstraints DEFAULT
DEFAULT_MAX_DEPTHback to summary
public static final int DEFAULT_MAX_DEPTH

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

serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

StreamWriteConstraintsback to summary
protected StreamWriteConstraints(final int maxNestingDepth)

Method Detail

_constrainRefback to summary
protected String _constrainRef(String method)
_constructExceptionback to summary
protected StreamConstraintsException _constructException(String msgTemplate, Object... args) throws StreamConstraintsException
builderback to summary
public static StreamWriteConstraints.Builder builder()
defaultsback to summary
public static StreamWriteConstraints defaults()
Returns:StreamWriteConstraints

the default StreamWriteConstraints (when none is set on the JsonFactory explicitly)

See Also
overrideDefaultStreamWriteConstraints(StreamWriteConstraints)
getMaxNestingDepthback to summary
public int getMaxNestingDepth()

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

Returns:int

Maximum allowed depth

overrideDefaultStreamWriteConstraintsback to summary
public static void overrideDefaultStreamWriteConstraints(final StreamWriteConstraints streamWriteConstraints)

Override the default StreamWriteConstraints. These defaults are only used when JsonFactory instances are not configured with their own StreamWriteConstraints.

Library maintainers should not set this as it will affect other code that uses Jackson. Library maintainers who want to configure StreamWriteConstraints for the Jackson usage within their lib should create ObjectMapper instances that have a JsonFactory instance with the required StreamWriteConstraints.

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.

Parameters
streamWriteConstraints:StreamWriteConstraints

new default for StreamWriteConstraints (a null value will reset to built-in default)

See Also
defaults(), builder()
rebuildback to summary
public StreamWriteConstraints.Builder rebuild()
Returns:StreamWriteConstraints.Builder

New Builder initialized with settings of this constraints instance

validateNestingDepthback to summary
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:int

count of unclosed objects and arrays

Exceptions
StreamConstraintsException:
If depth exceeds maximum
com.fasterxml.jackson.core back to summary

public final Class StreamWriteConstraints.Builder

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private int

Constructor Summary

AccessConstructor and Description
pack-priv
pack-priv
Builder(final int maxNestingDepth)

pack-priv

Method Summary

Modifier and TypeMethod and Description
public StreamWriteConstraints
public StreamWriteConstraints.Builder

Returns:

this builder
maxNestingDepth
(final int
the maximum depth
maxNestingDepth
)

Sets the maximum nesting depth.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

maxNestingDepthback to summary
private int maxNestingDepth

Constructor Detail

Builderback to summary
pack-priv Builder()
Builderback to summary
pack-priv Builder(final int maxNestingDepth)
Builderback to summary
pack-priv Builder(StreamWriteConstraints src)

Method Detail

buildback to summary
public StreamWriteConstraints build()
maxNestingDepthback to summary
public StreamWriteConstraints.Builder maxNestingDepth(final int maxNestingDepth)

Sets the maximum nesting depth. The depth is a count of objects and arrays that have not been closed, `{` and `[` respectively.

Parameters
maxNestingDepth:int

the maximum depth

Returns:StreamWriteConstraints.Builder

this builder

Exceptions
IllegalArgumentException:
if the maxNestingDepth is set to a negative value