Class RuleEnvironment


  • public class RuleEnvironment
    extends java.lang.Object
    Implements the environment for a typing judgment
    Author:
    Lorenzo Bettini
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Map<java.lang.Object,​java.lang.Object> environment  
      protected RuleEnvironment next  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean add​(java.lang.Object o1, java.lang.Object o2)  
      boolean add​(java.lang.Object o1, java.lang.Object o2, boolean checkExist)
      If checkExist is true, before inserting, also checks that there is no other statement in the environment with left equal to the passed typingStatement left (otherwise returns false=
      void add​(RuleEnvironmentEntry runtimeEnvironmentEntry)  
      void clear()  
      void decrement​(java.lang.Object o1)
      Remove the mapping with the passed object as key
      void decrement​(RuleEnvironment ruleEnvironment)
      Removes all the mapping that have as keys the keys of the passed environment.
      java.util.Set<java.util.Map.Entry<java.lang.Object,​java.lang.Object>> entrySet()  
      boolean equals​(java.lang.Object o)
      If the passed object is a RuleEnvironment then returns equals on the two Map contained objects.
      java.lang.Object get​(java.lang.Object key)
      If the key is not found in this environment tries recursively with the next one
      java.util.Map<java.lang.Object,​java.lang.Object> getEnvironment()  
      RuleEnvironment getNext()  
      int hashCode()  
      void increment​(java.lang.Object o1, java.lang.Object o2)
      Same as add
      void increment​(RuleEnvironment ruleEnvironment)
      Adds all the entries of the passed environment to this one (existing mappings for the same key will be overwritten).
      void increment​(RuleEnvironmentEntry runtimeEnvironmentEntry)
      Same as add
      boolean isEmpty()  
      java.util.Set<java.lang.Object> keySet()  
      void setNext​(RuleEnvironment next)  
      void setNext​(RuleEnvironmentEntry runtimeEnvironmentEntry)  
      int size()  
      java.lang.String toString()  
      boolean union​(java.lang.Object o1, java.lang.Object o2)  
      boolean union​(RuleEnvironment ruleEnvironment)
      Adds all the entries of the passed environment, but it returns false if there are mappings in the passed environment with the same key of the current environment; the current environment is NOT restored to its original state in case of failure.
      boolean union​(RuleEnvironmentEntry runtimeEnvironmentEntry)  
      java.util.Collection<java.lang.Object> values()  
      • Methods inherited from class java.lang.Object

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

      • environment

        protected java.util.Map<java.lang.Object,​java.lang.Object> environment
    • Method Detail

      • getEnvironment

        public java.util.Map<java.lang.Object,​java.lang.Object> getEnvironment()
      • add

        public boolean add​(java.lang.Object o1,
                           java.lang.Object o2)
      • add

        public boolean add​(java.lang.Object o1,
                           java.lang.Object o2,
                           boolean checkExist)
        If checkExist is true, before inserting, also checks that there is no other statement in the environment with left equal to the passed typingStatement left (otherwise returns false=
        Parameters:
        typingStatement -
        checkExist -
        Returns:
      • get

        public java.lang.Object get​(java.lang.Object key)
        If the key is not found in this environment tries recursively with the next one
        Parameters:
        key -
        Returns:
      • increment

        public void increment​(RuleEnvironment ruleEnvironment)
        Adds all the entries of the passed environment to this one (existing mappings for the same key will be overwritten).
        Parameters:
        ruleEnvironment -
      • increment

        public void increment​(RuleEnvironmentEntry runtimeEnvironmentEntry)
        Same as add
        Parameters:
        runtimeEnvironmentEntry -
      • increment

        public void increment​(java.lang.Object o1,
                              java.lang.Object o2)
        Same as add
        Parameters:
        o1 -
        o2 -
      • decrement

        public void decrement​(RuleEnvironment ruleEnvironment)
        Removes all the mapping that have as keys the keys of the passed environment.
        Parameters:
        ruleEnvironment -
      • decrement

        public void decrement​(java.lang.Object o1)
        Remove the mapping with the passed object as key
        Parameters:
        o1 -
      • union

        public boolean union​(RuleEnvironment ruleEnvironment)
        Adds all the entries of the passed environment, but it returns false if there are mappings in the passed environment with the same key of the current environment; the current environment is NOT restored to its original state in case of failure.
        Parameters:
        ruleEnvironment - if null it's succeeds
        Returns:
      • union

        public boolean union​(java.lang.Object o1,
                             java.lang.Object o2)
      • toString

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

        public boolean isEmpty()
        Since:
        1.5
      • size

        public int size()
        Since:
        1.5
      • clear

        public void clear()
        Since:
        1.5
      • keySet

        public java.util.Set<java.lang.Object> keySet()
        Since:
        1.5
      • values

        public java.util.Collection<java.lang.Object> values()
        Since:
        1.5
      • entrySet

        public java.util.Set<java.util.Map.Entry<java.lang.Object,​java.lang.Object>> entrySet()
        Since:
        1.5
      • equals

        public boolean equals​(java.lang.Object o)
        If the passed object is a RuleEnvironment then returns equals on the two Map contained objects.
        Overrides:
        equals in class java.lang.Object
        Since:
        1.5
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
        Since:
        1.5