- All Known Implementing Classes:
ObjectWriteContext.Base
public interface ObjectWriteContext
Defines API for accessing configuration and state exposed by
higher level databind
functionality during write (Object to token stream serialization) process.
Access is mostly needed during construction of
JsonGenerator instances by TokenStreamFactory.- Since:
- 3.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classDefault no-op implementation. -
Method Summary
Modifier and TypeMethodDescriptionMethod for construct Array nodes for Tree Model instances.default JsonGeneratordefault JsonGeneratorcreateGenerator(OutputStream out, JsonEncoding enc) default JsonGeneratorMethod for construct Object nodes for Tree Model instances.static ObjectWriteContextempty()intgetFormatWriteFeatures(int defaults) Accessor for gettingPrettyPrinterinstance to use for a new generator.getRootValueSeparator(SerializableString defaultSeparator) intgetStreamWriteFeatures(int defaults) booleanAccessor similar togetPrettyPrinter()but which only indicates whether a non-nullinstance would be constructed if requested, or not.voidwriteTree(JsonGenerator g, TreeNode value) voidwriteValue(JsonGenerator g, Object value) Method that may be called to serialize given value, using specified token stream generator.
-
Method Details
-
empty
-
getSchema
FormatSchema getSchema() -
getCharacterEscapes
CharacterEscapes getCharacterEscapes() -
getPrettyPrinter
PrettyPrinter getPrettyPrinter()Accessor for gettingPrettyPrinterinstance to use for a new generator. Note that this MUST BE a thread-safe instance: that is, if the pretty printer implementation is stateful, a new unshared instance needs to be returned -- caller will NOT try to make a copy ofInstantiatableprinters, context must do that.- Returns:
PrettyPrinterinstance to use for a single serialization operation
-
hasPrettyPrinter
boolean hasPrettyPrinter()Accessor similar togetPrettyPrinter()but which only indicates whether a non-nullinstance would be constructed if requested, or not. This is useful for backends that have custom pretty-printing instead of relying on Jackson standard mechanism.- Returns:
- True if
getPrettyPrinter()would return non-null; false otherwise.
-
getRootValueSeparator
-
getStreamWriteFeatures
int getStreamWriteFeatures(int defaults) -
getFormatWriteFeatures
int getFormatWriteFeatures(int defaults) -
tokenStreamFactory
TokenStreamFactory tokenStreamFactory() -
createGenerator
- Throws:
JacksonException
-
createGenerator
- Throws:
JacksonException
-
createGenerator
- Throws:
JacksonException
-
createArrayNode
ArrayTreeNode createArrayNode()Method for construct Array nodes for Tree Model instances.- Returns:
- Array node created
-
createObjectNode
ObjectTreeNode createObjectNode()Method for construct Object nodes for Tree Model instances.- Returns:
- Object node created
-
writeValue
Method that may be called to serialize given value, using specified token stream generator.- Parameters:
g- Generator to use for serializationvalue- Java value to be serialized- Throws:
JacksonIOException- for low-level write problems,StreamWriteException- for encoding problemsJacksonException- (various subtypes) for databinding problems
-
writeTree
- Throws:
JacksonException
-