Enum Class BitSetFormat

java.lang.Object
java.lang.Enum<BitSetFormat>
org.apache.juneau.marshall.BitSetFormat
All Implemented Interfaces:
Serializable, Comparable<BitSetFormat>, Constable

public enum BitSetFormat extends Enum<BitSetFormat>
Supported wire formats for BitSet values.

Used by MarshallingContext.Builder.bitSetFormat(BitSetFormat), Marshalled.bitSetFormat(), MarshalledProp.bitSetFormat(), and MarshalledConfig.bitSetFormat() to control how BitSet values are written to text-based wire formats.

The default is INDICES which emits the ascending set-bit indices as a comma-delimited token.

Precedence (highest to lowest)
  1. @MarshalledProp(bitSetFormat=…) on the bean property.
  2. @Marshalled(bitSetFormat=…) on the bean class.
  3. @MarshalledConfig(bitSetFormat=…) on @Rest-annotated classes / methods.
  4. Programmatic MarshallingContext.Builder.bitSetFormat(BitSetFormat).
  5. Environment variable MarshallingContext.bitSetFormat.
  6. The default constant (INDICES).
Parsing

Parsing is directed by the configured constant — a serializer and parser sharing the same BitSetFormat round-trip cleanly. The three textual shapes are ambiguous with each other (a bare digit string is a valid index list, bit string, and hex token), so the configured format is honored rather than auto-detected.

  • Enum Constant Details

    • NOT_SET

      public static final BitSetFormat NOT_SET
      Sentinel meaning "no value configured" — falls through to the next-higher precedence level.
    • INDICES

      public static final BitSetFormat INDICES
      Ascending set-bit indices as a comma-delimited token (the default).
      Example:

      0,2,5

      An empty BitSet emits the empty string.

    • BITS

      public static final BitSetFormat BITS
      Little-endian bit string — character at position i is '1' when bit i is set.
      Example:

      101001

      The string length equals BitSet.length(); an empty BitSet emits the empty string.

    • HEX

      public static final BitSetFormat HEX
      Hex-encoded little-endian byte array (BitSet.toByteArray()).
      Example:

      25

      An empty BitSet emits the empty string.

  • Method Details

    • values

      public static BitSetFormat[] 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 BitSetFormat 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
    • format

      public static String format(BitSet value, BitSetFormat format)
      Formats the specified BitSet using this format.

      NOT_SET falls through to INDICES.

      Parameters:
      value - The value to format. Can be null (returns null).
      format - The format to use. Can be null (treated as INDICES).
      Returns:
      The formatted wire representation, or null if value is null.
    • parse

      public static BitSet parse(String value, BitSetFormat format)
      Parses the specified wire value into a BitSet.

      Parsing is directed by the format hint (defaulting to INDICES); the three textual shapes are mutually ambiguous, so the configured format is honored rather than auto-detected.

      Parameters:
      value - The wire value. Can be null (returns null) or blank (returns an empty BitSet).
      format - The configured format hint. Can be null (treated as INDICES).
      Returns:
      The parsed BitSet, or null if value is null.
      Throws:
      IllegalArgumentException - If the value does not match the configured textual shape.
    • isNumeric

      public boolean isNumeric()
      Returns true if this format is numeric on the wire.

      Always false — every constant emits a textual representation.

      Returns:
      false.