Class AbstractInteractiveUnit

All Implemented Interfaces:
IUnitCreator, IUserDataSupport, IAddressableUnit, IInteractiveUnit, IUnit, IEventSource

@Ser public abstract class AbstractInteractiveUnit extends AbstractUnit implements IInteractiveUnit
Skeleton of an interactive unit. Usage of this abstract class is encouraged. This unit provides a default metadata manager.

Implementors must implement their own constructor; the default constructor is used for deserialization only. Example of a typical interactive unit constructor:

 public DerivedClass(String name, IUnitProcessor unitProcessor, IUnitCreator parent,
         IPropertyDefinitionManager pdm) {
     super(..., name, unitProcessor, parent, pdm);
     ...
 }
 
  • Constructor Details

  • Method Details

    • getItemObject

      public Object getItemObject(long id)
      The skeleton implementation returns null.
      Specified by:
      getItemObject in interface IAddressableUnit
      Parameters:
      id - the item id
      Returns:
      an object, whose type is defined by contract, potentially null
    • getGlobalActions

      public List<Integer> getGlobalActions()
      The skeleton implementation returns an empty list.
      Specified by:
      getGlobalActions in interface IInteractiveUnit
      Returns:
      the list of actions
    • getItemActions

      public List<Integer> getItemActions(long id)
      The skeleton implementation returns an empty list.
      Specified by:
      getItemActions in interface IInteractiveUnit
      Parameters:
      id - the target item identifier
      Returns:
      the list of actions
    • isValidAddress

      public boolean isValidAddress(String address)
      The default implementation returns true IFF the address can be converted to a valid (non-zero) item id.
      Specified by:
      isValidAddress in interface IAddressableUnit
      Returns:
    • getAddressActions

      public List<Integer> getAddressActions(String address)
      The skeleton implementation returns an empty list.
      Specified by:
      getAddressActions in interface IInteractiveUnit
      Parameters:
      address - the target address
      Returns:
      the list of actions
      See Also:
    • getAddressOfItem

      public String getAddressOfItem(long id)
      The skeleton implementation returns null.
      Specified by:
      getAddressOfItem in interface IAddressableUnit
      Parameters:
      id - the item id
      Returns:
      an address best representing or matching the provided item, null otherwise
    • getRelatedItems

      public List<Long> getRelatedItems(long id)
      The skeleton implementation returns an empty list.
      Specified by:
      getRelatedItems in interface IAddressableUnit
      Parameters:
      id - an item id
      Returns:
      a list of related items (not containing the provided id), may be empty - never null
    • getItemAtAddress

      public long getItemAtAddress(String address)
      The skeleton implementation returns 0.
      Specified by:
      getItemAtAddress in interface IAddressableUnit
      Parameters:
      address - the address
      Returns:
      an item best representing or matching the provided address, 0 otherwise
    • canExecuteAction

      public boolean canExecuteAction(ActionContext actionContext)
      The skeleton implementation returns false.
      Specified by:
      canExecuteAction in interface IInteractiveUnit
      Parameters:
      actionContext - location context for the action
      Returns:
      true
    • prepareExecution

      public boolean prepareExecution(ActionContext actionContext, IActionData actionData)
      The skeleton implementation returns false.
      Specified by:
      prepareExecution in interface IInteractiveUnit
      Parameters:
      actionContext - location context for the action
      actionData - data for the action
      Returns:
      true if the preparation was successful, and the action may be executed. Upon successful preparation, actionData will contain plugin-set pre-execution data
    • executeAction

      public boolean executeAction(ActionContext actionContext, IActionData actionData)
      The skeleton implementation returns executeAction(actionContext, actionData, true).
      Specified by:
      executeAction in interface IInteractiveUnit
      Parameters:
      actionContext - location context for the action
      actionData - data for the action
      Returns:
      true if the execution was successful. Upon successful execution, actionData will contain plugin-set post-execution data
    • executeAction

      public boolean executeAction(ActionContext actionContext, IActionData actionData, boolean notify)
      The skeleton implementation returns false.
      Specified by:
      executeAction in interface IInteractiveUnit
      Parameters:
      actionContext - context for the action
      actionData - data for the action
      notify - true to notify clients if the action was successfully executed and the unit contents has changed
      Returns:
      action success indicator
    • getMetadataManager

      public IMetadataManager getMetadataManager()
      The skeleton implementation returns an empty metadata manager.
      Specified by:
      getMetadataManager in interface IInteractiveUnit
      Returns:
      the manager, null if none