Class Symbol

  • All Implemented Interfaces:
    IGroundable, java.io.Serializable, java.lang.Cloneable

    public class Symbol
    extends Name
    implements java.io.Serializable
    Well Formed Name with just one literal The alphabet that makes up the symbols expressions consists of: � The set of letters, upper and lowercase. � The set of digits, 0,1,..,9 � The symbols �_� and �-� Symbols expressions begin with a letter and are followed by any sequence of these legal characters. Well formed names are composed by four types of symbols: 1. The Truth symbols "True" and "False". 2. Constant symbols, which are simple symbol expressions. 3. Variables symbols, which are symbol expressions enclosed in square parentheses. Ex: [x] represents the variable x. 4. The Self symbol [SELF], a reserved special variable which refers to the agent.
    Author:
    Joao Dias
    See Also:
    Name, Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.String _name  
    • Constructor Summary

      Constructors 
      Constructor Description
      Symbol​(java.lang.String name)
      Creates a new Symbol
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object clone()
      Clones this Symbol, returning an equal copy.
      java.lang.Object evaluate​(Memory m)
      Evaluates this symbol
      Symbol GetFirstLiteral()
      Gets the Name's First Symbol or Literal
      java.util.ArrayList<Symbol> GetLiteralList()
      Generates a list with all symbols contained in the Name
      java.lang.String getName()
      Gets the String that represents the Symbol's name
      void MakeGround​(Substitution subst)
      Applies a set of substitutions to the object, grounding it.
      void MakeGround​(java.util.ArrayList<Substitution> bindings)
      Applies a set of substitutions to the object, grounding it.
      void ReplaceUnboundVariables​(int id)
      Replaces all unbound variables in the object by applying a numeric identifier to each one.
      java.lang.String toString()
      Converts the Symbol to a String
      • Methods inherited from class java.lang.Object

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

      • _name

        protected java.lang.String _name
    • Constructor Detail

      • Symbol

        public Symbol​(java.lang.String name)
        Creates a new Symbol
        Parameters:
        name - - A String that corresponds to a Well Formed Symbol
    • Method Detail

      • GetFirstLiteral

        public Symbol GetFirstLiteral()
        Gets the Name's First Symbol or Literal
        Specified by:
        GetFirstLiteral in class Name
        Returns:
        the first Symbol
      • GetLiteralList

        public java.util.ArrayList<Symbol> GetLiteralList()
        Generates a list with all symbols contained in the Name
        Specified by:
        GetLiteralList in class Name
        Returns:
        the list with the symbols
      • getName

        public java.lang.String getName()
        Gets the String that represents the Symbol's name
        Returns:
        the Symbol's name
      • evaluate

        public java.lang.Object evaluate​(Memory m)
        Evaluates this symbol
        Specified by:
        evaluate in class Name
        Parameters:
        m - - a reference to the memory
        Returns:
        the Symbol's name
      • ReplaceUnboundVariables

        public void ReplaceUnboundVariables​(int id)
        Replaces all unbound variables in the object by applying a numeric identifier to each one. For example, the variable [x] becomes [x4] if the received ID is 4. Attention, this method modifies the original object.
        Specified by:
        ReplaceUnboundVariables in interface IGroundable
        Parameters:
        id - - the identifier to be applied
      • MakeGround

        public void MakeGround​(java.util.ArrayList<Substitution> bindings)
        Applies a set of substitutions to the object, grounding it. Example: Applying the substitution "[X]/John" in the name "Weak([X])" returns "Weak(John)". Attention, this method modifies the original object.
        Specified by:
        MakeGround in interface IGroundable
        Parameters:
        bindings - - A list of substitutions of the type "[Variable]/value"
        See Also:
        Substitution
      • MakeGround

        public void MakeGround​(Substitution subst)
        Applies a set of substitutions to the object, grounding it. Example: Applying the substitution "[X]/John" in the name "Weak([X])" returns "Weak(John)". Attention, this method modifies the original object.
        Specified by:
        MakeGround in interface IGroundable
        Parameters:
        subst - - a substitution of the type "[Variable]/value"
        See Also:
        Substitution
      • clone

        public java.lang.Object clone()
        Clones this Symbol, returning an equal copy. If this clone is changed afterwards, the original object remains the same.
        Specified by:
        clone in class Name
        Returns:
        The Symbol's copy.
      • toString

        public java.lang.String toString()
        Converts the Symbol to a String
        Overrides:
        toString in class java.lang.Object
        Returns:
        the converted String