Interface Base

    • Field Detail

      • PROPERTY_CHILD_COUNT

        static final java.lang.String PROPERTY_CHILD_COUNT
        The name of the property child count. To get the number of children, use the method getChildCount(). This constant is used in calls to firePropertyChange(). The class fires a property change then a child is added or removed.

        If children are removed, the field oldValue of the PropertyChange event must be a List<FemaleSocket> with the FemaleSockets that are removed from the list so that the listener can unregister itself as a listener of this female socket.

        If children are added, the field newValue of the PropertyChange event must be a List<FemaleSocket> with the FemaleSockets that are added to the list so that the listener can register itself as a listener of this female socket.

        See Also:
        Constant Field Values
      • PROPERTY_CHILD_REORDER

        static final java.lang.String PROPERTY_CHILD_REORDER
        The name of the property child reorder. The number of children has remained the same, but the order of children has changed.

        The field newValue of the PropertyChange event must be a List<FemaleSocket> with the FemaleSockets that are reordered so that the listener can update the tree.

        See Also:
        Constant Field Values
      • PROPERTY_SOCKET_CONNECTED

        static final java.lang.String PROPERTY_SOCKET_CONNECTED
        The socket has been connected. This constant is used in calls to firePropertyChange(). The socket fires a property change when it is connected or disconnected.
        See Also:
        Constant Field Values
      • PROPERTY_SOCKET_DISCONNECTED

        static final java.lang.String PROPERTY_SOCKET_DISCONNECTED
        The socket has been disconnected. This constant is used in calls to firePropertyChange(). The socket fires a property change when it is connected or disconnected.
        See Also:
        Constant Field Values
    • Method Detail

      • getSystemName

        java.lang.String getSystemName()
        Get the system name.
        Returns:
        the system name
      • getDeepCopy

        Base getDeepCopy​(java.util.Map<java.lang.String,​java.lang.String> systemNames,
                         java.util.Map<java.lang.String,​java.lang.String> userNames)
                  throws JmriException
        Create a deep copy of myself and my children The item needs to try to lookup itself in both systemNames and userNames to see if the user has given a new system name and/or a new user name.If no new system name is given, an auto system name is used. If no user name is given, a null user name is used.
        Parameters:
        systemNames - a map of old and new system name
        userNames - a map of old system name and new user name
        Returns:
        a deep copy
        Throws:
        JmriException - in case of an error
      • deepCopyChildren

        Base deepCopyChildren​(Base original,
                              java.util.Map<java.lang.String,​java.lang.String> systemNames,
                              java.util.Map<java.lang.String,​java.lang.String> userNames)
                       throws JmriException
        Do a deep copy of children from the original to me.
        Parameters:
        original - the item to copy from
        systemNames - a map of old and new system name
        userNames - a map of old system name and new user name
        Returns:
        myself
        Throws:
        JmriException - in case of an error
      • setComment

        void setComment​(@CheckForNull
                        java.lang.String comment)
        Set associated comment text.

        Comments can be any valid text.

        Parameters:
        comment - the comment or null to remove an existing comment
      • getShortDescription

        default java.lang.String getShortDescription()
        Get a short description of this item.
        Returns:
        a short description
      • getLongDescription

        default java.lang.String getLongDescription()
        Get a long description of this item.
        Returns:
        a long description
      • getShortDescription

        java.lang.String getShortDescription​(java.util.Locale locale)
        Get a short description of this item.
        Parameters:
        locale - The locale to be used
        Returns:
        a short description
      • getLongDescription

        java.lang.String getLongDescription​(java.util.Locale locale)
        Get a long description of this item.
        Parameters:
        locale - The locale to be used
        Returns:
        a long description
      • getLogixNG

        LogixNG getLogixNG()
        Get the LogixNG of this item.
        Returns:
        the LogixNG that owns this item
      • getRoot

        Base getRoot()
        Get the root of the tree that this item belongs to.
        Returns:
        the top most item in the tree
      • getParent

        Base getParent()
        Get the parent.

        The following rules apply

        • LogixNGs has no parent. The method throws an UnsupportedOperationException if called.
        • Expressions and actions has the male socket that they are connected to as their parent.
        • Male sockets has the female socket that they are connected to as their parent.
        • The parent of a female sockets is the LogixNG, expression or action that has this female socket.
        • The parent of a male sockets is the same parent as the expression or action that it contains.
        Returns:
        the parent of this object
      • setParent

        void setParent​(Base parent)
        Set the parent.

        The following rules apply

        • ExecutionGroups has no parent. The method throws an UnsupportedOperationException if called.
        • LogixNGs has the execution group as its parent.
        • Expressions and actions has the male socket that they are connected to as their parent.
        • Male sockets has the female socket that they are connected to as their parent.
        • The parent of a female sockets is the LogixNG, expression or action that has this female socket.
        • The parent of a male sockets is the same parent as the expression or action that it contains.
        Parameters:
        parent - the new parent of this object
      • setParentForAllChildren

        boolean setParentForAllChildren​(java.util.List<java.lang.String> errors)
        Set the parent for all the children.
        Parameters:
        errors - a list of potential errors
        Returns:
        true if success, false otherwise
      • getChild

        FemaleSocket getChild​(int index)
                       throws java.lang.IllegalArgumentException,
                              java.lang.UnsupportedOperationException
        Get a child of this item
        Parameters:
        index - the index of the child to get
        Returns:
        the child
        Throws:
        java.lang.IllegalArgumentException - if the index is less than 0 or greater or equal with the value returned by getChildCount()
        java.lang.UnsupportedOperationException
      • getChildCount

        int getChildCount()
        Get the number of children.
        Returns:
        the number of children
      • isSocketOperationAllowed

        default boolean isSocketOperationAllowed​(int index,
                                                 FemaleSocketOperation oper)
        Is the operation allowed on this child?
        Parameters:
        index - the index of the child to do the operation on
        oper - the operation to do
        Returns:
        true if operation is allowed, false otherwise
      • doSocketOperation

        default void doSocketOperation​(int index,
                                       FemaleSocketOperation oper)
        Do an operation on a child
        Parameters:
        index - the index of the child to do the operation on
        oper - the operation to do
      • isActive

        boolean isActive()
        Is this item active? If this item is enabled and all the parents are enabled, this item is active.
        Returns:
        true if active, false otherwise.
      • setup

        void setup()
        Setup this object and its children. This method is used to lookup system names for child sockets, turnouts, sensors, and so on.
      • dispose

        void dispose()
        Deactivate this object, so that it releases as many resources as possible and no longer effects others.

        For example, if this object has listeners, after a call to this method it should no longer notify those listeners. Any native or system-wide resources it maintains should be released, including threads, files, etc.

        It is an error to invoke any other methods on this object once dispose() has been called. Note, however, that there is no guarantee about behavior in that case.

        Afterwards, references to this object may still exist elsewhere, preventing its garbage collection. But it's formally dead, and shouldn't be keeping any other objects alive. Therefore, this method should null out any references to other objects that this object contained.

      • isEnabled

        default boolean isEnabled()
        Determines whether this object is enabled.
        Returns:
        true if the object is enabled, false otherwise
      • registerListeners

        void registerListeners()
        Register listeners if this object needs that.

        Important: This method may be called more than once. Methods overriding this method must ensure that listeners are not registered more than once.

      • unregisterListeners

        void unregisterListeners()
        Unregister listeners if this object needs that.

        Important: This method may be called more than once. Methods overriding this method must ensure that listeners are not unregistered more than once.

      • printTree

        default void printTree​(java.io.PrintWriter writer,
                               java.lang.String indent,
                               MutableInt lineNumber)
        Print the tree to a stream.
        Parameters:
        writer - the stream to print the tree to
        indent - the indentation of each level
        lineNumber - the line number
      • printTree

        void printTree​(Base.PrintTreeSettings settings,
                       java.io.PrintWriter writer,
                       java.lang.String indent,
                       MutableInt lineNumber)
        Print the tree to a stream.
        Parameters:
        settings - settings for what to print
        writer - the stream to print the tree to
        indent - the indentation of each level
        lineNumber - the line number
      • printTree

        default void printTree​(java.util.Locale locale,
                               java.io.PrintWriter writer,
                               java.lang.String indent,
                               MutableInt lineNumber)
        Print the tree to a stream.
        Parameters:
        locale - The locale to be used
        writer - the stream to print the tree to
        indent - the indentation of each level
        lineNumber - the line number
      • printTree

        void printTree​(Base.PrintTreeSettings settings,
                       java.util.Locale locale,
                       java.io.PrintWriter writer,
                       java.lang.String indent,
                       MutableInt lineNumber)
        Print the tree to a stream.
        Parameters:
        settings - settings for what to print
        locale - The locale to be used
        writer - the stream to print the tree to
        indent - the indentation of each level
        lineNumber - the line number
      • printTree

        void printTree​(Base.PrintTreeSettings settings,
                       java.util.Locale locale,
                       java.io.PrintWriter writer,
                       java.lang.String indent,
                       java.lang.String currentIndent,
                       MutableInt lineNumber)
        Print the tree to a stream.
        Parameters:
        settings - settings for what to print
        locale - The locale to be used
        writer - the stream to print the tree to
        indent - the indentation of each level
        currentIndent - the current indentation
        lineNumber - the line number
      • getUsageTree

        void getUsageTree​(int level,
                          NamedBean bean,
                          java.util.List<NamedBeanUsageReport> report,
                          NamedBean cdl)
        Navigate the LogixNG tree.
        Parameters:
        level - The current recursion level for debugging.
        bean - The named bean that is the object of the search.
        report - A list of NamedBeanUsageReport usage reports.
        cdl - The current ConditionalNG bean. Null for Module searches since there is no conditional
      • getUsageDetail

        void getUsageDetail​(int level,
                            NamedBean bean,
                            java.util.List<NamedBeanUsageReport> report,
                            NamedBean cdl)
        Add a new NamedBeanUsageReport to the report list if there are any matches in this action or expresssion.

        NamedBeanUsageReport Usage keys:

        • LogixNGAction
        • LogixNGExpression
        Parameters:
        level - The current recursion level for debugging.
        bean - The named bean that is the object of the search.
        report - A list of NamedBeanUsageReport usage reports.
        cdl - The current ConditionalNG bean. Null for Module searches since there is no conditional
      • addPropertyChangeListener

        void addPropertyChangeListener​(@Nonnull
                                       java.beans.PropertyChangeListener listener,
                                       java.lang.String name,
                                       java.lang.String listenerRef)
        Request a call-back when a bound property changes. Bound properties are the known state, commanded state, user and system names.
        Parameters:
        listener - The listener. This may change in the future to be a subclass of NamedProprtyChangeListener that carries the name and listenerRef values internally
        name - The name (either system or user) that the listener uses for this namedBean, this parameter is used to help determine when which listeners should be moved when the username is moved from one bean to another
        listenerRef - A textual reference for the listener, that can be presented to the user when a delete is called
      • addPropertyChangeListener

        void addPropertyChangeListener​(@Nonnull
                                       java.lang.String propertyName,
                                       @Nonnull
                                       java.beans.PropertyChangeListener listener,
                                       java.lang.String name,
                                       java.lang.String listenerRef)
        Request a call-back when a bound property changes. Bound properties are the known state, commanded state, user and system names.
        Parameters:
        propertyName - The name of the property to listen to
        listener - The listener. This may change in the future to be a subclass of NamedProprtyChangeListener that carries the name and listenerRef values internally
        name - The name (either system or user) that the listener uses for this namedBean, this parameter is used to help determine when which listeners should be moved when the username is moved from one bean to another
        listenerRef - A textual reference for the listener, that can be presented to the user when a delete is called
      • vetoableChange

        void vetoableChange​(@Nonnull
                            java.beans.PropertyChangeEvent evt)
                     throws java.beans.PropertyVetoException
        Throws:
        java.beans.PropertyVetoException
      • getListenerRef

        @CheckReturnValue
        java.lang.String getListenerRef​(@Nonnull
                                        java.beans.PropertyChangeListener l)
        Get the textual reference for the specific listener
        Parameters:
        l - the listener of interest
        Returns:
        the textual reference
      • getListenerRefs

        @CheckReturnValue
        java.util.ArrayList<java.lang.String> getListenerRefs()
        Returns a list of all the listeners references
        Returns:
        a list of textual references
      • getListenerRefsIncludingChildren

        @CheckReturnValue
        void getListenerRefsIncludingChildren​(java.util.List<java.lang.String> list)
        Returns a list of all the listeners references for this object and all its children.
        Parameters:
        list - a list of textual references
      • getPropertyChangeListenersByReference

        @CheckReturnValue
        @Nonnull
        java.beans.PropertyChangeListener[] getPropertyChangeListenersByReference​(@Nonnull
                                                                                  java.lang.String name)
        Get a list of all the property change listeners that are registered using a specific name
        Parameters:
        name - The name (either system or user) that the listener has registered as referencing this namedBean
        Returns:
        empty list if none
      • forEntireTree

        default void forEntireTree​(Base.RunnableWithBase r)
        Do something on every item in the sub tree of this item.
        Parameters:
        r - the action to do on all items.