Class SimpleNametable

  • All Implemented Interfaces:
    Nametable

    public class SimpleNametable
    extends java.lang.Object
    implements Nametable
    A simple implementation of nametable
    Author:
    TiongHiang Lee (thlee@onemindsoft.org)
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Map _table  
    • Constructor Summary

      Constructors 
      Constructor Description
      SimpleNametable​(java.util.Map m)
      Constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object access​(java.lang.String name)
      Access the value associated with name
      java.util.Map asMap()
      Return the name table as a map
      java.lang.Object assign​(java.lang.String name, java.lang.Object value)
      Assign a variable in the name table
      boolean containsName​(java.lang.String name)
      Whether the nametable contains the name
      void declare​(java.lang.String name, java.lang.Object value)
      Declare a variable in the name table
      java.lang.String toString()  
      void undeclare​(java.lang.String name)
      Undeclare the name
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • _table

        private final java.util.Map _table
    • Constructor Detail

      • SimpleNametable

        public SimpleNametable​(java.util.Map m)
        Constructor
        Parameters:
        m - the name
    • Method Detail

      • declare

        public void declare​(java.lang.String name,
                            java.lang.Object value)
        Declare a variable in the name table
        Specified by:
        declare in interface Nametable
        Parameters:
        name - the name
        value - the value
      • assign

        public java.lang.Object assign​(java.lang.String name,
                                       java.lang.Object value)
        Assign a variable in the name table
        Specified by:
        assign in interface Nametable
        Parameters:
        name - the name
        value - the value
        Returns:
        the old value, or null
      • containsName

        public boolean containsName​(java.lang.String name)
        Whether the nametable contains the name
        Specified by:
        containsName in interface Nametable
        Parameters:
        name - the name
        Returns:
        true if contains the name
      • access

        public java.lang.Object access​(java.lang.String name)
        Access the value associated with name
        Specified by:
        access in interface Nametable
        Returns:
      • undeclare

        public void undeclare​(java.lang.String name)
        Undeclare the name
        Specified by:
        undeclare in interface Nametable
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • asMap

        public java.util.Map asMap()
        Return the name table as a map
        Specified by:
        asMap in interface Nametable
        Returns:
        unmodifiable map representation of the name table