Class AbstractContainer

java.lang.Object
org.praxislive.base.AbstractComponent
org.praxislive.base.AbstractContainer
All Implemented Interfaces:
Component, Container, Lookup.Provider
Direct Known Subclasses:
AbstractContainer.Delegate

public abstract class AbstractContainer extends AbstractComponent implements Container
Abstract base class for Container supporting all controls of ContainerProtocol.

Use the AbstractContainer.Delegate subclass to reuse the functionality here inside an alternative Container implementation (see eg. use in AbstractRootContainer ).

  • Constructor Details

    • AbstractContainer

      protected AbstractContainer()
  • Method Details

    • getChild

      public Component getChild(String id)
      Description copied from interface: Container
      Get child component with specific ID.
      Specified by:
      getChild in interface Container
      Parameters:
      id -
      Returns:
      Component, or null if no component with that ID exists.
    • children

      public Stream<String> children()
      Description copied from interface: Container
      Get a Stream of the child IDs that this container makes publicly visible. Containers may have hidden children that can be returned from Container.getChild(java.lang.String) but are not listed here. All IDs returned should correspond to valid components, and (if provided) match the implementation of ContainerProtocol.

      A Stream is returned allowing flexibility in implementation.

      Specified by:
      children in interface Container
      Returns:
      stream of public child IDs
    • getAddress

      public ComponentAddress getAddress(Component child)
      Description copied from interface: Container
      Get the address for the provided child component, or null if the component is not a child of this container.
      Specified by:
      getAddress in interface Container
      Parameters:
      child - component
      Returns:
      address, or null of component is not a child of this container.
    • getType

      public ComponentType getType(Component child)
      Description copied from interface: Container
      Get the ComponentType of the provided child. The default implementation looks for ComponentInfo.KEY_COMPONENT_TYPE in the child's info. Container's may override to provide a more efficient or suitable result.

      The default implementation does not check if the provided component is actually a child of this container.

      Specified by:
      getType in interface Container
      Parameters:
      child - child component
      Returns:
      component type, or null if unavailable
    • hierarchyChanged

      public void hierarchyChanged()
      Description copied from interface: Component
      Notify the component that a change has happened in its component hierarchy. For example its direct parent or an ancestor has changed. This method will be called after parentNotify() if the result of an immediate parent change.
      Specified by:
      hierarchyChanged in interface Component
      Overrides:
      hierarchyChanged in class AbstractComponent
    • getLookup

      public Lookup getLookup()
      Description copied from interface: Lookup.Provider
      Get the Lookup from this Provider.
      Specified by:
      getLookup in interface Lookup.Provider
      Overrides:
      getLookup in class AbstractComponent
      Returns:
      lookup
    • write

      public void write(TreeWriter writer)
      Description copied from interface: Component
      If supported, write the state of this component to the provided TreeWriter. This should allow for the component to be recreated in as close to its current state as possible.

      To fully support this method, the Component should write its type, component info, and property values, in that order. It may also add custom annotations.

      The component should delegate to Container.getType(org.praxislive.core.Component) to find its type rather than relying directly on ComponentInfo.KEY_COMPONENT_TYPE.

      The default implementation of this method does nothing.

      Specified by:
      write in interface Component
      Specified by:
      write in interface Container
      Overrides:
      write in class AbstractComponent
      Parameters:
      writer - TreeWriter to write to
    • writeChildren

      protected final void writeChildren(TreeWriter writer)
    • writeConnections

      protected final void writeConnections(TreeWriter writer)
    • addChild

      protected void addChild(String id, Component child) throws VetoException
      Throws:
      VetoException
    • recordChildType

      protected void recordChildType(Component child, ComponentType type)
    • notifyChild

      protected void notifyChild(Component child) throws VetoException
      Throws:
      VetoException
    • removeChild

      protected Component removeChild(String id)
    • getChildID

      protected String getChildID(Component child)
    • connect

      protected void connect(String component1, String port1, String component2, String port2) throws PortConnectionException
      Throws:
      PortConnectionException
    • disconnect

      protected void disconnect(String component1, String port1, String component2, String port2)