Class DefaultSymbolTable
- java.lang.Object
-
- jmri.jmrit.logixng.implementation.DefaultSymbolTable
-
- All Implemented Interfaces:
SymbolTable
public class DefaultSymbolTable extends java.lang.Object implements SymbolTable
The default implementation of a NamedTable
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DefaultSymbolTable.DefaultParameter
static class
DefaultSymbolTable.DefaultSymbol
-
Nested classes/interfaces inherited from interface jmri.jmrit.logixng.SymbolTable
SymbolTable.InitialValueType, SymbolTable.Symbol, SymbolTable.SymbolNotFound, SymbolTable.Type, SymbolTable.VariableData
-
-
Field Summary
-
Fields inherited from interface jmri.jmrit.logixng.SymbolTable
log
-
-
Constructor Summary
Constructors Constructor Description DefaultSymbolTable()
Create a new instance of DefaultSymbolTable with no previous symbol table.DefaultSymbolTable(ConditionalNG currentConditionalNG)
Create a new instance of DefaultSymbolTable with previous symbol table and the stack from a ConditionalNG.DefaultSymbolTable(SymbolTable prevSymbolTable)
Create a new instance of DefaultSymbolTable from a previous symbol table and a stack.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
createSymbols(java.util.Collection<? extends SymbolTable.VariableData> symbolDefinitions)
Add new symbols to the symbol tablevoid
createSymbols(SymbolTable symbolTable, java.util.Collection<? extends SymbolTable.VariableData> symbolDefinitions)
Add new symbols to the symbol table.SymbolTable
getPrevSymbolTable()
Get the previous symbol tableStack
getStack()
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.Object
getValue(java.lang.String name)
Get the value of a symbolStack.ValueAndType
getValueAndType(java.lang.String name)
Get the value and type of a symbol.boolean
hasValue(java.lang.String name)
Is the symbol in the symbol table?void
printSymbolTable(java.io.PrintWriter stream)
Print the symbol table on a streamvoid
removeSymbols(java.util.Collection<? extends SymbolTable.VariableData> symbolDefinitions)
Removes symbols from the symbol tablevoid
setValue(java.lang.String name, java.lang.Object value)
Set the value of a symbol
-
-
-
Constructor Detail
-
DefaultSymbolTable
public DefaultSymbolTable()
Create a new instance of DefaultSymbolTable with no previous symbol table.
-
DefaultSymbolTable
public DefaultSymbolTable(ConditionalNG currentConditionalNG)
Create a new instance of DefaultSymbolTable with previous symbol table and the stack from a ConditionalNG.- Parameters:
currentConditionalNG
- the ConditionalNG
-
DefaultSymbolTable
public DefaultSymbolTable(SymbolTable prevSymbolTable)
Create a new instance of DefaultSymbolTable from a previous symbol table and a stack.- Parameters:
prevSymbolTable
- the previous symbol table
-
-
Method Detail
-
getPrevSymbolTable
public SymbolTable getPrevSymbolTable()
Get the previous symbol table- Returns:
- the symbol table
-
getSymbols
public java.util.Map<java.lang.String,SymbolTable.Symbol> getSymbols()
The list of symbols in the table- Specified by:
getSymbols
in interfaceSymbolTable
- Returns:
- the symbols
-
getSymbolValues
public java.util.Map<java.lang.String,java.lang.Object> getSymbolValues()
The list of symbols and their values in the table- Specified by:
getSymbolValues
in interfaceSymbolTable
- Returns:
- the name of the symbols and their values
-
getValue
public java.lang.Object getValue(java.lang.String name)
Get the value of a symbol- Specified by:
getValue
in interfaceSymbolTable
- Parameters:
name
- the name- Returns:
- the value
-
getValueAndType
public Stack.ValueAndType getValueAndType(java.lang.String name)
Get the value and type of a symbol. This method does not lookup global variables.- Specified by:
getValueAndType
in interfaceSymbolTable
- Parameters:
name
- the name- Returns:
- the value and type
-
hasValue
public boolean hasValue(java.lang.String name)
Is the symbol in the symbol table?- Specified by:
hasValue
in interfaceSymbolTable
- Parameters:
name
- the name- Returns:
- true if the symbol exists, false otherwise
-
setValue
public void setValue(java.lang.String name, java.lang.Object value)
Set the value of a symbol- Specified by:
setValue
in interfaceSymbolTable
- Parameters:
name
- the namevalue
- the value
-
printSymbolTable
public void printSymbolTable(java.io.PrintWriter stream)
Print the symbol table on a stream- Specified by:
printSymbolTable
in interfaceSymbolTable
- Parameters:
stream
- the stream
-
createSymbols
public void createSymbols(java.util.Collection<? extends SymbolTable.VariableData> symbolDefinitions) throws JmriException
Add new symbols to the symbol table- Specified by:
createSymbols
in interfaceSymbolTable
- Parameters:
symbolDefinitions
- the definitions of the new symbols- Throws:
JmriException
- if an exception is thrown
-
createSymbols
public 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.- Specified by:
createSymbols
in interfaceSymbolTable
- Parameters:
symbolTable
- the symbol table to get existing symbols fromsymbolDefinitions
- the definitions of the new symbols- Throws:
JmriException
- if an exception is thrown
-
removeSymbols
public void removeSymbols(java.util.Collection<? extends SymbolTable.VariableData> symbolDefinitions) throws JmriException
Removes symbols from the symbol table- Specified by:
removeSymbols
in interfaceSymbolTable
- Parameters:
symbolDefinitions
- the definitions of the symbols to be removed- Throws:
JmriException
- if an exception is thrown
-
getStack
public Stack getStack()
Get the stack. This method is only used internally by DefaultSymbolTable.- Specified by:
getStack
in interfaceSymbolTable
- Returns:
- the stack
-
-