Package jmri.implementation
Class AbstractStringIO
- java.lang.Object
-
- jmri.implementation.AbstractNamedBean
-
- jmri.implementation.AbstractStringIO
-
- All Implemented Interfaces:
java.lang.Comparable<NamedBean>
,PropertyChangeProvider
,NamedBean
,StringIO
- Direct Known Subclasses:
LnThrottleStringIO
public abstract class AbstractStringIO extends AbstractNamedBean implements StringIO
Base implementation of the StringIO interface.
-
-
Nested Class Summary
-
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.implementation.AbstractNamedBean
listenerRefs, mSystemName, register
-
Fields inherited from interface jmri.NamedBean
DISPLAY_NAME_FORMAT, INCONSISTENT, PROPERTY_STATE, QUOTED_NAME_FORMAT, UNKNOWN
-
-
Constructor Summary
Constructors Constructor Description AbstractStringIO(java.lang.String systemName)
Abstract constructor for new StringIO with system nameAbstractStringIO(java.lang.String systemName, java.lang.String userName)
Abstract constructor for new StringIO with system name and user name
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description 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.protected abstract boolean
cutLongStrings()
Cut long strings instead of throwing an exception?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
getCommandedStringValue()
Query the commanded string.java.lang.String
getKnownStringValue()
Query the known string value.int
getState()
Provide generic access to internal state.protected abstract void
sendStringToLayout(java.lang.String value)
Sends the string to the layout.void
setCommandedStringValue(java.lang.String value)
Change the commanded value, which results in the relevant command(s) being sent to the hardware.void
setState(int newState)
Provide generic access to internal state.protected void
setString(java.lang.String newValue)
Set the string of this StringIO.-
Methods inherited from class jmri.implementation.AbstractNamedBean
addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, describeState, dispose, 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.NamedBean
addPropertyChangeListener, addPropertyChangeListener, compareTo, describeState, dispose, getComment, getDisplayName, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListenersByReference, getPropertyKeys, getSystemName, getUsageReport, getUserName, removeProperty, setComment, setProperty, setUserName, toString, updateListenerRef, vetoableChange
-
Methods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
Methods inherited from interface jmri.StringIO
getMaximumLength, requestUpdateFromLayout
-
-
-
-
Constructor Detail
-
AbstractStringIO
public AbstractStringIO(@Nonnull java.lang.String systemName)
Abstract constructor for new StringIO with system name- Parameters:
systemName
- StringIO system name
-
AbstractStringIO
public AbstractStringIO(@Nonnull java.lang.String systemName, java.lang.String userName)
Abstract constructor for new StringIO with system name and user name- Parameters:
systemName
- StringIO system nameuserName
- StringIO user name
-
-
Method Detail
-
sendStringToLayout
protected abstract void sendStringToLayout(@Nonnull java.lang.String value) throws JmriException
Sends the string to the layout. The string [u]must not[/u] be longer than the value of getMaximumLength() unless that value is zero. Some microcomputers have little memory and it's very important that this method is never called with too long strings.- Parameters:
value
- the desired string value- Throws:
JmriException
- general error when setting the value fails
-
setString
protected void setString(@Nonnull java.lang.String newValue)
Set the string of this StringIO. Called from the implementation class when the layout updates this StringIO.- Parameters:
newValue
- new value to set
-
setCommandedStringValue
public void setCommandedStringValue(@Nonnull java.lang.String value) throws JmriException
Change the commanded value, which results in the relevant command(s) being sent to the hardware. The exception is thrown if there are problems communicating with the layout hardware.- Specified by:
setCommandedStringValue
in interfaceStringIO
- Parameters:
value
- the desired string value- Throws:
JmriException
- general error when setting the value fails
-
getCommandedStringValue
@Nonnull public java.lang.String getCommandedStringValue()
Query the commanded string. This is a bound parameter, so you can also register a listener to be informed of changes.- Specified by:
getCommandedStringValue
in interfaceStringIO
- Returns:
- the string value
-
getKnownStringValue
public java.lang.String getKnownStringValue()
Query the known string value. This is a bound parameter, so you can also register a listener to be informed of changes. A result is always returned; if no other feedback method is available, the commanded value will be used.- Specified by:
getKnownStringValue
in interfaceStringIO
- Returns:
- the known string value
-
cutLongStrings
protected abstract boolean cutLongStrings()
Cut long strings instead of throwing an exception? For example, if the StringIO is a display, it could be desired to accept too long strings. On the other hand, if the StringIO is used to send a command, a too long string is an error.- Returns:
- true if long strings should be cut
-
getState
public int getState()
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.
-
setState
public void setState(int newState)
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.
-
getBeanType
@Nonnull public 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.- Specified by:
getBeanType
in interfaceNamedBean
- Returns:
- a string of the bean type, eg Turnout, Sensor etc
-
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.
-
-