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 java.lang.Object implements FemaleSocket
Abstract female socket.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jmri.jmrit.logixng.Base
Base.PrintTreeSettings, Base.RunnableWithBase, Base.RunnableWithBaseThrowException
-
-
Field Summary
Fields Modifier and Type Field Description (package private) boolean_enableListenersprotected FemaleSocketListener_listener-
Fields inherited from interface jmri.jmrit.logixng.Base
PRINT_LINE_NUMBERS_FORMAT, PROPERTY_CHILD_COUNT, PROPERTY_CHILD_REORDER, PROPERTY_LAST_RESULT_CHANGED, PROPERTY_SOCKET_CONNECTED, PROPERTY_SOCKET_DISCONNECTED, SEPARATOR, SOCKET_CONNECTED, SOCKET_DISCONNECTED
-
-
Constructor Summary
Constructors Constructor Description AbstractFemaleSocket(Base parent, FemaleSocketListener listener, java.lang.String name)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddPropertyChangeListener(java.beans.PropertyChangeListener listener)Add aPropertyChangeListenerto the listener list.voidaddPropertyChangeListener(java.beans.PropertyChangeListener listener, java.lang.String name, java.lang.String listenerRef)Request a call-back when a bound property changes.voidaddPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)Add aPropertyChangeListenerfor a specific property.voidaddPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener, java.lang.String name, java.lang.String listenerRef)Request a call-back when a bound property changes.voidconnect(MaleSocket socket)Connect the male socket to this female socket.BasedeepCopyChildren(Base original, java.util.Map<java.lang.String,java.lang.String> systemNames, java.util.Map<java.lang.String,java.lang.String> userNames)Do a deep copy of children from the original to me.voiddisconnect()Disconnect the current connected male socket from this female socket.voiddispose()Deactivate this object, so that it releases as many resources as possible and no longer effects others.abstract voiddisposeMe()voidforEntireTree(Base.RunnableWithBase r)Do something on every item in the sub tree of this item.voidforEntireTreeWithException(Base.RunnableWithBaseThrowException r)Do something on every item in the sub tree of this item.CategorygetCategory()Get the category.FemaleSocketgetChild(int index)Get a child of this itemintgetChildCount()Get the number of children.java.lang.StringgetComment()Get associated comment text.ConditionalNGgetConditionalNG()Get the ConditionalNG of this item.MaleSocketgetConnectedSocket()Get the connected socket.BasegetDeepCopy(java.util.Map<java.lang.String,java.lang.String> systemNames, java.util.Map<java.lang.String,java.lang.String> userNames)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.booleangetEnableListeners()Gets whenever listeners are enabled or not.java.lang.StringgetListenerRef(java.beans.PropertyChangeListener l)Get the textual reference for the specific listenerjava.util.ArrayList<java.lang.String>getListenerRefs()Returns a list of all the listeners referencesvoidgetListenerRefsIncludingChildren(java.util.List<java.lang.String> list)Returns a list of all the listeners references for this object and all its children.LogixNGgetLogixNG()Get the LogixNG of this item.java.lang.StringgetName()Get the name of this socket.intgetNumPropertyChangeListeners()Number of current listeners.BasegetParent()Get the parent.java.beans.PropertyChangeListener[]getPropertyChangeListeners()Get allPropertyChangeListeners currently attached to this object.java.beans.PropertyChangeListener[]getPropertyChangeListeners(java.lang.String propertyName)Get allPropertyChangeListeners currently listening to changes to the specified property.java.beans.PropertyChangeListener[]getPropertyChangeListenersByReference(java.lang.String name)Get a list of all the property change listeners that are registered using a specific nameBasegetRoot()Get the root of the tree that this item belongs to.java.lang.StringgetSystemName()Get the system name.voidgetUsageDetail(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.voidgetUsageTree(int level, NamedBean bean, java.util.List<NamedBeanUsageReport> report, NamedBean cdl)Navigate the LogixNG tree.java.lang.StringgetUserName()Get the user name.booleanhasChild(Base b)Does this item has the child b?booleanisActive()Is this item active?booleanisConnected()Is a male socket connected to this female socket?voidprintTree(Base.PrintTreeSettings settings, java.io.PrintWriter writer, java.lang.String indent, MutableInt lineNumber)Print the tree to a stream.voidprintTree(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.voidprintTree(Base.PrintTreeSettings settings, java.util.Locale locale, java.io.PrintWriter writer, java.lang.String indent, MutableInt lineNumber)Print the tree to a stream.protected voidprintTreeRow(Base.PrintTreeSettings settings, java.util.Locale locale, java.io.PrintWriter writer, java.lang.String currentIndent, MutableInt lineNumber)voidregisterListeners()Register listeners if this object needs that.protected voidregisterListenersForThisClass()Register listeners if this object needs that.voidremovePropertyChangeListener(java.beans.PropertyChangeListener listener)Remove the specified listener from this object.voidremovePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)Remove the specified listener of the specified property from this object.voidsetComment(java.lang.String s)Set associated comment text.voidsetEnableListeners(boolean enable)Sets whenever listeners are enabled or not.voidsetName(java.lang.String name, boolean ignoreDuplicateErrors)Set the name of this socket.voidsetParent(Base parent)Set the parent.booleansetParentForAllChildren(java.util.List<java.lang.String> errors)Set the parent for all the children.voidsetUserName(java.lang.String s)Get the user name.voidunregisterListeners()Register listeners if this object needs that.protected voidunregisterListenersForThisClass()Unregister listeners if this object needs that.voidupdateListenerRef(java.beans.PropertyChangeListener l, java.lang.String newName)booleanvalidateName(java.lang.String name, boolean ignoreDuplicateErrors)Validates a name for a FemaleSocket.voidvetoableChange(java.beans.PropertyChangeEvent evt)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jmri.jmrit.logixng.Base
doSocketOperation, existsInTree, getLongDescription, getLongDescription, getModule, getShortDescription, getShortDescription, isEnabled, isSocketOperationAllowed, printTree, printTree
-
Methods inherited from interface jmri.jmrit.logixng.FemaleSocket
canDisconnect, doSocketOperation, getConnectableClasses, isAncestor, isCompatible, isSocketOperationAllowed, setName, setup, validateName
-
-
-
-
Field Detail
-
_listener
protected final FemaleSocketListener _listener
-
_enableListeners
boolean _enableListeners
-
-
Constructor Detail
-
AbstractFemaleSocket
public AbstractFemaleSocket(Base parent, FemaleSocketListener listener, java.lang.String name)
-
-
Method Detail
-
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:
setEnableListenersin interfaceFemaleSocket- 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:
getEnableListenersin interfaceFemaleSocket- 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.
-
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.
-
setParentForAllChildren
public boolean setParentForAllChildren(java.util.List<java.lang.String> errors)
Set the parent for all the children.- Specified by:
setParentForAllChildrenin interfaceBase- 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:
connectin interfaceFemaleSocket- 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:
disconnectin interfaceFemaleSocket
-
getConnectedSocket
public MaleSocket getConnectedSocket()
Get the connected socket.- Specified by:
getConnectedSocketin interfaceFemaleSocket- Returns:
- the male socket or null if not connected
-
isConnected
public boolean isConnected()
Is a male socket connected to this female socket?- Specified by:
isConnectedin interfaceFemaleSocket- Returns:
- true if connected
-
validateName
public final boolean validateName(java.lang.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:
validateNamein interfaceFemaleSocket- Parameters:
name- the nameignoreDuplicateErrors- true if duplicate names should be ignored, false otherwise- Returns:
- true if the name is valid, false otherwise
-
setName
public void setName(java.lang.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:
setNamein interfaceFemaleSocket- Parameters:
name- the nameignoreDuplicateErrors- true if duplicate names should be ignored, false otherwise
-
getName
public java.lang.String getName()
Get the name of this socket.- Specified by:
getNamein interfaceFemaleSocket- 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.
-
registerListenersForThisClass
protected void 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
protected void 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:
registerListenersin interfaceBase
-
unregisterListeners
public void unregisterListeners()
Register listeners if this object needs that.- Specified by:
unregisterListenersin interfaceBase
-
isActive
public final boolean isActive()
Is this item active? If this item is enabled and all the parents are enabled, this item is active.
-
getCategory
public Category getCategory()
Get the category.- Specified by:
getCategoryin interfaceBase- Returns:
- the category
-
getChild
public FemaleSocket getChild(int index)
Get a child of this item
-
getChildCount
public int getChildCount()
Get the number of children.- Specified by:
getChildCountin interfaceBase- Returns:
- the number of children
-
getUserName
public java.lang.String getUserName()
Get the user name.- Specified by:
getUserNamein interfaceBase- Returns:
- the user name
-
setUserName
public void setUserName(java.lang.String s) throws NamedBean.BadUserNameException
Get the user name.- Specified by:
setUserNamein interfaceBase- Parameters:
s- the new user name- Throws:
NamedBean.BadUserNameException- when needed
-
getComment
public java.lang.String getComment()
Get associated comment text. A LogixNG comment can have multiple lines, separated with \n.- Specified by:
getCommentin interfaceBase- Returns:
- the comment or null
-
setComment
public void setComment(java.lang.String s)
Set associated comment text.Comments can be any valid text.
- Specified by:
setCommentin interfaceBase- Parameters:
s- the comment or null to remove an existing comment
-
getSystemName
public java.lang.String getSystemName()
Get the system name.- Specified by:
getSystemNamein interfaceBase- Returns:
- the system name
-
getConditionalNG
public final ConditionalNG getConditionalNG()
Get the ConditionalNG of this item.- Specified by:
getConditionalNGin interfaceBase- Returns:
- the ConditionalNG that owns this item
-
getLogixNG
public final LogixNG getLogixNG()
Get the LogixNG of this item.- Specified by:
getLogixNGin interfaceBase- Returns:
- the LogixNG that owns this item
-
printTreeRow
protected void printTreeRow(Base.PrintTreeSettings settings, java.util.Locale locale, java.io.PrintWriter writer, java.lang.String currentIndent, MutableInt lineNumber)
-
printTree
public void printTree(Base.PrintTreeSettings settings, java.io.PrintWriter writer, java.lang.String indent, MutableInt lineNumber)
Print the tree to a stream.
-
printTree
public 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.
-
printTree
public 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.
-
getUsageTree
public void getUsageTree(int level, NamedBean bean, java.util.List<NamedBeanUsageReport> report, NamedBean cdl)
Navigate the LogixNG tree.- Specified by:
getUsageTreein interfaceBase- 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, 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
- Specified by:
getUsageDetailin interfaceBase- 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
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Description copied from interface:PropertyChangeProviderAdd aPropertyChangeListenerto the listener list.- Specified by:
addPropertyChangeListenerin interfacePropertyChangeProvider- Parameters:
listener- The PropertyChangeListener to be added
-
addPropertyChangeListener
public void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
Description copied from interface:PropertyChangeProviderAdd aPropertyChangeListenerfor a specific property.- Specified by:
addPropertyChangeListenerin interfacePropertyChangeProvider- Parameters:
propertyName- The name of the property to listen on.listener- The PropertyChangeListener to be added
-
getPropertyChangeListeners
public java.beans.PropertyChangeListener[] getPropertyChangeListeners()
Description copied from interface:PropertyChangeProviderGet allPropertyChangeListeners currently attached to this object.- Specified by:
getPropertyChangeListenersin interfacePropertyChangeProvider- Returns:
- An array of PropertyChangeListeners.
-
getPropertyChangeListeners
public java.beans.PropertyChangeListener[] getPropertyChangeListeners(java.lang.String propertyName)
Description copied from interface:PropertyChangeProviderGet allPropertyChangeListeners currently listening to changes to the specified property.- Specified by:
getPropertyChangeListenersin interfacePropertyChangeProvider- Parameters:
propertyName- the name of the property of interest- Returns:
- an array of PropertyChangeListeners
-
removePropertyChangeListener
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Description copied from interface:PropertyChangeProviderRemove the specified listener from this object.- Specified by:
removePropertyChangeListenerin interfacePropertyChangeProvider- Parameters:
listener- ThePropertyChangeListenerto remove.
-
removePropertyChangeListener
public void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
Description copied from interface:PropertyChangeProviderRemove the specified listener of the specified property from this object.- Specified by:
removePropertyChangeListenerin interfacePropertyChangeProvider- Parameters:
propertyName- The name of the property to stop listening to.listener- ThePropertyChangeListenerto remove.
-
addPropertyChangeListener
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener, java.lang.String name, java.lang.String listenerRef)
Description copied from interface:BaseRequest a call-back when a bound property changes. Bound properties are the known state, commanded state, user and system names.- Specified by:
addPropertyChangeListenerin interfaceBase- Parameters:
listener- The listener. This may change in the future to be a subclass of NamedProprtyChangeListener that carries the name and listenerRef values internallyname- 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 anotherlistenerRef- A textual reference for the listener, that can be presented to the user when a delete is called
-
addPropertyChangeListener
public void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener, java.lang.String name, java.lang.String listenerRef)
Description copied from interface:BaseRequest a call-back when a bound property changes. Bound properties are the known state, commanded state, user and system names.- Specified by:
addPropertyChangeListenerin interfaceBase- Parameters:
propertyName- The name of the property to listen tolistener- The listener. This may change in the future to be a subclass of NamedProprtyChangeListener that carries the name and listenerRef values internallyname- 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 anotherlistenerRef- A textual reference for the listener, that can be presented to the user when a delete is called
-
updateListenerRef
public void updateListenerRef(java.beans.PropertyChangeListener l, java.lang.String newName)
- Specified by:
updateListenerRefin interfaceBase
-
vetoableChange
public void vetoableChange(java.beans.PropertyChangeEvent evt) throws java.beans.PropertyVetoException
- Specified by:
vetoableChangein interfaceBase- Throws:
java.beans.PropertyVetoException
-
getListenerRef
public java.lang.String getListenerRef(java.beans.PropertyChangeListener l)
Description copied from interface:BaseGet the textual reference for the specific listener- Specified by:
getListenerRefin interfaceBase- Parameters:
l- the listener of interest- Returns:
- the textual reference
-
getListenerRefs
public java.util.ArrayList<java.lang.String> getListenerRefs()
Description copied from interface:BaseReturns a list of all the listeners references- Specified by:
getListenerRefsin interfaceBase- Returns:
- a list of textual references
-
getNumPropertyChangeListeners
public int getNumPropertyChangeListeners()
Description copied from interface:BaseNumber of current listeners. May return -1 if the information is not available for some reason.- Specified by:
getNumPropertyChangeListenersin interfaceBase- Returns:
- the number of listeners.
-
getPropertyChangeListenersByReference
public java.beans.PropertyChangeListener[] getPropertyChangeListenersByReference(java.lang.String name)
Description copied from interface:BaseGet a list of all the property change listeners that are registered using a specific name- Specified by:
getPropertyChangeListenersByReferencein interfaceBase- Parameters:
name- The name (either system or user) that the listener has registered as referencing this namedBean- Returns:
- empty list if none
-
forEntireTree
public void forEntireTree(Base.RunnableWithBase r)
Do something on every item in the sub tree of this item.- Specified by:
forEntireTreein interfaceBase- Parameters:
r- the action to do on all items.
-
forEntireTreeWithException
public void forEntireTreeWithException(Base.RunnableWithBaseThrowException r) throws java.lang.Exception
Do something on every item in the sub tree of this item.- Specified by:
forEntireTreeWithExceptionin interfaceBase- Parameters:
r- the action to do on all items.- Throws:
java.lang.Exception- if an exception occurs
-
getDeepCopy
public Base getDeepCopy(java.util.Map<java.lang.String,java.lang.String> systemNames, java.util.Map<java.lang.String,java.lang.String> userNames)
Description copied from interface:BaseCreate 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:
getDeepCopyin interfaceBase- Parameters:
systemNames- a map of old and new system nameuserNames- a map of old system name and new user name- Returns:
- a deep copy
-
deepCopyChildren
public 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
Description copied from interface:BaseDo a deep copy of children from the original to me.- Specified by:
deepCopyChildrenin interfaceBase- Parameters:
original- the item to copy fromsystemNames- a map of old and new system nameuserNames- a map of old system name and new user name- Returns:
- myself
- Throws:
JmriException- in case of an error
-
getListenerRefsIncludingChildren
public void getListenerRefsIncludingChildren(java.util.List<java.lang.String> list)
Returns a list of all the listeners references for this object and all its children.- Specified by:
getListenerRefsIncludingChildrenin interfaceBase- Parameters:
list- a list of textual references
-
-