Class AbstractBase
- java.lang.Object
-
- jmri.implementation.AbstractNamedBean
-
- jmri.jmrit.logixng.implementation.AbstractBase
-
- All Implemented Interfaces:
java.lang.Comparable<NamedBean>
,PropertyChangeProvider
,Base
,NamedBean
- Direct Known Subclasses:
AbstractAnalogAction
,AbstractAnalogExpression
,AbstractDigitalAction
,AbstractDigitalBooleanAction
,AbstractDigitalExpression
,AbstractStringAction
,AbstractStringExpression
,ClipboardMany
,DefaultClipboard
,DefaultConditionalNG
,DefaultModule
,NullBase
public abstract class AbstractBase extends AbstractNamedBean implements Base
The abstract class that is the base class for all LogixNG classes that implements the Base interface.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jmri.jmrit.logixng.Base
Base.PrintTreeSettings, Base.RunnableWithBase, Base.RunnableWithBaseThrowException
-
Nested classes/interfaces inherited from interface jmri.NamedBean
NamedBean.BadNameException, NamedBean.BadSystemNameException, NamedBean.BadUserNameException, NamedBean.DisplayOptions, NamedBean.DuplicateSystemNameException
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
_listenersAreRegistered
-
Fields inherited from class jmri.implementation.AbstractNamedBean
listenerRefs, mSystemName, register
-
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 AbstractBase(java.lang.String sys)
AbstractBase(java.lang.String sys, java.lang.String user)
AbstractBase(java.lang.String sys, java.lang.String user, Category category)
AbstractBase(java.lang.String sys, Category category)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
assertListenersAreNotRegistered(org.slf4j.Logger log, java.lang.String method)
int
compareSystemNameSuffix(java.lang.String suffix1, java.lang.String suffix2, NamedBean n)
Compare the suffix of this NamedBean's name with the suffix of the argument NamedBean's name for theNamedBean.compareTo(jmri.NamedBean)
operation.Base
deepCopyChildren(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.void
dispose()
Deactivate this object, so that it releases as many resources as possible and no longer effects others.protected void
disposeMe()
Dispose this class.Category
getCategory()
Get the category.FemaleSocket
getChild(int index)
Get a child of this itemint
getChildCount()
Get the number of children.ConditionalNG
getConditionalNG()
Get the ConditionalNG of this item.void
getListenerRefsIncludingChildren(java.util.List<java.lang.String> list)
Returns a list of all the listeners references for this object and all its children.LogixNG
getLogixNG()
Get the LogixNG of this item.Base
getRoot()
Get the root of the tree that this item belongs to.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.void
getUsageTree(int level, NamedBean bean, java.util.List<NamedBeanUsageReport> report, NamedBean cdl)
Navigate the LogixNG tree.boolean
isActive()
Is this item active?void
printTree(Base.PrintTreeSettings settings, java.io.PrintWriter writer, java.lang.String indent, MutableInt lineNumber)
Print the tree to a stream.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.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.protected void
printTreeRow(Base.PrintTreeSettings settings, java.util.Locale locale, java.io.PrintWriter writer, java.lang.String currentIndent, MutableInt lineNumber)
void
registerListeners()
Register listeners if this object needs that.protected void
registerListenersForThisClass()
Register listeners if this object needs that.boolean
setParentForAllChildren(java.util.List<java.lang.String> errors)
Set the parent for all the children.void
unregisterListeners()
Unregister listeners if this object needs that.protected void
unregisterListenersForThisClass()
Unregister listeners if this object needs that.-
Methods inherited from class jmri.implementation.AbstractNamedBean
addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, describeState, equals, firePropertyChange, getComment, getDisplayName, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeListenersByReference, getPropertyKeys, getSystemName, getUserName, hashCode, removeProperty, removePropertyChangeListener, removePropertyChangeListener, setComment, setProperty, setUserName, toString, toStringSuffix, updateListenerRef, vetoableChange
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jmri.jmrit.logixng.Base
addPropertyChangeListener, addPropertyChangeListener, doSocketOperation, existsInTree, forEntireTree, forEntireTreeWithException, getComment, getDeepCopy, getListenerRef, getListenerRefs, getLongDescription, getLongDescription, getModule, getNumPropertyChangeListeners, getParent, getPropertyChangeListenersByReference, getShortDescription, getShortDescription, getSystemName, getUserName, hasChild, isEnabled, isSocketOperationAllowed, printTree, printTree, setComment, setParent, setup, setUserName, updateListenerRef, vetoableChange
-
Methods inherited from interface jmri.NamedBean
compareTo, getBeanType, getRecommendedToolTip, getState, getUsageReport, setState
-
Methods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
-
-
-
Field Detail
-
_listenersAreRegistered
protected boolean _listenersAreRegistered
-
-
Constructor Detail
-
AbstractBase
public AbstractBase(java.lang.String sys) throws NamedBean.BadSystemNameException
- Throws:
NamedBean.BadSystemNameException
-
AbstractBase
public AbstractBase(java.lang.String sys, java.lang.String user) throws NamedBean.BadUserNameException, NamedBean.BadSystemNameException
-
AbstractBase
public AbstractBase(java.lang.String sys, Category category) throws NamedBean.BadSystemNameException
- Throws:
NamedBean.BadSystemNameException
-
AbstractBase
public AbstractBase(java.lang.String sys, java.lang.String user, Category category) throws NamedBean.BadUserNameException, NamedBean.BadSystemNameException
-
-
Method Detail
-
getCategory
public Category getCategory()
Get the category.- Specified by:
getCategory
in interfaceBase
- Returns:
- the category
-
getChild
public FemaleSocket getChild(int index) throws java.lang.IllegalArgumentException, java.lang.UnsupportedOperationException
Get a child of this item
-
getChildCount
public int getChildCount()
Get the number of children.- Specified by:
getChildCount
in interfaceBase
- Returns:
- the number of children
-
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
Do a deep copy of children from the original to me.- Specified by:
deepCopyChildren
in 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
-
getConditionalNG
public ConditionalNG getConditionalNG()
Get the ConditionalNG of this item.- Specified by:
getConditionalNG
in interfaceBase
- Returns:
- the ConditionalNG that owns this item
-
getLogixNG
public final LogixNG getLogixNG()
Get the LogixNG of this item.- Specified by:
getLogixNG
in interfaceBase
- Returns:
- the LogixNG that owns this item
-
setParentForAllChildren
public final boolean setParentForAllChildren(java.util.List<java.lang.String> errors)
Set the parent for all the children.- Specified by:
setParentForAllChildren
in interfaceBase
- Parameters:
errors
- a list of potential errors- Returns:
- true if success, false otherwise
-
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 final 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.
- Specified by:
registerListeners
in interfaceBase
-
unregisterListeners
public final 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.
- Specified by:
unregisterListeners
in 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.
-
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:
getUsageTree
in 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:
getUsageDetail
in 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
-
compareSystemNameSuffix
@CheckReturnValue public int compareSystemNameSuffix(@Nonnull java.lang.String suffix1, @Nonnull java.lang.String suffix2, @Nonnull NamedBean n)
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. By default, does an alphanumeric-by-chunks comparison. Do a string comparison.- Specified by:
compareSystemNameSuffix
in interfaceNamedBean
- Overrides:
compareSystemNameSuffix
in classAbstractNamedBean
- Parameters:
suffix1
- The suffix for the 1st bean in the comparisonsuffix2
- The suffix for the 2nd bean in the comparisonn
- 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.
-
disposeMe
protected void disposeMe()
Dispose this class. Listeners do not need to be unregistered by this method since they are unregistered by dispose().
-
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 NamedBean contained.
-
assertListenersAreNotRegistered
public void assertListenersAreNotRegistered(org.slf4j.Logger log, java.lang.String method)
-
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:
getListenerRefsIncludingChildren
in interfaceBase
- Parameters:
list
- a list of textual references
-
-