Class Symbol<T>

java.lang.Object
fr.uga.pddl4j.parser.Symbol<T>
Type Parameters:
T - the type of symbol, i.e., integer of string.
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
TypedSymbol

public class Symbol<T> extends Object implements Serializable
This class implements the symbols manipulated by the parser and by the instantiation process.
See Also:
Serialized Form
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static String
    The name of rename task tag.
    static String
    The name of rename variable.
    static Symbol<String>
    The default symbol for number type.
    static Symbol<String>
    The default symbol for object type.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Symbol​(Symbol<T> other)
    Creates a symbol from a specified symbol.
    Symbol​(SymbolType type, T value)
    Creates a new symbol with a specified value.
    Symbol​(SymbolType type, T value, int beginLine, int beginColumn, int endLine, int endColumn)
    Create a symbol with a specified image, line and column.
    Symbol​(SymbolType type, T value, Location location)
    Create a new symbol from a specified token.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    equals​(Object object)
    Return if this symbol is equal to another object, i.e., if they have the same value.
    Return the string image of this symbol.
    Return the location of the symbol.
    Returns the type of this symbol.
    Returns the value of the symbol.
    int
    Returns the hash code value of this symbol.
    rename​(Map<T,​T> context)
    Renames the symbol.
    void
    setBegin​(fr.uga.pddl4j.parser.lexer.Token begin)
    Sets the begin line and column of the expression from a specified token.
    void
    setEnd​(fr.uga.pddl4j.parser.lexer.Token end)
    Sets the end line and column of the expression from a specified token.
    void
    setLocation​(Location location)
    Sets the location of the symbol.
    void
    Sets the type of this symbol.
    void
    setValue​(T value)
    Sets the value of the symbol.
    Returns a string representation of this symbol.

    Methods inherited from class java.lang.Object

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

    • DEFAULT_VARIABLE_SYMBOL

      public static final String DEFAULT_VARIABLE_SYMBOL
      The name of rename variable.
      See Also:
      Constant Field Values
    • DEFAULT_TASK_ID_SYMBOL

      public static final String DEFAULT_TASK_ID_SYMBOL
      The name of rename task tag.
      See Also:
      Constant Field Values
    • OBJECT_TYPE

      public static final Symbol<String> OBJECT_TYPE
      The default symbol for object type.
    • NUMBER_TYPE

      public static final Symbol<String> NUMBER_TYPE
      The default symbol for number type.
  • Constructor Details

    • Symbol

      public Symbol(Symbol<T> other)
      Creates a symbol from a specified symbol.
      Parameters:
      other - the symbol.
    • Symbol

      public Symbol(SymbolType type, T value, Location location)
      Create a new symbol from a specified token.
      Parameters:
      type - the type of the symbol.
      value - the token.
      location - the location of the symbol.
    • Symbol

      public Symbol(SymbolType type, T value, int beginLine, int beginColumn, int endLine, int endColumn)
      Create a symbol with a specified image, line and column.
      Parameters:
      type - the type of the symbol.
      value - the value of the symbol.
      beginLine - the begin line of the symbol.
      beginColumn - the begin column of the symbol.
      endLine - the end line of the symbol.
      endColumn - the end column of the symbol.
    • Symbol

      public Symbol(SymbolType type, T value)
      Creates a new symbol with a specified value.
      Parameters:
      type - the kind of the symbol.
      value - the string image of the symbol.
  • Method Details

    • getType

      public final SymbolType getType()
      Returns the type of this symbol.
      Returns:
      the type of this symbol.
    • setType

      public final void setType(SymbolType type)
      Sets the type of this symbol.
      Parameters:
      type - the type of the symbol.
    • getValue

      public final T getValue()
      Returns the value of the symbol.
      Returns:
      the value of the symbol.
    • setValue

      public final void setValue(T value)
      Sets the value of the symbol.
      Parameters:
      value - the value to set.
    • getLocation

      public final Location getLocation()
      Return the location of the symbol.
      Returns:
      the location of the symbol.
    • setLocation

      public final void setLocation(Location location)
      Sets the location of the symbol.
      Parameters:
      location - the location to set.
    • setBegin

      public final void setBegin(fr.uga.pddl4j.parser.lexer.Token begin)
      Sets the begin line and column of the expression from a specified token.
      Parameters:
      begin - the first token of the expression.
    • setEnd

      public final void setEnd(fr.uga.pddl4j.parser.lexer.Token end)
      Sets the end line and column of the expression from a specified token.
      Parameters:
      end - the last token of the expression.
    • getImage

      public final String getImage()
      Return the string image of this symbol.
      Returns:
      the string image of this symbol.
    • rename

      public final T rename(Map<T,​T> context)
      Renames the symbol. The symbol is renamed if only if this symbol is contained the map in parameters, otherwise nothing is done.
      Parameters:
      context - the images of the symbol to renamed .
      Returns:
      the old image of the symbol or null if the symbol was not renamed.
    • equals

      public boolean equals(Object object)
      Return if this symbol is equal to another object, i.e., if they have the same value.
      Overrides:
      equals in class Object
      Parameters:
      object - the other object.
      Returns:
      true if this symbol is equal to object, i.e., other is not null and of type Symbol and it has the same value; otherwise return false.
      See Also:
      Object.equals(java.lang.Object)
    • hashCode

      public int hashCode()
      Returns the hash code value of this symbol.
      Overrides:
      hashCode in class Object
      Returns:
      the hash code value of this symbol.
      See Also:
      Object.hashCode()
    • toString

      public String toString()
      Returns a string representation of this symbol.
      Overrides:
      toString in class Object
      Returns:
      a string representation of this symbol.