Package jmri.jmrit.logixng
Interface SymbolTable
- All Known Implementing Classes:
DefaultSymbolTable
public interface SymbolTable
A symbol table
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumAn enum that defines the types of initial value.static interfaceThe definition of the symbolstatic classstatic enumstatic classData for a variable. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidcreateSymbols(Collection<? extends SymbolTable.VariableData> symbolDefinitions) Add new symbols to the symbol tablevoidcreateSymbols(SymbolTable symbolTable, Collection<? extends SymbolTable.VariableData> symbolDefinitions) Add new symbols to the symbol table.static ObjectgetInitialValue(SymbolTable.Type type, String name, SymbolTable.InitialValueType initialType, String initialData, SymbolTable symbolTable, Map<String, SymbolTable.Symbol> symbols) getStack()Get the stack.The list of symbols in the tableThe list of symbols and their values in the tableGet the value of a symbolgetValueAndType(String name) Get the value and type of a symbol.booleanIs the symbol in the symbol table?voidprintSymbolTable(PrintWriter stream) Print the symbol table on a streamstatic voidprintVariable(org.slf4j.Logger log, String pad, String name, Object value, boolean expandArraysAndMaps, boolean showClassName, String headerName, String headerValue) Print a variablevoidremoveSymbols(Collection<? extends SymbolTable.VariableData> symbolDefinitions) Removes symbols from the symbol tablevoidSet the value of a symbolstatic booleanvalidateName(String name) Validates the name of a symbolstatic ObjectvalidateStrictTyping(SymbolTable.InitialValueType type, Object oldValue, Object newValue) Validates that the value can be assigned to a local or global variable of the specified type if strict typing is enforced.
-
Field Details
-
log
-
-
Method Details
-
getSymbols
The list of symbols in the table- Returns:
- the symbols
-
getSymbolValues
The list of symbols and their values in the table- Returns:
- the name of the symbols and their values
-
getValue
Get the value of a symbol- Parameters:
name- the name- Returns:
- the value
-
getValueAndType
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
Is the symbol in the symbol table?- Parameters:
name- the name- Returns:
- true if the symbol exists, false otherwise
-
setValue
Set the value of a symbol- Parameters:
name- the namevalue- the value
-
createSymbols
void createSymbols(Collection<? extends SymbolTable.VariableData> symbolDefinitions) throws JmriException Add new symbols to the symbol table- Parameters:
symbolDefinitions- the definitions of the new symbols- Throws:
JmriException- if an exception is thrown
-
createSymbols
void createSymbols(SymbolTable symbolTable, 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 fromsymbolDefinitions- the definitions of the new symbols- Throws:
JmriException- if an exception is thrown
-
removeSymbols
void removeSymbols(Collection<? extends SymbolTable.VariableData> symbolDefinitions) throws JmriException Removes symbols from the symbol table- Parameters:
symbolDefinitions- the definitions of the symbols to be removed- Throws:
JmriException- if an exception is thrown
-
printSymbolTable
Print the symbol table on a stream- Parameters:
stream- the stream
-
validateName
Validates the name of a symbol- Parameters:
name- the name- Returns:
- true if the name is valid, false otherwise
-
getStack
Get the stack. This method is only used internally by DefaultSymbolTable.- Returns:
- the stack
-
printVariable
static void printVariable(org.slf4j.Logger log, String pad, String name, Object value, boolean expandArraysAndMaps, boolean showClassName, String headerName, String headerValue) Print a variable- Parameters:
log- the loggerpad- the paddingname- the namevalue- the valueexpandArraysAndMaps- true if arrays and maps should be expanded, false otherwiseshowClassName- true if class name should be shownheaderName- header for the variable nameheaderValue- header for the variable value
-
getInitialValue
static Object getInitialValue(SymbolTable.Type type, String name, SymbolTable.InitialValueType initialType, String initialData, SymbolTable symbolTable, Map<String, SymbolTable.Symbol> symbols) throws ParserException, JmriException- Throws:
ParserExceptionJmriException
-
validateStrictTyping
static Object validateStrictTyping(SymbolTable.InitialValueType type, Object oldValue, Object newValue) throws 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 typeoldValue- the old valuenewValue- the new value- Returns:
- the value to assign. It might be converted if needed.
- Throws:
NumberFormatException- when needed
-