Interface EventContextInterface

All Superinterfaces:
ContextInterface, org.djutils.event.EventProducer
All Known Subinterfaces:
EventContext
All Known Implementing Classes:
InitialEventContext

public interface EventContextInterface extends ContextInterface
EventContextInterface specifies the subscription methods for a part of the context tree. The ContextScope in each method indicates for which part of the tree notifications will be triggered. The listeners will be subscribed to three events for the part of the context: OBJECT_ADDED_EVENT, OBJECT_REMOVED_EVENT and OBJECT_CHANGED_EVENT.

Copyright (c) 2020-2025 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information DSOL Manual. The DSOL project is distributed under a three-clause BSD-style license, which can be found at DSOL License.

Author:
Alexander Verbraeck
  • Method Details

    • addListener

      boolean addListener(org.djutils.event.EventListener listener, String absolutePath, ContextScope contextScope) throws NameNotFoundException, InvalidNameException, NotContextException, NamingException, NullPointerException
      Add a listener for the provided scope as strong reference to the BEGINNING of a queue of listeners.
      Parameters:
      listener - the listener which is interested at events of eventType.
      absolutePath - the absolute path of the context or object to subscribe to
      contextScope - the part of the tree that the listener is aimed at (current node, current node and keys, subtree).
      Returns:
      the success of adding the listener. If a listener was already added false is returned.
      Throws:
      NameNotFoundException - when the absolutePath could not be found in the parent context, or when an intermediate context does not exist
      InvalidNameException - when the scope is OBJECT_SCOPE, but the key points to a (sub)context
      NotContextException - when the scope is LEVEL_SCOPE, OBJECT_LEVEL_SCOPE or SUBTREE_SCOPE, and the key points to an ordinary object
      NamingException - as an overarching exception for context errors
      NullPointerException - when one of the arguments is null
    • addListener

      boolean addListener(org.djutils.event.EventListener listener, String absolutePath, ContextScope contextScope, org.djutils.event.reference.ReferenceType referenceType) throws NameNotFoundException, InvalidNameException, NotContextException, NamingException, NullPointerException
      Add a listener for the provided scope to the BEGINNING of a queue of listeners.
      Parameters:
      listener - the listener which is interested at events of eventType.
      absolutePath - the absolute path of the context or object to subscribe to
      contextScope - the part of the tree that the listener is aimed at (current node, current node and keys, subtree).
      referenceType - whether the listener is added as a strong or as a weak reference.
      Returns:
      the success of adding the listener. If a listener was already added false is returned.
      Throws:
      NameNotFoundException - when the absolutePath could not be found in the parent context, or when an intermediate context does not exist
      InvalidNameException - when the scope is OBJECT_SCOPE, but the key points to a (sub)context
      NotContextException - when the scope is LEVEL_SCOPE, OBJECT_LEVEL_SCOPE or SUBTREE_SCOPE, and the key points to an ordinary object
      NamingException - as an overarching exception for context errors
      NullPointerException - when one of the arguments is null
    • addListener

      boolean addListener(org.djutils.event.EventListener listener, String absolutePath, ContextScope contextScope, int position) throws NameNotFoundException, InvalidNameException, NotContextException, NamingException, NullPointerException
      Add a listener for the provided scope as strong reference to the specified position of a queue of listeners.
      Parameters:
      listener - the listener which is interested at events of eventType.
      absolutePath - the absolute path of the context or object to subscribe to
      contextScope - the part of the tree that the listener is aimed at (current node, current node and keys, subtree).
      position - the position of the listener in the queue.
      Returns:
      the success of adding the listener. If a listener was already added, or an illegal position is provided false is returned.
      Throws:
      NameNotFoundException - when the absolutePath could not be found in the parent context, or when an intermediate context does not exist
      InvalidNameException - when the scope is OBJECT_SCOPE, but the key points to a (sub)context
      NotContextException - when the scope is LEVEL_SCOPE, OBJECT_LEVEL_SCOPE or SUBTREE_SCOPE, and the key points to an ordinary object
      NamingException - as an overarching exception for context errors
      NullPointerException - when one of the arguments is null
    • addListener

      boolean addListener(org.djutils.event.EventListener listener, String absolutePath, ContextScope contextScope, int position, org.djutils.event.reference.ReferenceType referenceType) throws NameNotFoundException, InvalidNameException, NotContextException, NamingException, NullPointerException
      Add a listener for the provided scope to the specified position of a queue of listeners.
      Parameters:
      listener - which is interested at certain events,
      absolutePath - the absolute path of the context or object to subscribe to
      contextScope - the part of the tree that the listener is aimed at (current node, current node and keys, subtree).
      position - the position of the listener in the queue
      referenceType - whether the listener is added as a strong or as a weak reference.
      Returns:
      the success of adding the listener. If a listener was already added or an illegal position is provided false is returned.
      Throws:
      NameNotFoundException - when the absolutePath could not be found in the parent context, or when an intermediate context does not exist
      InvalidNameException - when the scope is OBJECT_SCOPE, but the key points to a (sub)context
      NotContextException - when the scope is LEVEL_SCOPE, OBJECT_LEVEL_SCOPE or SUBTREE_SCOPE, and the key points to an ordinary object
      NamingException - as an overarching exception for context errors
      NullPointerException - when one of the arguments is null
    • removeListener

      boolean removeListener(org.djutils.event.EventListener listener, String absolutePath, ContextScope contextScope) throws InvalidNameException, NullPointerException
      Remove the subscription of a listener for the provided scope for a specific event.
      Parameters:
      listener - which is no longer interested.
      absolutePath - the absolute path of the context or object to subscribe to
      contextScope - ContextScope;the scope which is of no interest any more.
      Returns:
      the success of removing the listener. If a listener was not subscribed false is returned.
      Throws:
      InvalidNameException - when the path does not start with a slash
      NullPointerException - when one of the arguments is null