Enum Class BinaryFormat
- All Implemented Interfaces:
Serializable,Comparable<BinaryFormat>,Constable
byte [] values and stream-based serialization output.
Used by MarshallingContext.Builder.binaryFormat(BinaryFormat),
Marshalled.binaryFormat(),
MarshalledProp.binaryFormat(), and
MarshalledConfig.binaryFormat() to control how
values are written to and read from the wire on text formats, as well as
the encoding used by stream-based serializers when converting their byte output to a string.
The default is NOT_SET — leaves byte[] handling to the surrounding serializer / parser
(e.g. textual serializers fall back to the natural language-level array representation, and binary
serializers emit native bytes). Callers wanting a textual encoding on the wire should set this to
HEX, BASE64, SPACED_HEX, or BASE64_URL.
Binary serializers (BSON / CBOR / MsgPack / Prototext) emit native bytes regardless of the configured
BinaryFormat; this setting only affects text-based serializers and the
OutputStreamSerializerSession#writeToString(Object) stream-to-string convenience.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionformat(byte[] value) Formats the specified value using this format.byte[]Parses the specified wire value using this format.static BinaryFormatReturns the enum constant of this class with the specified name.static BinaryFormat[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
NOT_SET
Sentinel meaning "no value configured" — falls through to the next-higher precedence level. -
SPACED_HEX
Spaced-hex.Example:
12 34 56 78 90 AB CD EF
-
HEX
Hex.Example:
1234567890ABCDEF
-
BASE64
StandardBase64encoding. -
BASE64_URL
URL-safeBase64encoding (RFC 4648 §5).Uses
-and_in place of+and/. Padding (=) is omitted on the wire but accepted on input.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
format
Formats the specified value using this format.- Parameters:
value- The value to format. Can benull (returnsnull ).- Returns:
- The formatted string, or
null ifvalueisnull .
-
parse
Parses the specified wire value using this format.The parser accepts any of the formats produced by
format(byte[])regardless of the configured constant, mirroring the format-agnostic parser convention used by other<type>Formatenums in this package. The configured format is consulted only as a hint for ambiguous input.- Parameters:
value- The wire value. Can benull or blank (returns an empty array).- Returns:
- The parsed bytes, or an empty array if
valueisnull or blank.
-