Interface ContainerModel


public interface ContainerModel

This interface defines a model that represents a container. Implement it to simplify the processing of incoming ContainerMessages.

 

Note: You do not have to use this interface to process ContainerMessages. You can instead use the basic approach, as explained in ContainerMessage.getOperations().

 

To use the ContainerModel interface:

 

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addElement(String subject)
    Called to indicate that you should add (append) an element with the given subject to the container.
    void
    insertElement(String subject, int position)
    Called to indicate that you should insert an element with the given subject at the given position within the container.
    void
    Called to indicate that you should remove the element with the given subject from the container.
    void
    Called to indicate that you should remove all elements from the container that have a subject that matches the specified prefix.
  • Method Details

    • addElement

      void addElement(String subject)

      Called to indicate that you should add (append) an element with the given subject to the container.

       

      The element must be added to the end of the container. For example, if there are three elements already in the container at positions 0, 1, and 2 respectively, adding a fourth element places it at position 3.

      Parameters:
      subject - The subject of the element to add.
    • removeElement

      void removeElement(String subject)

      Called to indicate that you should remove the element with the given subject from the container.

      Parameters:
      subject - The subject of the element to be to removed.
    • insertElement

      void insertElement(String subject, int position)

      Called to indicate that you should insert an element with the given subject at the given position within the container.

      Parameters:
      subject - The subject of the element to be inserted.
      position - The position at which to insert the element. The first element in a container is at position 0.
    • removeElementsWithPrefix

      void removeElementsWithPrefix(String prefix)

      Called to indicate that you should remove all elements from the container that have a subject that matches the specified prefix.

       

      Instructions should be processed in the order in which they are retrieved from the ContainerMessage and this affects earlier instructions. For example, assume that in the same message you received these operations:

       

      1. Add a container element with subject /A/1,
      2. Remove all container elements with prefix /A,
      3. Add a container element with subject /A/2.

      When this sequence has been processed, the container should only contain the element /A/2, because /A/1 was removed at step 2.

      Parameters:
      prefix - The prefix to match subjects for which elements are to be removed from the container.