Interface KeysAwareEncoder
- All Superinterfaces:
AutoCloseable, Encoder
- All Known Implementing Classes:
BsonWriterEncoder, JacksonEncoder, ProtobufEncoder, XmlStaxEncoder
Optional encoder capability for writing object keys from a known key set.
- Since:
- 3.1
- Author:
- Denis Stepanov
-
Method Summary
Modifier and TypeMethodDescriptionvoidEncode a key by index from the supplied key set.static voidencodeStringValue(Encoder encoder, Keys values, int index) Encode a string value by index from the supplied set of constant values with any encoder.default voidencodeStringValue(Keys values, int index) Encode a string value by index from the supplied set of constant values, such as the serialized names of the constants of an enum.static KeysAwareEncoderAdapt the encoder to the keys-aware contract.Methods inherited from interface Encoder
close, currentPath, encodeArray, encodeBigDecimal, encodeBigInteger, encodeBinary, encodeBoolean, encodeByte, encodeChar, encodeDouble, encodeFloat, encodeInt, encodeKey, encodeLong, encodeNull, encodeObject, encodeShort, encodeString, finishStructure
-
Method Details
-
of
Adapt the encoder to the keys-aware contract.- Parameters:
encoder- The encoder- Returns:
- A keys-aware encoder
-
encodeKey
Encode a key by index from the supplied key set.- Parameters:
keys- The keysindex- The key index- Throws:
IOException- If an unrecoverable error occurs
-
encodeStringValue
Encode a string value by index from the supplied set of constant values, such as the serialized names of the constants of an enum. An encoder can write a value it prepared once for the set instead of encoding the string again.- Parameters:
values- The valuesindex- The value index- Throws:
IOException- If an unrecoverable error occurs- Since:
- 3.3
-
encodeStringValue
Encode a string value by index from the supplied set of constant values with any encoder.- Parameters:
encoder- The encodervalues- The valuesindex- The value index- Throws:
IOException- If an unrecoverable error occurs- Since:
- 3.3
-