com.h3c.of.lib.msg

## Class QueueFactory

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

-     public class QueueFactory
      extends AbstractFactory

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

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static QueueProperty` | `createProperty(QueuePropType type, ExperimenterId eid, byte[] data)` Creates an experimenter property.
    `static QueueProperty` | `createProperty(QueuePropType type, int rate)` Creates a rate property.
    `static QueueProperty` | `createProperty(QueuePropType type, int encId, byte[] data)` Creates an experimenter property.
    `static MutableQueue` | `createQueue(ProtocolVersion pv)` Creates a mutable queue.
    `static void` | `encodeQueue(Queue queue, OfPacketWriter pkt)` Writes the specified queue structure into the specified buffer.
    `static void` | `encodeQueueList(List<Queue> queues, OfPacketWriter pkt)` Encodes a list of queues, writing them into the supplied buffer.
    `static int` | `getQueueStatsLength(ProtocolVersion pv)` Returns the length of a queue stats structure in bytes.
    `static List<Queue>` | `parseQueueList(int targetRi, OfPacketReader pkt, ProtocolVersion pv)` Parses a list of Queue structures from the supplied buffer.
    `protected String` | `tag()` Returns an identifying tag for the queue 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 queue factory.
      Specified by:
        `tag` in class `AbstractFactory`
      Returns:
        an identifying tag

    - #### parseQueueList

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

      Parses a list of Queue 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 read index at `targetRi`.

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

      Parameters:
        `targetRi` - the target reader index
        `pkt` - the data buffer
        `pv` - the protocol version
      Returns:
        a list of parsed queues
      Throws:
        `MessageParseException` - if a problem parsing the buffer

    - #### createQueue

          public static MutableQueue createQueue(ProtocolVersion pv)

      Creates a mutable queue. Initially, no fields are set.
      Parameters:
        `pv` - the required protocol version
      Returns:
        the queue structure
      Throws:
        `VersionNotSupportedException` - if the version is not supported

    - #### createProperty

          public static QueueProperty createProperty(QueuePropType type,
                                     int rate)

      Creates a rate property. The `type` parameter should be either `MIN_RATE` or `MAX_RATE`. The `rate` parameter is the rate expressed in 1/10ths of a percent. For example:
      - 455 = 45.5%
      - 1000 = 100.0%
      - >1000 = disabled
      Parameters:
        `type` - either MIN_RATE or MAX_RATE
        `rate` - the rate in 1/10ths of a percent
      Returns:
        a rate property
      Throws:
        `IllegalArgumentException` - if rate is invalid

    - #### createProperty

          public static QueueProperty createProperty(QueuePropType type,
                                     ExperimenterId eid,
                                     byte[] data)

      Creates an experimenter property. The `type` parameter must be `EXPERIMENTER`.
      Parameters:
        `type` - EXPERIMENTER
        `eid` - Experimenter id
        `data` - experimenter-defined data
      Returns:
        an experimenter property

    - #### createProperty

          public static QueueProperty createProperty(QueuePropType type,
                                     int encId,
                                     byte[] data)

      Creates an experimenter property. The `type` parameter must be `EXPERIMENTER`.
      Parameters:
        `type` - EXPERIMENTER
        `encId` - an encoded experimenter id
        `data` - experimenter-defined data
      Returns:
        an experimenter property

    - #### encodeQueueList

          public static void encodeQueueList(List<Queue> queues,
                             OfPacketWriter pkt)

      Encodes a list of queues, 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 queues.
      Parameters:
        `queues` - the list of queues
        `pkt` - the buffer into which the queues are to be written

    - #### encodeQueue

          public static void encodeQueue(Queue queue,
                         OfPacketWriter pkt)

      Writes the specified queue structure into the specified buffer. It is assumed that the writer index is in the correct place for the start of the structure. At the end of this method call, the writer index will have advanced by the length of the encoded queue.
      Parameters:
        `queue` - the queue to encode
        `pkt` - the buffer to write into
      Throws:
        `IllegalArgumentException` - if the queue is mutable

    - #### getQueueStatsLength

          public static int getQueueStatsLength(ProtocolVersion pv)

      Returns the length of a queue stats structure in bytes.
      Parameters:
        `pv` - the protocol version
      Returns:
        the length in bytes

Copyright © 2014. All Rights Reserved.