com.h3c.of.ctl.pkt

## Class MessageContextAdapter

- java.lang.Object
- - com.h3c.of.ctl.pkt.MessageContextAdapter

- All Implemented Interfaces:
    MessageContext

      public class MessageContextAdapter
      extends Object
      implements MessageContext

  An adapter for the `MessageContext` interface. This class can be used as a base for unit tests that wish to provide mocked message contexts.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `MessageContextAdapter()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `MessageContext` | `addHint(Hint hint)` Adds a hint to the context.
    `Packet` | `decodedPacket()` Returns the decoded packet data generated by the Network Packet Library facility.
    `boolean` | `failedToSend()` This flag is set in the unlikely event that the packet sequencer failed to send the PacketOut message via the controller.
    `OfmPacketOut` | `getCompletedPacketOut()` Returns the PacketOut message that was sent back to the source datapath.
    `List<Hint>` | `getHints()` Returns the hints contained in this context, in the order they were added by the Advisors.
    `OfmPacketIn` | `getPacketIn()` Convenience method that returns the PacketIn message from the message event.
    `List<ProtocolId>` | `getProtocols()` Returns an ordered list of `protocols` decoded from the packet.
    `ProtocolVersion` | `getVersion()` Returns the protocol version of the associated PacketIn message event.
    `boolean` | `isHandled()` Returns true if the associated message event has already been handled.
    `boolean` | `isTestPacket()` Returns true if the associated packet has been determined to be a diagnostic test packet.
    `PacketOut` | `packetOut()` Returns the API for manipulating the PacketOut message.
    `void` | `resetHandled()`
    `MessageEvent` | `srcEvent()` Returns the associated PacketIn message event.
    `String` | `toDebugString()` Returns a multi-line string representation of this message context, suitable for debugging.

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

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

- - ### Constructor Detail

    - #### MessageContextAdapter

          public MessageContextAdapter()

  - ### Method Detail

    - #### srcEvent

          public MessageEvent srcEvent()

      Description copied from interface: `MessageContext`
      Returns the associated PacketIn message event.
      Specified by:
        `srcEvent` in interface `MessageContext`
      Returns:
        the PacketIn message event

    - #### getVersion

          public ProtocolVersion getVersion()

      Description copied from interface: `MessageContext`
      Returns the protocol version of the associated PacketIn message event.
      Specified by:
        `getVersion` in interface `MessageContext`
      Returns:
        the protocol version

    - #### getPacketIn

          public OfmPacketIn getPacketIn()

      Description copied from interface: `MessageContext`
      Convenience method that returns the PacketIn message from the message event.
      Specified by:
        `getPacketIn` in interface `MessageContext`
      Returns:
        the PacketIn message

    - #### decodedPacket

          public Packet decodedPacket()

      Description copied from interface: `MessageContext`
      Returns the decoded packet data generated by the Network Packet Library facility. This will be null if there is no packet data associated with the PacketIn message.
      Specified by:
        `decodedPacket` in interface `MessageContext`
      Returns:
        the decoded packet data

    - #### getProtocols

          public List<ProtocolId> getProtocols()

      Description copied from interface: `MessageContext`
      Returns an ordered list of `protocols` decoded from the packet. The protocols are ordered from outermost to innermost layer. This will be null if there is no packet data associated with the PacketIn message.
      Specified by:
        `getProtocols` in interface `MessageContext`
      Returns:
        the list of protocols

    - #### packetOut

          public PacketOut packetOut()

      Description copied from interface: `MessageContext`
      Returns the API for manipulating the PacketOut message.
      Specified by:
        `packetOut` in interface `MessageContext`
      Returns:
        the packet out API

    - #### getCompletedPacketOut

          public OfmPacketOut getCompletedPacketOut()

      Description copied from interface: `MessageContext`
      Returns the PacketOut message that was sent back to the source datapath. Note that this method will return null if the PacketOut message has not yet been sent.
      Specified by:
        `getCompletedPacketOut` in interface `MessageContext`
      Returns:
        the PacketOut message

    - #### addHint

          public MessageContext addHint(Hint hint)

      Description copied from interface: `MessageContext`
      Adds a hint to the context.
      Specified by:
        `addHint` in interface `MessageContext`
      Parameters:
        `hint` - the hint to be added
      Returns:
        self, for chaining

    - #### getHints

          public List<Hint> getHints()

      Description copied from interface: `MessageContext`
      Returns the hints contained in this context, in the order they were added by the Advisors.
      Specified by:
        `getHints` in interface `MessageContext`
      Returns:
        the hints

    - #### isHandled

          public boolean isHandled()

      Description copied from interface: `MessageContext`
      Returns true if the associated message event has already been handled.
      Specified by:
        `isHandled` in interface `MessageContext`
      Returns:
        true if handled; false otherwise

    - #### failedToSend

          public boolean failedToSend()

      Description copied from interface: `MessageContext`
      This flag is set in the unlikely event that the packet sequencer failed to send the PacketOut message via the controller.
      Specified by:
        `failedToSend` in interface `MessageContext`
      Returns:
        true if an error occurred during send

    - #### toDebugString

          public String toDebugString()

      Description copied from interface: `MessageContext`
      Returns a multi-line string representation of this message context, suitable for debugging.
      Specified by:
        `toDebugString` in interface `MessageContext`
      Returns:
        a multi-line string representation

    - #### isTestPacket

          public boolean isTestPacket()

      Description copied from interface: `MessageContext`
      Returns true if the associated packet has been determined to be a diagnostic test packet.
      Specified by:
        `isTestPacket` in interface `MessageContext`
      Returns:
        true if a diagnostic test packet; false otherwise

    - #### resetHandled

          public void resetHandled()

      Specified by:
        `resetHandled` in interface `MessageContext`

Copyright © 2014. All Rights Reserved.