Class CodeComponent<D extends CodeDelegate>

java.lang.Object
org.praxislive.code.CodeComponent<D>
Type Parameters:
D - wrapped delegate type
All Implemented Interfaces:
Component
Direct Known Subclasses:
CodeContainer, CodeRoot

public class CodeComponent<D extends CodeDelegate> extends Object implements Component
A CodeComponent is a Component instance that is rewritable at runtime. The CodeComponent itself remains constant, but passes most responsibility to a CodeContext wrapping a CodeDelegate (user code). This component handles switching from one context to the next. A CodeComponent cannot be created directly - see CodeFactory.
  • Method Details

    • getParent

      public final Container getParent()
      Description copied from interface: Component
      Return the Container that is the immediate parent of this Component, or null if this Component is not currently contained within a Component hierarchy.
      Specified by:
      getParent in interface Component
      Returns:
      Container
    • parentNotify

      public void parentNotify(Container parent) throws VetoException
      Description copied from interface: Component
      Notify the Component that it has been added to the supplied Container, or removed from its parent if the supplied argument is null. The Component may throw a VetoException if it should not be added to the Container provided. It should also throw this exception if a parent is already set.
      Specified by:
      parentNotify in interface Component
      Parameters:
      parent -
      Throws:
      VetoException
    • 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
    • getControl

      public Control getControl(String id)
      Description copied from interface: Component
      Get a Control that can handle a Call to the given ID, or null if it does not exist. Component implementations are free to return a different Control for each ID, a single control to handle any message, or somewhere in between. A null return from this method shall be handled by the Root component by responding with an error message to the sender where required.
      Specified by:
      getControl in interface Component
      Parameters:
      id -
      Returns:
      Control or null
    • getPort

      public Port getPort(String id)
      Description copied from interface: Component
      Get the Port with the given ID, or null if it does not exist.
      Specified by:
      getPort in interface Component
      Parameters:
      id -
      Returns:
      Port or null
    • getInfo

      public ComponentInfo getInfo()
      Description copied from interface: Component
      Get the ComponentInfo object for this component.
      Specified by:
      getInfo in interface Component
      Returns:
      ComponentInfo
    • 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
      Parameters:
      writer - TreeWriter to write to