Class ComposedName

java.lang.Object
FAtiMA.Core.wellFormedNames.Name
FAtiMA.Core.wellFormedNames.ComposedName
All Implemented Interfaces:
IGroundable, Serializable, Cloneable

public class ComposedName extends Name implements Serializable
Author:
Joao Dias
See Also:
  • Field Details

    • _literals

      protected ArrayList<Symbol> _literals
    • _evaluate

      protected boolean _evaluate
  • Constructor Details

    • ComposedName

      public ComposedName(String name, 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 Details

    • 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 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 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(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:
    • 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:
    • clone

      public 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 String toString()
      Converts the ComposedName to a String
      Overrides:
      toString in class Object
      Returns:
      the converted String