Enum Class Codecs.Termination

java.lang.Object
java.lang.Enum<Codecs.Termination>
io.bytestreams.codec.core.Codecs.Termination
All Implemented Interfaces:
Serializable, Comparable<Codecs.Termination>, Constable
Enclosing class:
Codecs

public static enum Codecs.Termination extends Enum<Codecs.Termination>
Policy for decoding a value whose terminator is absent at the end of the stream.

Encoding always writes the terminator regardless of this setting, so decoding an unterminated final value and re-encoding it adds one. Use RecordingCodec when the original bytes must be preserved exactly.

  • Enum Constant Details

    • OPTIONAL

      public static final Codecs.Termination OPTIONAL
      A final value without a terminator is valid. Suitable for file formats, where end-of-stream already marks the end of the last value.

      Whatever was read is passed to the value codec, including nothing at all, so the value codec decides whether empty is valid — Codecs.ascii() yields an empty string, while Codecs.ascii(int) still reports end-of-stream.

    • REQUIRED

      public static final Codecs.Termination REQUIRED
      Every value must be terminated. Suitable for message formats, where the terminator is how the end of a value is known.
  • Method Details

    • values

      public static Codecs.Termination[] 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

      public static Codecs.Termination valueOf(String name)
      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 name
      NullPointerException - if the argument is null