- java.lang.Object
- 
- org.apache.johnzon.core.Snippet
 
- 
 public class Snippet extends java.lang.ObjectConstructs short snippets of serialized JSON text representations of JsonValue instances in a way that is ideal for error messages. Instances of Snippet are thread-safe, reusable and memory-safe. Snippet serializes only enough of the json to fill the desired snippet size and is therefore safe to use regardless of the size of the JsonValue.
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description private classSnippet.BufferThere are several buffers involved in the creation of a json string.private static classSnippet.PassthroughWriter
 - 
Field SummaryFields Modifier and Type Field Description private jakarta.json.stream.JsonGeneratorFactorygeneratorFactoryprivate intmax
 - 
Constructor SummaryConstructors Constructor Description Snippet(int max, jakarta.json.stream.JsonGeneratorFactory generatorFactory)This is the preferred approach to using Snippet in any context where there is an existing JsonGeneratorFactory in scope.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Snippetof(int max)This factory should be used only in static or other scenarios were there is no JsonGeneratorFactory instance in scope - ie external code.static java.lang.Stringof(int max, jakarta.json.JsonValue value)Create a serialized json representation of the supplied JsonValue, truncating the value to the specified max length.java.lang.Stringof(jakarta.json.JsonValue value)Create a serialized json representation of the supplied JsonValue, truncating the value to the specified max length.
 
- 
- 
- 
Constructor Detail- 
Snippetpublic Snippet(int max, jakarta.json.stream.JsonGeneratorFactory generatorFactory)This is the preferred approach to using Snippet in any context where there is an existing JsonGeneratorFactory in scope.- Parameters:
- max- the maximum length of the serialized json produced via of()
- generatorFactory- the JsonGeneratorFactory created by the user
 
 
- 
 - 
Method Detail- 
ofpublic java.lang.String of(jakarta.json.JsonValue value) Create a serialized json representation of the supplied JsonValue, truncating the value to the specified max length. Truncated text appears with a suffix of "..." This method is thread safe.- Parameters:
- value- the JsonValue to be serialized as json text
- Returns:
- a potentially truncated json text
 
 - 
ofpublic static Snippet of(int max) This factory should be used only in static or other scenarios were there is no JsonGeneratorFactory instance in scope - ie external code.- Parameters:
- max- the maximum length of the serialized json produced via of()
 
 - 
ofpublic static java.lang.String of(int max, jakarta.json.JsonValue value)Create a serialized json representation of the supplied JsonValue, truncating the value to the specified max length. Truncated text appears with a suffix of "..." This method is thread safe. Avoid using this method in any context where there already is a JsonGeneratorFactory instance in scope. For those scenarios use the constructor that accepts a JsonGeneratorFactory instead.- Parameters:
- max- the maximum length of the serialized json text
- value- the JsonValue to be serialized as json text
- Returns:
- a potentially truncated json text
 
 
- 
 
-