public class StreamWriteConstraints 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_DEPTH
)
Modifier and Type | Class and Description |
---|---|
static class |
StreamWriteConstraints.Builder |
Modifier and Type | Field and Description |
---|---|
protected int |
_maxNestingDepth |
static int |
DEFAULT_MAX_DEPTH
Default setting for maximum depth: see
StreamWriteConstraints.Builder.maxNestingDepth(int) for details. |
Modifier | Constructor and Description |
---|---|
protected |
StreamWriteConstraints(int maxNestingDepth) |
Modifier and Type | Method and Description |
---|---|
protected String |
_constrainRef(String method) |
protected StreamConstraintsException |
_constructException(String msgTemplate,
Object... args) |
static StreamWriteConstraints.Builder |
builder() |
static StreamWriteConstraints |
defaults() |
int |
getMaxNestingDepth()
Accessor for maximum depth.
|
static void |
overrideDefaultStreamWriteConstraints(StreamWriteConstraints streamWriteConstraints)
Override the default StreamWriteConstraints.
|
StreamWriteConstraints.Builder |
rebuild() |
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. |
public static final int DEFAULT_MAX_DEPTH
StreamWriteConstraints.Builder.maxNestingDepth(int)
for details.protected final int _maxNestingDepth
public static void overrideDefaultStreamWriteConstraints(StreamWriteConstraints streamWriteConstraints)
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.
streamWriteConstraints
- new default for StreamWriteConstraints (a null value will reset to built-in default)defaults()
,
builder()
public static StreamWriteConstraints.Builder builder()
public static StreamWriteConstraints defaults()
StreamWriteConstraints
(when none is set on the JsonFactory
explicitly)overrideDefaultStreamWriteConstraints(StreamWriteConstraints)
public StreamWriteConstraints.Builder rebuild()
StreamWriteConstraints.Builder
initialized with settings of this constraints
instancepublic int getMaxNestingDepth()
StreamWriteConstraints.Builder.maxNestingDepth(int)
for details.public void validateNestingDepth(int depth) throws StreamConstraintsException
StreamConstraintsException
is thrown.depth
- count of unclosed objects and arraysStreamConstraintsException
- If depth exceeds maximumprotected StreamConstraintsException _constructException(String msgTemplate, Object... args) throws StreamConstraintsException
StreamConstraintsException
Copyright © 2008–2023 FasterXML. All rights reserved.