java.lang.Object
com.siperf.amistream.protocol.messages.AmiMessage
com.siperf.amistream.protocol.messages.actions.AmiAction

public class AmiAction extends AmiMessage
Represents an AMI (Asterisk Manager Interface) action message.

This class extends AmiMessage and provides additional functionality for managing headers related to AMI actions, including the action type, action ID, and channel ID. It also formats the action message in text format for AMI communication.

See Also:
  • Constructor Details

    • AmiAction

      public AmiAction(AmiActionType actionType, ConnectionType processorType, String processorId)
      Constructs a new AmiAction using the specified action type, processor type, and processor ID.

      This constructor creates an action with a new ActionHeader based on the specified action type.

      Parameters:
      actionType - the AmiActionType representing the action type.
      processorType - the ConnectionType representing the type of processor.
      processorId - the ID of the processor initiating the action.
    • AmiAction

      public AmiAction(ActionHeader actionHeader, ConnectionType processorType, String processorId)
      Constructs a new AmiAction with the specified action header, processor type, and processor ID.

      This constructor allows the action header to be passed in directly, enabling more customization.

      Parameters:
      actionHeader - the ActionHeader representing the action type.
      processorType - the ConnectionType representing the type of processor.
      processorId - the ID of the processor initiating the action.
  • Method Details

    • getActionType

      public AmiActionType getActionType()
      Returns the action type of this AMI action.
      Returns:
      the AmiActionType of the action, or null if no action header is set.
    • getActionHeader

      public ActionHeader getActionHeader()
      Returns the ActionHeader associated with this AMI action.
      Returns:
      the ActionHeader for this action, or null if not set.
    • getActionId

      public String getActionId()
      Returns the action ID for this AMI action.

      This method retrieves the action ID from the ActionIdHeader, or null if not set.

      Overrides:
      getActionId in class AmiMessage
      Returns:
      the action ID, or null if not set.
    • getActionIdHeader

      public ActionIdHeader getActionIdHeader()
      Returns the ActionIdHeader associated with this AMI action.
      Overrides:
      getActionIdHeader in class AmiMessage
      Returns:
      the ActionIdHeader for this action, or null if not set.
    • getChannelId

      public String getChannelId()
      Returns the channel ID associated with this AMI action.

      This method retrieves the channel ID from the ChannelHeader, or null if not set.

      Overrides:
      getChannelId in class AmiMessage
      Returns:
      the channel ID, or null if not set.
    • getChannelHeader

      public ChannelHeader getChannelHeader()
      Returns the ChannelHeader associated with this AMI action.
      Overrides:
      getChannelHeader in class AmiMessage
      Returns:
      the ChannelHeader for this action, or null if not set.
    • addHeader

      public void addHeader(Header header)
      Adds a header to the AMI action message.

      This method adds headers of type ActionHeader, ActionIdHeader, or ChannelHeader. If the header is of another type, it is added to the parent class headers.

      Overrides:
      addHeader in class AmiMessage
      Parameters:
      header - the Header to be added to the AMI action.
    • toTextPresentation

      public String toTextPresentation()
      Converts this AMI action to its text representation.

      The format follows the convention: "AmiAction[actionType, channelId, actionId]". If the channel ID or action ID is not set, "N/A" is used instead.

      Overrides:
      toTextPresentation in class AmiMessage
      Returns:
      the string representation of this AMI action.
    • toString

      public String toString()
      Returns the string representation of this AMI action.

      This is equivalent to calling toTextPresentation().

      Overrides:
      toString in class AmiMessage
      Returns:
      the string representation of the AMI action.