Package ptolemy.actor

Class Mailbox

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected Token _token
      The token held.
    • Constructor Summary

      Constructors 
      Constructor Description
      Mailbox()
      Construct an empty Mailbox with no container.
      Mailbox​(IOPort container)
      Construct an empty Mailbox with the specified container.
    • Field Detail

      • _token

        protected Token _token
        The token held.
    • Constructor Detail

      • Mailbox

        public Mailbox()
        Construct an empty Mailbox with no container.
      • Mailbox

        public Mailbox​(IOPort container)
                throws IllegalActionException
        Construct an empty Mailbox with the specified container.
        Parameters:
        container - The container.
        Throws:
        IllegalActionException - If the container does not accept this receiver.
    • Method Detail

      • elementList

        public java.util.List<Token> elementList()
        Return a list with the token currently in the receiver, or an empty list if there is no such token.
        Specified by:
        elementList in interface Receiver
        Overrides:
        elementList in class AbstractReceiver
        Returns:
        A list of instances of Token.
      • hasRoom

        public boolean hasRoom()
        Return true if this mailbox is empty.
        Specified by:
        hasRoom in interface Receiver
        Specified by:
        hasRoom in class AbstractReceiver
        Returns:
        True if this mailbox is empty.
      • hasRoom

        public boolean hasRoom​(int numberOfTokens)
                        throws java.lang.IllegalArgumentException
        Return true if the argument is 1 and the mailbox is empty, and otherwise return false.
        Specified by:
        hasRoom in interface Receiver
        Specified by:
        hasRoom in class AbstractReceiver
        Parameters:
        numberOfTokens - The number of tokens to put into the mailbox.
        Returns:
        True if the argument is 1 and the mailbox is empty, and otherwise return false.
        Throws:
        java.lang.IllegalArgumentException - If the argument is not positive. This is a runtime exception, so it does not need to be declared explicitly.
      • hasToken

        public boolean hasToken()
        Return true if this mailbox is not empty.
        Specified by:
        hasToken in interface Receiver
        Specified by:
        hasToken in class AbstractReceiver
        Returns:
        True if this mailbox is not empty.
      • hasToken

        public boolean hasToken​(int numberOfTokens)
                         throws java.lang.IllegalArgumentException
        Return true if the argument is 1 and this mailbox is not empty, and otherwise return false.
        Specified by:
        hasToken in interface Receiver
        Specified by:
        hasToken in class AbstractReceiver
        Parameters:
        numberOfTokens - The number of tokens to get from the receiver.
        Returns:
        True if the argument is 1 and this mailbox is not empty.
        Throws:
        java.lang.IllegalArgumentException - If the argument is not positive. This is a runtime exception, so it does not need to be declared explicitly.
      • put

        public void put​(Token token)
                 throws NoRoomException
        Put a token into the mailbox. If the argument is null, then the mailbox will not contain a token after this returns.
        Specified by:
        put in interface Receiver
        Specified by:
        put in class AbstractReceiver
        Parameters:
        token - The token to be put into the mailbox.
        Throws:
        NoRoomException - If this mailbox is not empty.