Class AbstractStringIO

    • 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 name
        userName - 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 interface StringIO
        Parameters:
        value - the desired string value
        Throws:
        JmriException - general error when setting the value fails
      • 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 interface StringIO
        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.

        Specified by:
        getState in interface NamedBean
        Returns:
        the state
      • 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.

        Specified by:
        setState in interface NamedBean
        Parameters:
        newState - the state
      • 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 interface NamedBean
        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 the NamedBean.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 interface NamedBean
        Overrides:
        compareSystemNameSuffix in class AbstractNamedBean
        Parameters:
        suffix1 - The suffix for the 1st bean in the comparison
        suffix2 - The suffix for the 2nd bean in the comparison
        n - 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.