Class DefaultMaleStringExpressionSocket
- java.lang.Object
-
- jmri.jmrit.logixng.implementation.AbstractMaleSocket
-
- jmri.jmrit.logixng.implementation.DefaultMaleStringExpressionSocket
-
- All Implemented Interfaces:
java.lang.Comparable<NamedBean>
,PropertyChangeProvider
,Base
,Debugable
,MaleSocket
,MaleStringExpressionSocket
,StringExpression
,StringExpressionBean
,NamedBean
public class DefaultMaleStringExpressionSocket extends AbstractMaleSocket implements MaleStringExpressionSocket
Every StringExpressionBean has an DefaultMaleStringExpressionSocket as its parent.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DefaultMaleStringExpressionSocket.StringExpressionDebugConfig
-
Nested classes/interfaces inherited from interface jmri.jmrit.logixng.Base
Base.PrintTreeSettings, Base.RunnableWithBase, Base.RunnableWithBaseThrowException
-
Nested classes/interfaces inherited from interface jmri.jmrit.logixng.Debugable
Debugable.DebugConfig
-
Nested classes/interfaces inherited from interface jmri.jmrit.logixng.MaleSocket
MaleSocket.ErrorHandlingType
-
Nested classes/interfaces inherited from interface jmri.NamedBean
NamedBean.BadNameException, NamedBean.BadSystemNameException, NamedBean.BadUserNameException, NamedBean.DisplayOptions, NamedBean.DuplicateSystemNameException
-
-
Field Summary
-
Fields inherited from class jmri.jmrit.logixng.implementation.AbstractMaleSocket
_localVariables
-
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
-
Fields inherited from interface jmri.NamedBean
DISPLAY_NAME_FORMAT, INCONSISTENT, PROPERTY_STATE, QUOTED_NAME_FORMAT, UNKNOWN
-
-
Constructor Summary
Constructors Constructor Description DefaultMaleStringExpressionSocket(BaseManager<? extends NamedBean> manager, StringExpressionBean stringExpression)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareSystemNameSuffix(java.lang.String suffix1, java.lang.String suffix2, NamedBean n2)
Compare the suffix of this NamedBean's name with the suffix of the argument NamedBean's name for theNamedBean.compareTo(jmri.NamedBean)
operation.Debugable.DebugConfig
createDebugConfig()
Create a debug configuration for this male socket.java.lang.String
describeState(int state)
Provide human-readable, localized version of state value.void
disposeMe()
Disposes this object.java.lang.String
evaluate()
Evaluate this expression.java.lang.String
getBeanType()
For instances in the code where we are dealing with just a bean and a message needs to be passed to the user or in a log.java.lang.String
getComment()
Get associated comment text.Debugable.DebugConfig
getDebugConfig()
Get the debug configuration for this male socket.java.lang.String
getDisplayName()
Get user name if it exists, otherwise return System name.java.lang.Object
getProperty(java.lang.String key)
Retrieve the value associated with a key.java.util.Set<java.lang.String>
getPropertyKeys()
Retrieve the complete current set of keys.int
getState()
Provide generic access to internal state.boolean
getTriggerOnChange()
Get whenether this expression should trigger the ConditionalNG if the named beans it listens to changes state.boolean
isEnabled()
Determines whether this male socket is enabled.void
registerListenersForThisClass()
Register listeners if this object needs that.void
removeProperty(java.lang.String key)
Remove the key/value pair against the NamedBean.void
setComment(java.lang.String comment)
Set associated comment text.void
setDebugConfig(Debugable.DebugConfig config)
Set the debug configuration for this male socket.void
setEnabled(boolean enable)
Set whenether this male socket is enabled or disabled.void
setEnabledFlag(boolean enable)
Set whenether this male socket is enabled or disabled, without activating the male socket.void
setProperty(java.lang.String key, java.lang.Object value)
Attach a key/value pair to the NamedBean, which can be retrieved later.void
setState(int s)
Provide generic access to internal state.void
setTriggerOnChange(boolean triggerOnChange)
Set whenether this expression should trigger the ConditionalNG if the named beans it listens to changes state.void
unregisterListenersForThisClass()
Register listeners if this object needs that.-
Methods inherited from class jmri.jmrit.logixng.implementation.AbstractMaleSocket
addLocalVariable, addLocalVariable, addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, clearLocalVariables, deepCopyChildren, dispose, getCatchAbortExecution, getCategory, getChild, getChildCount, getConditionalNG, getDeepCopy, getErrorHandlingType, getListen, getListenerRef, getListenerRefs, getListenerRefsIncludingChildren, getLocalVariables, getLogixNG, getLongDescription, getManager, getNumPropertyChangeListeners, getObject, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeListenersByReference, getRoot, getShortDescription, getSystemName, getUsageDetail, getUsageTree, getUserName, handleError, handleError, handleError, hasChild, isActive, isLocked, isSystem, printLocalVariable, printTree, printTree, printTree, printTreeRow, registerListeners, removePropertyChangeListener, removePropertyChangeListener, setCatchAbortExecution, setErrorHandlingType, setListen, setLocked, setParent, setParentForAllChildren, setSystem, setUserName, toString, unregisterListeners, updateListenerRef, vetoableChange
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jmri.jmrit.logixng.Base
addPropertyChangeListener, addPropertyChangeListener, deepCopyChildren, dispose, doSocketOperation, existsInTree, forEntireTree, forEntireTreeWithException, getCategory, getChild, getChildCount, getConditionalNG, getDeepCopy, getListenerRef, getListenerRefs, getListenerRefsIncludingChildren, getLogixNG, getLongDescription, getLongDescription, getModule, getNumPropertyChangeListeners, getParent, getPropertyChangeListenersByReference, getRoot, getShortDescription, getShortDescription, getSystemName, getUsageDetail, getUsageTree, getUserName, hasChild, isActive, isSocketOperationAllowed, printTree, printTree, printTree, printTree, printTree, registerListeners, setParent, setParentForAllChildren, setUserName, unregisterListeners, updateListenerRef, vetoableChange
-
Methods inherited from interface jmri.jmrit.logixng.MaleSocket
addLocalVariable, addLocalVariable, clearLocalVariables, find, getCatchAbortExecution, getErrorHandlingType, getListen, getLocalVariables, getManager, getObject, handleError, handleError, handleError, isLocked, isSupportingLocalVariables, isSystem, setCatchAbortExecution, setErrorHandlingType, setListen, setLocked, setSystem, setup
-
Methods inherited from interface jmri.NamedBean
addPropertyChangeListener, addPropertyChangeListener, compareTo, dispose, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getPropertyChangeListenersByReference, getSystemName, getUsageReport, getUserName, setUserName, toString, updateListenerRef, vetoableChange
-
Methods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
-
-
-
Constructor Detail
-
DefaultMaleStringExpressionSocket
public DefaultMaleStringExpressionSocket(@Nonnull BaseManager<? extends NamedBean> manager, @Nonnull StringExpressionBean stringExpression)
-
-
Method Detail
-
getTriggerOnChange
public boolean getTriggerOnChange()
Get whenether this expression should trigger the ConditionalNG if the named beans it listens to changes state.- Specified by:
getTriggerOnChange
in interfaceStringExpression
- Returns:
- true if trigger on change, false otherwise
-
setTriggerOnChange
public void setTriggerOnChange(boolean triggerOnChange)
Set whenether this expression should trigger the ConditionalNG if the named beans it listens to changes state.- Specified by:
setTriggerOnChange
in interfaceStringExpression
- Parameters:
triggerOnChange
- true if trigger on change, false otherwise
-
evaluate
public java.lang.String evaluate() throws JmriException
Evaluate this expression.This method must ensure that the value is not a Double.NaN, negative infinity or positive infinity. If that is the case, it must throw an IllegalArgumentException before checking if an error has occured.
- Specified by:
evaluate
in interfaceMaleStringExpressionSocket
- Specified by:
evaluate
in interfaceStringExpression
- Returns:
- the result of the evaluation
- Throws:
JmriException
- when an exception occurs
-
getState
public int getState()
Description copied from interface:NamedBean
Provide generic access to internal state.This generally shouldn't be used by Java code; use the class-specific form instead (e.g. getCommandedState in Turnout). This is provided to make scripts easier to read.
-
getDisplayName
public java.lang.String getDisplayName()
Description copied from interface:NamedBean
Get user name if it exists, otherwise return System name.- Specified by:
getDisplayName
in interfaceNamedBean
- Returns:
- the user name or system-specific name
-
disposeMe
public void disposeMe()
Description copied from class:AbstractMaleSocket
Disposes this object. This must remove _all_ connections!- Specified by:
disposeMe
in classAbstractMaleSocket
-
registerListenersForThisClass
public void registerListenersForThisClass()
Register listeners if this object needs that.- Specified by:
registerListenersForThisClass
in classAbstractMaleSocket
-
unregisterListenersForThisClass
public void unregisterListenersForThisClass()
Register listeners if this object needs that.- Specified by:
unregisterListenersForThisClass
in classAbstractMaleSocket
-
setState
public void setState(int s) throws JmriException
Description copied from interface:NamedBean
Provide generic access to internal state.This generally shouldn't be used by Java code; use the class-specific form instead (e.g. setCommandedState in Turnout). This is provided to make scripts access easier to read.
- Specified by:
setState
in interfaceNamedBean
- Parameters:
s
- the state- Throws:
JmriException
- general error when setting the state fails
-
describeState
public java.lang.String describeState(int state)
Description copied from interface:NamedBean
Provide human-readable, localized version of state value.This method is intended for use when presenting to a human operator.
- Specified by:
describeState
in interfaceNamedBean
- Parameters:
state
- the state to describe- Returns:
- the state in localized form
-
getComment
public java.lang.String getComment()
Description copied from interface:Base
Get associated comment text. A LogixNG comment can have multiple lines, separated with \n.- Specified by:
getComment
in interfaceBase
- Specified by:
getComment
in interfaceNamedBean
- Overrides:
getComment
in classAbstractMaleSocket
- Returns:
- the comment or null
-
setComment
public void setComment(java.lang.String comment)
Description copied from interface:Base
Set associated comment text.Comments can be any valid text.
- Specified by:
setComment
in interfaceBase
- Specified by:
setComment
in interfaceNamedBean
- Overrides:
setComment
in classAbstractMaleSocket
- Parameters:
comment
- the comment or null to remove an existing comment
-
setProperty
public void setProperty(java.lang.String key, java.lang.Object value)
Description copied from interface:NamedBean
Attach a key/value pair to the NamedBean, which can be retrieved later. These are not bound properties as yet, and don't throw events on modification. Key must not be null.Prior to JMRI 4.3, the key was of Object type. It was constrained to String to make these more like normal Java Beans.
- Specified by:
setProperty
in interfaceNamedBean
- Parameters:
key
- the property to setvalue
- the value of the property
-
getProperty
public java.lang.Object getProperty(java.lang.String key)
Description copied from interface:NamedBean
Retrieve the value associated with a key. If no value has been set for that key, returns null.- Specified by:
getProperty
in interfaceNamedBean
- Parameters:
key
- the property to get- Returns:
- The value of the property or null.
-
removeProperty
public void removeProperty(java.lang.String key)
Description copied from interface:NamedBean
Remove the key/value pair against the NamedBean.- Specified by:
removeProperty
in interfaceNamedBean
- Parameters:
key
- the property to remove
-
getPropertyKeys
public java.util.Set<java.lang.String> getPropertyKeys()
Description copied from interface:NamedBean
Retrieve the complete current set of keys.- Specified by:
getPropertyKeys
in interfaceNamedBean
- Returns:
- empty set if none
-
getBeanType
public java.lang.String getBeanType()
Description copied from interface:NamedBean
For instances in the code where we are dealing with just a bean and a message needs to be passed to the user or in a log.- Specified by:
getBeanType
in interfaceNamedBean
- Returns:
- a string of the bean type, eg Turnout, Sensor etc
-
compareSystemNameSuffix
public int compareSystemNameSuffix(java.lang.String suffix1, java.lang.String suffix2, NamedBean n2)
Description copied from interface:NamedBean
Compare the suffix of this NamedBean's name with the suffix of the argument NamedBean's name for theNamedBean.compareTo(jmri.NamedBean)
operation. This is intended to be a system-specific comparison that understands the various formats, etc.- Specified by:
compareSystemNameSuffix
in interfaceNamedBean
- Parameters:
suffix1
- The suffix for the 1st bean in the comparisonsuffix2
- The suffix for the 2nd bean in the comparisonn2
- The other (second) NamedBean in the comparison- Returns:
- -1,0,+1 for ordering if the names are well-formed; may not provide proper ordering if the names are not well-formed.
-
setDebugConfig
public void setDebugConfig(Debugable.DebugConfig config)
Set the debug configuration for this male socket.Each implementation of MaleSocket has their own implementation of DebugConfig. Use reflection to get the proper class <package-name>.debug.<ClassName>Debug that returns a JPanel that can configure debugging for this male socket.
- Specified by:
setDebugConfig
in interfaceDebugable
- Parameters:
config
- the new configuration or null to turn off debugging
-
getDebugConfig
public Debugable.DebugConfig getDebugConfig()
Get the debug configuration for this male socket.- Specified by:
getDebugConfig
in interfaceDebugable
- Returns:
- the configuration or null if debugging is turned off for this male socket
-
createDebugConfig
public Debugable.DebugConfig createDebugConfig()
Create a debug configuration for this male socket.- Specified by:
createDebugConfig
in interfaceDebugable
- Returns:
- the new configuration
-
setEnabled
public void setEnabled(boolean enable)
Set whenether this male socket is enabled or disabled.This method must call registerListeners() / unregisterListeners().
- Specified by:
setEnabled
in interfaceMaleSocket
- Parameters:
enable
- true if this male socket should be enabled, false otherwise
-
setEnabledFlag
public void setEnabledFlag(boolean enable)
Set whenether this male socket is enabled or disabled, without activating the male socket. This is used when loading the xml file and when copying an item.This method must call registerListeners() / unregisterListeners().
- Specified by:
setEnabledFlag
in interfaceMaleSocket
- Parameters:
enable
- true if this male socket should be enabled, false otherwise
-
isEnabled
public boolean isEnabled()
Determines whether this male socket is enabled.- Specified by:
isEnabled
in interfaceBase
- Specified by:
isEnabled
in interfaceMaleSocket
- Returns:
- true if the male socket is enabled, false otherwise
-
-