Class AbstractFemaleSocket

java.lang.Object
jmri.jmrit.logixng.implementation.AbstractFemaleSocket
All Implemented Interfaces:
PropertyChangeProvider, Base, FemaleSocket
Direct Known Subclasses:
DefaultFemaleAnalogActionSocket, DefaultFemaleAnalogExpressionSocket, DefaultFemaleAnySocket, DefaultFemaleDigitalActionSocket, DefaultFemaleDigitalBooleanActionSocket, DefaultFemaleDigitalExpressionSocket, DefaultFemaleGenericExpressionSocket, DefaultFemaleStringActionSocket, DefaultFemaleStringExpressionSocket

public abstract class AbstractFemaleSocket extends Object implements FemaleSocket
Abstract female socket.
  • Field Details

  • Constructor Details

  • Method Details

    • setEnableListeners

      public void setEnableListeners(boolean enable)
      Sets whenever listeners are enabled or not. ConditionalNG has always listeners enabled, but Clipboard and Module has never listeners enabled.
      Specified by:
      setEnableListeners in interface FemaleSocket
      Parameters:
      enable - true if listeners should be enabled, false otherwise
    • getEnableListeners

      public boolean getEnableListeners()
      Gets whenever listeners are enabled or not. ConditionalNG has always listeners enabled, but Clipboard and Module has never listeners enabled.
      Specified by:
      getEnableListeners in interface FemaleSocket
      Returns:
      true if listeners should be enabled, false otherwise
    • getParent

      public 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.
      Specified by:
      getParent in interface Base
      Returns:
      the parent of this object
    • setParent

      public void setParent(@Nonnull 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.
      Specified by:
      setParent in interface Base
      Parameters:
      parent - the new parent of this object
    • setParentForAllChildren

      public boolean setParentForAllChildren(List<String> errors)
      Set the parent for all the children.
      Specified by:
      setParentForAllChildren in interface Base
      Parameters:
      errors - a list of potential errors
      Returns:
      true if success, false otherwise
    • connect

      public void connect(MaleSocket socket) throws SocketAlreadyConnectedException
      Connect the male socket to this female socket.
      Specified by:
      connect in interface FemaleSocket
      Parameters:
      socket - the socket to connect
      Throws:
      SocketAlreadyConnectedException - if the socket is already connected
    • disconnect

      public void disconnect()
      Disconnect the current connected male socket from this female socket.
      Specified by:
      disconnect in interface FemaleSocket
    • getConnectedSocket

      Get the connected socket.
      Specified by:
      getConnectedSocket in interface FemaleSocket
      Returns:
      the male socket or null if not connected
    • isConnected

      public boolean isConnected()
      Is a male socket connected to this female socket?
      Specified by:
      isConnected in interface FemaleSocket
      Returns:
      true if connected
    • validateName

      public final boolean validateName(String name, boolean ignoreDuplicateErrors)
      Validates a name for a FemaleSocket.

      The name must have at least one character and only alphanumeric characters. The first character must not be a digit.

      Specified by:
      validateName in interface FemaleSocket
      Parameters:
      name - the name
      ignoreDuplicateErrors - true if duplicate names should be ignored, false otherwise
      Returns:
      true if the name is valid, false otherwise
    • setName

      public void setName(String name, boolean ignoreDuplicateErrors)
      Set the name of this socket.

      The name must have at least one character and only alphanumeric characters. The first character must not be a digit.

      Specified by:
      setName in interface FemaleSocket
      Parameters:
      name - the name
      ignoreDuplicateErrors - true if duplicate names should be ignored, false otherwise
    • getName

      public String getName()
      Get the name of this socket.
      Specified by:
      getName in interface FemaleSocket
      Returns:
      the name
    • disposeMe

      public abstract void disposeMe()
    • dispose

      public final 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.

      Specified by:
      dispose in interface Base
    • registerListenersForThisClass

      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.

    • unregisterListenersForThisClass

      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.

    • registerListeners

      public void registerListeners()
      Register listeners if this object needs that.
      Specified by:
      registerListeners in interface Base
    • unregisterListeners

      public void unregisterListeners()
      Register listeners if this object needs that.
      Specified by:
      unregisterListeners in interface Base
    • isActive

      public final boolean isActive()
      Is this item active? If this item is enabled and all the parents are enabled, this item is active.
      Specified by:
      isActive in interface Base
      Returns:
      true if active, false otherwise.
    • getCategory

      Get the category.
      Specified by:
      getCategory in interface Base
      Returns:
      the category
    • getChild

      public FemaleSocket getChild(int index)
      Get a child of this item
      Specified by:
      getChild in interface Base
      Parameters:
      index - the index of the child to get
      Returns:
      the child
    • getChildCount

      public int getChildCount()
      Get the number of children.
      Specified by:
      getChildCount in interface Base
      Returns:
      the number of children
    • getUserName

      public String getUserName()
      Get the user name.
      Specified by:
      getUserName in interface Base
      Returns:
      the user name
    • setUserName

      Get the user name.
      Specified by:
      setUserName in interface Base
      Parameters:
      s - the new user name
      Throws:
      NamedBean.BadUserNameException - when needed
    • getComment

      public String getComment()
      Get associated comment text. A LogixNG comment can have multiple lines, separated with \n.
      Specified by:
      getComment in interface Base
      Returns:
      the comment or null
    • setComment

      public void setComment(String s)
      Set associated comment text.

      Comments can be any valid text.

      Specified by:
      setComment in interface Base
      Parameters:
      s - the comment or null to remove an existing comment
    • getSystemName

      Get the system name.
      Specified by:
      getSystemName in interface Base
      Returns:
      the system name
    • getConditionalNG

      Get the ConditionalNG of this item.
      Specified by:
      getConditionalNG in interface Base
      Returns:
      the ConditionalNG that owns this item
    • getLogixNG

      public final LogixNG getLogixNG()
      Get the LogixNG of this item.
      Specified by:
      getLogixNG in interface Base
      Returns:
      the LogixNG that owns this item
    • getRoot

      public final Base getRoot()
      Get the root of the tree that this item belongs to.
      Specified by:
      getRoot in interface Base
      Returns:
      the top most item in the tree
    • printTreeRow

      protected void printTreeRow(Base.PrintTreeSettings settings, Locale locale, PrintWriter writer, String currentIndent, MutableInt lineNumber)
    • printTree

      public void printTree(Base.PrintTreeSettings settings, PrintWriter writer, String indent, MutableInt lineNumber)
      Print the tree to a stream.
      Specified by:
      printTree in interface Base
      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

      public void printTree(Base.PrintTreeSettings settings, Locale locale, PrintWriter writer, String indent, MutableInt lineNumber)
      Print the tree to a stream.
      Specified by:
      printTree in interface Base
      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

      public void printTree(Base.PrintTreeSettings settings, Locale locale, PrintWriter writer, String indent, String currentIndent, MutableInt lineNumber)
      Print the tree to a stream.
      Specified by:
      printTree in interface Base
      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

      public void getUsageTree(int level, NamedBean bean, List<NamedBeanUsageReport> report, NamedBean cdl)
      Navigate the LogixNG tree.
      Specified by:
      getUsageTree in interface Base
      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

      public void getUsageDetail(int level, NamedBean bean, 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
      Specified by:
      getUsageDetail in interface Base
      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

      Description copied from interface: PropertyChangeProvider
      Add a PropertyChangeListener to the listener list.
      Specified by:
      addPropertyChangeListener in interface PropertyChangeProvider
      Parameters:
      listener - The PropertyChangeListener to be added
    • addPropertyChangeListener

      public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
      Description copied from interface: PropertyChangeProvider
      Add a PropertyChangeListener for a specific property.
      Specified by:
      addPropertyChangeListener in interface PropertyChangeProvider
      Parameters:
      propertyName - The name of the property to listen on.
      listener - The PropertyChangeListener to be added
    • getPropertyChangeListeners

      Description copied from interface: PropertyChangeProvider
      Get all PropertyChangeListeners currently attached to this object.
      Specified by:
      getPropertyChangeListeners in interface PropertyChangeProvider
      Returns:
      An array of PropertyChangeListeners.
    • getPropertyChangeListeners

      Description copied from interface: PropertyChangeProvider
      Get all PropertyChangeListeners currently listening to changes to the specified property.
      Specified by:
      getPropertyChangeListeners in interface PropertyChangeProvider
      Parameters:
      propertyName - the name of the property of interest
      Returns:
      an array of PropertyChangeListeners
    • removePropertyChangeListener

      Description copied from interface: PropertyChangeProvider
      Remove the specified listener from this object.
      Specified by:
      removePropertyChangeListener in interface PropertyChangeProvider
      Parameters:
      listener - The PropertyChangeListener to remove.
    • removePropertyChangeListener

      public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
      Description copied from interface: PropertyChangeProvider
      Remove the specified listener of the specified property from this object.
      Specified by:
      removePropertyChangeListener in interface PropertyChangeProvider
      Parameters:
      propertyName - The name of the property to stop listening to.
      listener - The PropertyChangeListener to remove.
    • addPropertyChangeListener

      public void addPropertyChangeListener(PropertyChangeListener listener, String name, String listenerRef)
      Description copied from interface: Base
      Request a call-back when a bound property changes. Bound properties are the known state, commanded state, user and system names.
      Specified by:
      addPropertyChangeListener in interface Base
      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

      public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener, String name, String listenerRef)
      Description copied from interface: Base
      Request a call-back when a bound property changes. Bound properties are the known state, commanded state, user and system names.
      Specified by:
      addPropertyChangeListener in interface Base
      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
    • updateListenerRef

      public void updateListenerRef(PropertyChangeListener l, String newName)
      Specified by:
      updateListenerRef in interface Base
    • vetoableChange

      Specified by:
      vetoableChange in interface Base
      Throws:
      PropertyVetoException
    • getListenerRef

      Description copied from interface: Base
      Get the textual reference for the specific listener
      Specified by:
      getListenerRef in interface Base
      Parameters:
      l - the listener of interest
      Returns:
      the textual reference
    • getListenerRefs

      Description copied from interface: Base
      Returns a list of all the listeners references
      Specified by:
      getListenerRefs in interface Base
      Returns:
      a list of textual references
    • getNumPropertyChangeListeners

      Description copied from interface: Base
      Number of current listeners. May return -1 if the information is not available for some reason.
      Specified by:
      getNumPropertyChangeListeners in interface Base
      Returns:
      the number of listeners.
    • getPropertyChangeListenersByReference

      Description copied from interface: Base
      Get a list of all the property change listeners that are registered using a specific name
      Specified by:
      getPropertyChangeListenersByReference in interface Base
      Parameters:
      name - The name (either system or user) that the listener has registered as referencing this namedBean
      Returns:
      empty list if none
    • forEntireTree

      Do something on every item in the sub tree of this item.
      Specified by:
      forEntireTree in interface Base
      Parameters:
      r - the action to do on all items.
    • forEntireTreeWithException

      Do something on every item in the sub tree of this item.
      Specified by:
      forEntireTreeWithException in interface Base
      Parameters:
      r - the action to do on all items.
      Throws:
      Exception - if an exception occurs
    • getDeepCopy

      public Base getDeepCopy(Map<String,String> systemNames, Map<String,String> userNames)
      Description copied from interface: Base
      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.
      Specified by:
      getDeepCopy in interface Base
      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
    • deepCopyChildren

      public Base deepCopyChildren(Base original, Map<String,String> systemNames, Map<String,String> userNames) throws JmriException
      Description copied from interface: Base
      Do a deep copy of children from the original to me.
      Specified by:
      deepCopyChildren in interface Base
      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
    • getListenerRefsIncludingChildren

      Returns a list of all the listeners references for this object and all its children.
      Specified by:
      getListenerRefsIncludingChildren in interface Base
      Parameters:
      list - a list of textual references
    • hasChild

      public boolean hasChild(@Nonnull Base b)
      Description copied from interface: Base
      Does this item has the child b?
      Specified by:
      hasChild in interface Base
      Parameters:
      b - the child
      Returns:
      true if this item has the child b, false otherwise