com.h3c.of.lib.msg

## Class MeterBandFactory

- java.lang.Object
- - com.h3c.of.lib.AbstractFactory
  - - com.h3c.of.lib.msg.MeterBandFactory

-     public class MeterBandFactory
      extends AbstractFactory

  Provides facilities for parsing, creating and encoding `MeterBand` instances.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static MeterBand` | `createBand(ProtocolVersion pv, MeterBandType type, long rate, long burstSize)` Creates a DROP meter band.
    `static MeterBand` | `createBand(ProtocolVersion pv, MeterBandType type, long rate, long burstSize, ExperimenterId eid)` Creates an EXPERIMENTER meter band.
    `static MeterBand` | `createBand(ProtocolVersion pv, MeterBandType type, long rate, long burstSize, int value)` Creates a DSCP_REMARK or EXPERIMENTER meter band.
    `static void` | `encodeBandList(List<MeterBand> bands, OfPacketWriter pkt)` Encodes a list of meter bands, writing them into the supplied buffer.
    `static int` | `getLength(MeterBand band)` Returns the length for the given meter band, in bytes.
    `static List<MeterBand>` | `parseMeterBandList(int targetRi, OfPacketReader pkt, ProtocolVersion pv)` Parses a list of meter band structures from the supplied buffer.
    `protected String` | `tag()` Returns an identifying tag for the meter band factory.

    - ### Methods inherited from class com.h3c.of.lib.AbstractFactory

      `mpe, mpe, mpe, mpe`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### tag

          protected String tag()

      Returns an identifying tag for the meter band factory.
      Specified by:
        `tag` in class `AbstractFactory`
      Returns:
        an identifying tag

    - #### parseMeterBandList

          public static List<MeterBand> parseMeterBandList(int targetRi,
                                           OfPacketReader pkt,
                                           ProtocolVersion pv)
                                                    throws MessageParseException

      Parses a list of meter band structures from the supplied buffer. The caller must calculate and specify the target reader index of the buffer that marks the end of the list, so we know when to stop.

      Note that this method causes the reader index of the underlying `PacketBuffer` to be advanced by the length of the list, which should leave the reader index at `targetRi`.

      This method delegates to `parseMeterBand(com.h3c.of.lib.OfPacketReader, com.h3c.of.lib.ProtocolVersion)` for each individual band.

      Parameters:
        `targetRi` - the target reader index
        `pkt` - the data buffer
        `pv` - the protocol version
      Returns:
        a list of parsed meter bands
      Throws:
        `MessageParseException` - if unable to parse the structure

    - #### createBand

          public static MeterBand createBand(ProtocolVersion pv,
                             MeterBandType type,
                             long rate,
                             long burstSize)

      Creates a DROP meter band.
      Parameters:
        `pv` - the protocol version
        `type` - the meter band type (DROP)
        `rate` - the rate for dropping packets (u32)
        `burstSize` - the size of bursts (u32)
      Returns:
        the meter band instance
      Throws:
        `VersionNotSupportedException` - if the version is not supported
        `VersionMismatchException` - if pv < 1.3
        `NullPointerException` - if pv or type is null
        `IllegalArgumentException` - if any argument is inappropriate

    - #### createBand

          public static MeterBand createBand(ProtocolVersion pv,
                             MeterBandType type,
                             long rate,
                             long burstSize,
                             int value)

      Creates a DSCP_REMARK or EXPERIMENTER meter band.
      Parameters:
        `pv` - the protocol version
        `type` - the meter band type (DSCP_REMARK or EXPERIMENTER)
        `rate` - the rate (u32)
        `burstSize` - the size of bursts (u32)
        `value` - either the number of precedence levels to subtract (DSCP_REMARK) or experimenter encoded id (EXPERIMENTER)
      Returns:
        the meter band instance
      Throws:
        `VersionNotSupportedException` - if the version is not supported
        `VersionMismatchException` - if pv < 1.3
        `NullPointerException` - if pv or type is null
        `IllegalArgumentException` - if any argument is inappropriate

    - #### createBand

          public static MeterBand createBand(ProtocolVersion pv,
                             MeterBandType type,
                             long rate,
                             long burstSize,
                             ExperimenterId eid)

      Creates an EXPERIMENTER meter band.
      Parameters:
        `pv` - the protocol version
        `type` - the meter band type (EXPERIMENTER)
        `rate` - the rate (u32)
        `burstSize` - the size of bursts (u32)
        `eid` - the experimenter id
      Returns:
        the meter band instance
      Throws:
        `VersionNotSupportedException` - if the version is not supported
        `VersionMismatchException` - if pv < 1.3
        `NullPointerException` - if pv, type or eid is null
        `IllegalArgumentException` - if any argument is inappropriate

    - #### encodeBandList

          public static void encodeBandList(List<MeterBand> bands,
                            OfPacketWriter pkt)

      Encodes a list of meter bands, writing them into the supplied buffer. Note that this method causes the writer index of the underlying `PacketBuffer` to be advanced by the length of the written bands.
      Parameters:
        `bands` - the list of meter bands
        `pkt` - the buffer into which the bands are to be written

    - #### getLength

          public static int getLength(MeterBand band)

      Returns the length for the given meter band, in bytes.
      Parameters:
        `band` - the target band
      Returns:
        the length of the band
      Throws:
        `NullPointerException` - if the band is null

Copyright © 2014. All Rights Reserved.