Interface SymbolTable

    • Field Detail

      • log

        static final org.slf4j.Logger log
    • Method Detail

      • getSymbolValues

        java.util.Map<java.lang.String,​java.lang.Object> getSymbolValues()
        The list of symbols and their values in the table
        Returns:
        the name of the symbols and their values
      • getValue

        java.lang.Object getValue​(java.lang.String name)
        Get the value of a symbol
        Parameters:
        name - the name
        Returns:
        the value
      • getValueAndType

        Stack.ValueAndType getValueAndType​(java.lang.String name)
        Get the value and type of a symbol. This method does not lookup global variables.
        Parameters:
        name - the name
        Returns:
        the value and type
      • hasValue

        boolean hasValue​(java.lang.String name)
        Is the symbol in the symbol table?
        Parameters:
        name - the name
        Returns:
        true if the symbol exists, false otherwise
      • setValue

        void setValue​(java.lang.String name,
                      java.lang.Object value)
        Set the value of a symbol
        Parameters:
        name - the name
        value - the value
      • createSymbols

        void createSymbols​(SymbolTable symbolTable,
                           java.util.Collection<? extends SymbolTable.VariableData> symbolDefinitions)
                    throws JmriException
        Add new symbols to the symbol table. This method is used for parameters, when new symbols might be created that uses symbols from a previous symbol table.
        Parameters:
        symbolTable - the symbol table to get existing symbols from
        symbolDefinitions - the definitions of the new symbols
        Throws:
        JmriException - if an exception is thrown
      • printSymbolTable

        void printSymbolTable​(java.io.PrintWriter stream)
        Print the symbol table on a stream
        Parameters:
        stream - the stream
      • validateName

        static boolean validateName​(java.lang.String name)
        Validates the name of a symbol
        Parameters:
        name - the name
        Returns:
        true if the name is valid, false otherwise
      • getStack

        Stack getStack()
        Get the stack. This method is only used internally by DefaultSymbolTable.
        Returns:
        the stack
      • printVariable

        static void printVariable​(org.slf4j.Logger log,
                                  java.lang.String pad,
                                  java.lang.String name,
                                  java.lang.Object value,
                                  boolean expandArraysAndMaps,
                                  boolean showClassName,
                                  java.lang.String headerName,
                                  java.lang.String headerValue)
        Print a variable
        Parameters:
        log - the logger
        pad - the padding
        name - the name
        value - the value
        expandArraysAndMaps - true if arrays and maps should be expanded, false otherwise
        showClassName - true if class name should be shown
        headerName - header for the variable name
        headerValue - header for the variable value
      • validateStrictTyping

        static java.lang.Object validateStrictTyping​(SymbolTable.InitialValueType type,
                                                     java.lang.Object oldValue,
                                                     java.lang.Object newValue)
                                              throws java.lang.NumberFormatException
        Validates that the value can be assigned to a local or global variable of the specified type if strict typing is enforced. The caller must check first if this method should be called or not.
        Parameters:
        type - the type
        oldValue - the old value
        newValue - the new value
        Returns:
        the value to assign. It might be converted if needed.
        Throws:
        java.lang.NumberFormatException