java.lang.Object
org.rrd4j.core.RrdPrimitive<U>
org.rrd4j.core.RrdEnum<U,E>
Type Parameters:
U - The type of RrdUpdater this primitive belongs to
E - The enum type being stored

class RrdEnum<U extends RrdUpdater<U>, E extends Enum<E>>extends RrdPrimitive<U>
RRD primitive type for handling enum values.

This class provides methods to store and retrieve enum values in RRD files. It handles the conversion between enum constants and their string representations, with caching support for performance optimization.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private E
    The last value read, when caching is enabled.
    private final Class<E>
    The enum type this instance reads and writes.

    Fields inherited from class RrdPrimitive

    RRD_DOUBLE, RRD_INT, RRD_LONG, RRD_PRIM_SIZES, RRD_STRING, STRING_LENGTH
    Modifier and Type
    Field
    Description
    (package private) static final int
    Type identifier for double RRD primitives.
    (package private) static final int
    Type identifier for integer RRD primitives.
    (package private) static final int
    Type identifier for long RRD primitives.
    (package private) static final int[]
    Array containing the size in bytes for each RRD primitive type.
    (package private) static final int
    Type identifier for string RRD primitives.
    (package private) static final int
    Maximum length of string values stored in RRD primitives.
  • Constructor Summary

    Constructors
    Constructor
    Description
    RrdEnum(RrdUpdater<U> updater, boolean isConstant, Class<E> clazz)
    Create an enum-valued primitive.
    RrdEnum(RrdUpdater<U> updater, Class<E> clazz)
    Create a varying enum-valued primitive.
  • Method Summary

    All Methods
    Modifier and Type
    Method
    Description
    (package private) E
    get()
    Retrieve the stored enum value.
    (package private) String
    Gets the name of the enum value.
    (package private) void
    set(E value)
    Store an enum value with optional caching.

    Methods inherited from class RrdPrimitive

    isCachingAllowed, readBytes, readDouble, readDouble, readDouble, readEnum, readInt, readLong, readString, writeBytes, writeDouble, writeDouble, writeDouble, writeDouble, writeEnum, writeInt, writeLong, writeString
    Modifier and Type
    Method
    Description
    (package private) final boolean
    Checks if caching is allowed for this primitive.
    (package private) final byte[]
    Raw byte array from backend storage.
    (package private) final double
    Reads the double value from backend storage.
    (package private) final double
    readDouble(int index)
    Position in the primitive array.
    (package private) final double[]
    readDouble(int index, int count)
    Starting position in the primitive array.
    protected final <E extends Enum<E>>
    E
    readEnum(Class<E> clazz)
    Deserialize an enum value from backend storage.
    (package private) final int
    Reads the int value from backend storage.
    (package private) final long
    Reads the long value from backend storage.
    (package private) final String
    Reads the string value from backend storage.
    (package private) final void
    writeBytes(byte[] b)
    Byte array to write to backend storage.
    (package private) final void
    writeDouble(double value)
    Double value to write to backend storage.
    (package private) final void
    writeDouble(int index, double value)
    Position in the primitive array.
    (package private) final void
    writeDouble(int index, double[] values)
    Starting position in the primitive array.
    (package private) final void
    writeDouble(int index, double value, int count)
    Starting position in the primitive array.
    protected final <E extends Enum<E>>
    void
    writeEnum(E value)
    Serialize an enum value to backend storage.
    (package private) final void
    writeInt(int value)
    Int value to write to backend storage.
    (package private) final void
    writeLong(long value)
    Long value to write to backend storage.
    (package private) final void
    String value to write to backend storage.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • cache

      private E extends Enum<E> cache
      The last value read, when caching is enabled.
    • clazz

      private final Class<E extends Enum<E>> clazz
      The enum type this instance reads and writes.
  • Constructor Details

    • RrdEnum

      RrdEnum(RrdUpdater<U> updater, boolean isConstant, Class<E> clazz)
      Create an enum-valued primitive.
      Parameters:
      updater - the source of values
      isConstant - true to read a constant rather than a varying value
      clazz - the enum type to read and write
    • RrdEnum

      RrdEnum(RrdUpdater<U> updater, Class<E> clazz)
      Create a varying enum-valued primitive.
      Parameters:
      updater - the source of values
      clazz - the enum type to read and write
  • Method Details

    • set

      void set(E value) throws IOException
      Store an enum value with optional caching.
      Parameters:
      value - the enum value to set
      Throws:
      IOException - if an I/O error occurs
    • get

      E get() throws IOException
      Retrieve the stored enum value.
      Returns:
      the stored enum
      Throws:
      IOException - if an I/O error occurs
    • name

      String name() throws IOException
      Gets the name of the enum value.
      Returns:
      the name of the enum value
      Throws:
      IOException - if an I/O error occurs