Package jmri.jmrit.logixng
Interface SymbolTable
-
- All Known Implementing Classes:
DefaultSymbolTable
public interface SymbolTable
A symbol table
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classSymbolTable.InitialValueTypeAn enum that defines the types of initial value.static interfaceSymbolTable.SymbolThe definition of the symbolstatic classSymbolTable.SymbolNotFoundstatic classSymbolTable.Typestatic classSymbolTable.VariableDataData for a variable.
-
Field Summary
Fields Modifier and Type Field Description static org.slf4j.Loggerlog
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description voidcreateSymbols(java.util.Collection<? extends SymbolTable.VariableData> symbolDefinitions)Add new symbols to the symbol tablevoidcreateSymbols(SymbolTable symbolTable, java.util.Collection<? extends SymbolTable.VariableData> symbolDefinitions)Add new symbols to the symbol table.static java.lang.ObjectgetInitialValue(SymbolTable.Type type, java.lang.String name, SymbolTable.InitialValueType initialType, java.lang.String initialData, SymbolTable symbolTable, java.util.Map<java.lang.String,SymbolTable.Symbol> symbols)StackgetStack()Get the stack.java.util.Map<java.lang.String,SymbolTable.Symbol>getSymbols()The list of symbols in the tablejava.util.Map<java.lang.String,java.lang.Object>getSymbolValues()The list of symbols and their values in the tablejava.lang.ObjectgetValue(java.lang.String name)Get the value of a symbolStack.ValueAndTypegetValueAndType(java.lang.String name)Get the value and type of a symbol.booleanhasValue(java.lang.String name)Is the symbol in the symbol table?voidprintSymbolTable(java.io.PrintWriter stream)Print the symbol table on a streamstatic voidprintVariable(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 variablevoidremoveSymbols(java.util.Collection<? extends SymbolTable.VariableData> symbolDefinitions)Removes symbols from the symbol tablevoidsetValue(java.lang.String name, java.lang.Object value)Set the value of a symbolstatic booleanvalidateName(java.lang.String name)Validates the name of a symbolstatic java.lang.ObjectvalidateStrictTyping(SymbolTable.InitialValueType type, java.lang.Object oldValue, java.lang.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 Detail
-
log
static final org.slf4j.Logger log
-
-
Method Detail
-
getSymbols
java.util.Map<java.lang.String,SymbolTable.Symbol> getSymbols()
The list of symbols in the table- Returns:
- the symbols
-
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 namevalue- the value
-
createSymbols
void createSymbols(java.util.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, 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 fromsymbolDefinitions- the definitions of the new symbols- Throws:
JmriException- if an exception is thrown
-
removeSymbols
void removeSymbols(java.util.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
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 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 java.lang.Object getInitialValue(SymbolTable.Type type, java.lang.String name, SymbolTable.InitialValueType initialType, java.lang.String initialData, SymbolTable symbolTable, java.util.Map<java.lang.String,SymbolTable.Symbol> symbols) throws ParserException, JmriException
- Throws:
ParserExceptionJmriException
-
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 typeoldValue- the old valuenewValue- the new value- Returns:
- the value to assign. It might be converted if needed.
- Throws:
java.lang.NumberFormatException- when needed
-
-