com.h3c.of.lib.msg

## Class OpenflowMessage

- java.lang.Object
- - com.h3c.nbio.AbstractMessage
  - - com.h3c.of.lib.msg.OpenflowMessage

- All Implemented Interfaces:
    Message, Structure
  Direct Known Subclasses:
    OfmBarrierReply, OfmBarrierRequest, OfmEchoReply, OfmEchoRequest, OfmError, OfmExperimenter, OfmFeaturesReply, OfmFeaturesRequest, OfmFlowMod, OfmFlowRemoved, OfmGetAsyncReply, OfmGetAsyncRequest, OfmGetConfigReply, OfmGetConfigRequest, OfmGroupMod, OfmHello, OfmMeterMod, OfmMultipartReply, OfmMultipartRequest, OfmPacketIn, OfmPacketOut, OfmPortMod, OfmPortStatus, OfmQueueGetConfigReply, OfmQueueGetConfigRequest, OfmSetAsync, OfmSetConfig, OfmTableMod, Role

      public abstract class OpenflowMessage
      extends AbstractMessage
      implements Message

  Base class for all OpenFlow messages.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `OpenflowMessage.Header` Represents the header common to all OpenFlow messages.

  - ### Field Summary

    - ### Fields inherited from class com.h3c.nbio.AbstractMessage

      `length`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static String` | `decodeHeader(byte[] bytes)` A utility method that will attempt to decode the given bytes as an openflow message header, and return a string representation of the result.
    `MessageType` | `getType()` Returns the message type.
    `ProtocolVersion` | `getVersion()` Returns the protocol version of this OpenFlow structure.
    `long` | `getXid()` Returns the transaction id of this message.
    `protected static String` | `hex(int value)` Returns the given int as a string in hex form.
    `protected static String` | `hex(long value)` Returns the given long as a string in hex form.
    `int` | `length()` Gets the message length in bytes.
    `String` | `toDebugString()` Returns a string representation useful for debugging.
    `String` | `toString()`
    `void` | `validate()` Validates this message for completeness and throws an exception if the message is considered "not complete".

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

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

- - ### Method Detail

    - #### getVersion

          public ProtocolVersion getVersion()

      Description copied from interface: `Structure`
      Returns the protocol version of this OpenFlow structure.
      Specified by:
        `getVersion` in interface `Structure`
      Returns:
        the structure protocol version

    - #### getType

          public MessageType getType()

      Description copied from interface: `Message`
      Returns the message type.
      Returns:
        the message type

    - #### length

          public int length()

      Description copied from interface: `Message`
      Gets the message length in bytes.
      Specified by:
        `length` in interface `Message`
      Overrides:
        `length` in class `AbstractMessage`
      Returns:
        number of bytes

    - #### getXid

          public long getXid()

      Description copied from interface: `Message`
      Returns the transaction id of this message.
      Returns:
        the message transaction id

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### toDebugString

          public String toDebugString()

      Returns a string representation useful for debugging. This default implementation delegates to `toString()`, but subclasses are free to override this behavior.
      Specified by:
        `toDebugString` in interface `Structure`
      Returns:
        a (possibly multi-line) string representation of this message

    - #### validate

          public void validate()
                        throws IncompleteMessageException

      Validates this message for completeness and throws an exception if the message is considered "not complete".

      This default implementation does nothing, i.e. default behavior is that messages are considered complete.

      Subclasses should override this method to check that mandatory fields or other internal state is present, throwing an exception if it is not.

      Throws:
        `IncompleteMessageException` - if the message is not complete

    - #### decodeHeader

          public static String decodeHeader(byte[] bytes)

      A utility method that will attempt to decode the given bytes as an openflow message header, and return a string representation of the result. The array should be at least 8 bytes in length.
      Parameters:
        `bytes` - the bytes to decode
      Returns:
        a string representation of the header
      Throws:
        `NullPointerException` - if bytes is null
        `IllegalArgumentException` - if the array is too short

    - #### hex

          protected static String hex(long value)

      Returns the given long as a string in hex form.
      Parameters:
        `value` - the value
      Returns:
        the value in hex form

    - #### hex

          protected static String hex(int value)

      Returns the given int as a string in hex form.
      Parameters:
        `value` - the value
      Returns:
        the value in hex form

Copyright © 2014. All Rights Reserved.