Class DBEntry

java.lang.Object
edu.tufts.hrilab.action.db.DBEntry
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ActionDBEntry, OperatorDBEntry

public abstract class DBEntry extends Object implements Serializable
TODO: this class (and all sub-classes) are meant to be immutable, but currently several methods return ActionBindings which are not immutable, which breaks the immutability of this class.
See Also:
  • Field Details

    • type

      protected final String type
      Each entry in the database has an associated type. The type may be a name of an action or an operator. For example, the type could be "liftup". The type is also used to define a type hierarchy. The action with a type "liftup" may have a parent type of "action". The type hierarchy is used by isA.
    • description

      protected final String description
      The description is human-readable text describing the entry. The description is optional and an empty string by default.
    • roles

      protected final List<ActionBinding> roles
      Roles indicates the list of arguments expected for this entry. Default values may be provided and used when it is invoked if no other value is provided.
    • isVarArgs

      protected final boolean isVarArgs
  • Constructor Details

  • Method Details

    • getType

      public String getType()
      Get the type of this entry.
      Returns:
      the type
    • getName

      public String getName()
      Get the name of this entry (same as type)
      Returns:
      the name
    • getDescription

      public String getDescription()
      Get the description
      Returns:
      the description
    • getRoleName

      public String getRoleName(int pos)
      Get a role's name
      Parameters:
      pos - the argument position
      Returns:
      that role's type
    • getRoleJavaType

      public Class<?> getRoleJavaType(int pos)
      Get a role's Java type.
      Parameters:
      pos - the argument position
      Returns:
      that role's type
    • getRoleSemanticType

      public String getRoleSemanticType(int pos)
      Get a role's semantic type.
      Parameters:
      pos - the argument position
      Returns:
      that role's semantic type
    • getRoleDefault

      public String getRoleDefault(int pos)
    • getRoleReturn

      public boolean getRoleReturn(int pos)
    • getRoleLocal

      public boolean getRoleLocal(int pos)
    • getRoleIsVarArg

      public boolean getRoleIsVarArg(int pos)
    • getNumRoles

      public int getNumRoles()
      Get the number of roles for this entry.
      Returns:
      the number of roles
    • getRoles

      public List<ActionBinding> getRoles()
      Get roles.
      Returns:
      roles (read only)
    • getRole

      public ActionBinding getRole(String name)
      Return role with matching role name, and null otherwise.
      Parameters:
      name -
      Returns:
    • isVarArgs

      public boolean isVarArgs()
      Returns whether the underlying Java method is a varargs method.
      Returns:
    • getRequiredInputRoles

      public List<ActionBinding> getRequiredInputRoles()
      Get required roles. The required input roles, excluding the ?actor role.
      Returns:
      required roles (read only)
    • getOptionalInputRoles

      public List<ActionBinding> getOptionalInputRoles()
      Get optional roles. This consists of optional input roles that have a default value.
      Returns:
      optional roles (read only)
    • getInputRoles

      public List<ActionBinding> getInputRoles()
      Get the ?actor role (for Actions, not Operators), all required roles, and optional input roles (e.g., those with a default value). This INCLUDES the ?actor role for Actions, not Operators.
      Returns:
      all input roles roles (read only)
    • getReturnRoles

      public List<ActionBinding> getReturnRoles()
      Get the return roles of this DBEntry.
      Returns:
      list of return ActionBindings
    • getLocalRoles

      public List<ActionBinding> getLocalRoles()
      Get the local roles of this DBEntry.
      Returns:
      list of return ActionBindings
    • getRequiredInputRolesTypes

      public List<Class<?>> getRequiredInputRolesTypes()
      Get the list of required role types when calling this DBEntry. Required roles are the arguments that have to be provided when calling this DBEntry. This excludes the ?actor role.
      Returns:
      list of role types required when calling this DBEntry.
    • getInputRolesTypes

      public List<Class<?>> getInputRolesTypes()
      Get the list of input role types when calling this DBEntry. Input roles are all the arguments that can be provided when calling this DBEntry. This includes the ?actor role, all required roles, and all optional input roles that have a default value. This INCLUDES the ?actor role.
      Returns:
      list of role types (required and optional) when calling this DBEntry.
    • getOptionalInputRolesTypes

      public List<Class<?>> getOptionalInputRolesTypes()
      Get the list of optional role types when calling this DBEntry. Optional roles are either return variables or roles with default values. They do not have to be provided when calling this DBEntry.
      Returns:
      list of optional role types.
    • getReturnRolesTypes

      public List<Class<?>> getReturnRolesTypes()
      Get the list of return role types of this DBEntry.
      Returns:
      list of return role types
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • conflictsWith

      public boolean conflictsWith(DBEntry that)
      Checks if another DBEntry conflicts with this one (same type, name and role types). Two DBEntries are conflicting when it is not possible to identify which one is being called in an eventspec, because they have the same type, name and roles.
      Parameters:
      that - other DBEntry
      Returns:
      true if they conflict