Class ComposedName

    • Constructor Summary

      Constructors 
      Constructor Description
      ComposedName​(java.lang.String name, java.lang.String literals)
      Creates a new ComposedName, receiving a major symbol, and a string with several parameter symbols
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object clone()
      Clones this Composed Name, returning an equal copy.
      java.lang.Object evaluate​(Memory m)
      Evaluates this Name according to the evaluation attribute.
      Symbol GetFirstLiteral()
      Get's the Name's first symbol.
      java.util.ArrayList<Symbol> GetLiteralList()
      Generates a list with all symbols contained in the ComposedName
      void MakeGround​(Substitution subst)
      Applies a set of substitutions to the object, grounding it.
      void MakeGround​(java.util.ArrayList<Substitution> bindingConstraints)
      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.
      void SetEvaluation​(boolean evaluate)
      Sets the evaluation method.
      java.lang.String toString()
      Converts the ComposedName to a String
      • Methods inherited from class java.lang.Object

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

      • _literals

        protected java.util.ArrayList<Symbol> _literals
      • _evaluate

        protected boolean _evaluate
    • Constructor Detail

      • ComposedName

        public ComposedName​(java.lang.String name,
                            java.lang.String literals)
        Creates a new ComposedName, receiving a major symbol, and a string with several parameter symbols
        Parameters:
        name - - the Major symbol
        literals - - string containing parameter symbols separated by commas
    • Method Detail

      • SetEvaluation

        public void SetEvaluation​(boolean evaluate)
        Sets the evaluation method. If this attribute is false, the evaluate method behaves like a Symbol, and does not evaluate the name but just returns a String with the composedName. If the attribute is true, it will evaluate using the value stored in the KB.
      • GetFirstLiteral

        public Symbol GetFirstLiteral()
        Get's the Name's first symbol. Since this name is a ComposedName (composed by several symbols), this function returns the first one, which corresponds to the Major symbol
        Specified by:
        GetFirstLiteral in class Name
        Returns:
        the Major symbol
      • GetLiteralList

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

        public java.lang.Object evaluate​(Memory m)
        Evaluates this Name according to the evaluation attribute. If this attribute is false, the evaluate method behaves like a Symbol, and does not evaluate the name but just returns a String with the composedName. If the attribute is true, it will search the value associated to the ComposedName in the KnowledgeBase
        Specified by:
        evaluate in class Name
        Parameters:
        m - - a reference to the memory
        Returns:
        the result of evaluation the ComposedName
      • 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> bindingConstraints)
        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:
        bindingConstraints - - 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 Composed Name, returning an equal copy. If this clone is changed afterwards, the original object remains the same.
        Specified by:
        clone in class Name
        Returns:
        The ComposedName's copy.
      • toString

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