java.lang.Object
tools.refinery.interpreter.matchers.psystem.queries.BasePQuery
All Implemented Interfaces:
PTraceable, PQuery, PQueryHeader

public abstract class BasePQuery extends Object implements PQuery
Default implementation of PQuery.
  • Field Details

  • Constructor Details

    • BasePQuery

      public BasePQuery(PVisibility visibility)
      Since:
      2.0
  • Method Details

    • getPositionOfParameter

      public Integer getPositionOfParameter(String parameterName)
      Description copied from interface: PQueryHeader
      Returns the index of a named parameter
      Specified by:
      getPositionOfParameter in interface PQueryHeader
      Parameters:
      parameterName -
      Returns:
      the index, or null of no such parameter is available
    • setStatus

      protected void setStatus(PQuery.PQueryStatus newStatus)
    • addError

      protected void addError(PProblem problem)
    • getStatus

      public PQuery.PQueryStatus getStatus()
      Description copied from interface: PQuery
      Returns the initialization status of the definition
      Specified by:
      getStatus in interface PQuery
    • getPProblems

      public List<PProblem> getPProblems()
      Description copied from interface: PQuery
      Returns a list describing the problems that were found in this query.

      TODO: formulate invariant connecting PQuery.getPProblems() and PQuery.getStatus().

      Specified by:
      getPProblems in interface PQuery
      Returns:
      a non-null, but possibly empty list of problems
    • isMutable

      public boolean isMutable()
      Description copied from interface: PQuery
      An option to check mutability of the query. It can be used to avoid getting an IllegalStateException by the execution of PQuery.checkMutability().
      Specified by:
      isMutable in interface PQuery
      Returns:
      true if the query specification is still editable
    • checkMutability

      public void checkMutability()
      Description copied from interface: PQuery
      Before a modification operation is executed, a mutability check is performed (via the PQuery.getStatus() implementation, and in case of problems an IllegalStateException is thrown.
      Specified by:
      checkMutability in interface PQuery
    • setEvaluationHints

      public void setEvaluationHints(QueryEvaluationHint hints)
      Since:
      1.5
    • getEvaluationHints

      public QueryEvaluationHint getEvaluationHints()
      Description copied from interface: PQuery
      Optional hints regarding the query evaluation strategy, to be interpreted by the query engine.

      To ensure the possibility of external overrides, the evaluation engine should not directly consult this field, but use an IQueryBackendHintProvider instead.

      Specified by:
      getEvaluationHints in interface PQuery
    • addAnnotation

      protected void addAnnotation(PAnnotation annotation)
    • getAllAnnotations

      public List<PAnnotation> getAllAnnotations()
      Description copied from interface: PQueryHeader
      Returns the list of annotations specified for this query
      Specified by:
      getAllAnnotations in interface PQueryHeader
      Returns:
      a non-null, but possibly empty list of annotations
    • getAnnotationsByName

      public List<PAnnotation> getAnnotationsByName(String annotationName)
      Description copied from interface: PQueryHeader
      Returns the list of annotations with a specified name
      Specified by:
      getAnnotationsByName in interface PQueryHeader
      Parameters:
      annotationName -
      Returns:
      a non-null, but possibly empty list of annotations
    • getFirstAnnotationByName

      public Optional<PAnnotation> getFirstAnnotationByName(String annotationName)
      Description copied from interface: PQueryHeader
      Returns the first annotation with a specified name
      Specified by:
      getFirstAnnotationByName in interface PQueryHeader
    • getParameterNames

      public List<String> getParameterNames()
      Description copied from interface: PQueryHeader
      Return the list of parameter names
      Specified by:
      getParameterNames in interface PQueryHeader
      Returns:
      a non-null, but possibly empty list of parameter names
    • getDirectReferredQueries

      public Set<PQuery> getDirectReferredQueries()
      Description copied from interface: PQuery
      Returns all queries directly referred in the constraints. They are all required to evaluate this query
      Specified by:
      getDirectReferredQueries in interface PQuery
      Returns:
      a non-null, but possibly empty list of query definitions
    • getAllReferredQueries

      public Set<PQuery> getAllReferredQueries()
      Description copied from interface: PQuery
      Returns all queries required to evaluate this query (transitively).
      Specified by:
      getAllReferredQueries in interface PQuery
      Returns:
      a non-null, but possibly empty list of query definitions
    • publishedAs

      public List<Object> publishedAs()
      Description copied from interface: PQuery
      Returns the end-user query specification API objects that wrap this query.

      Intended for traceability and debug purposes, not part of normal operation. Returned list is intended to be appended during query specification construction time.

      Specified by:
      publishedAs in interface PQuery
      Returns:
      a non-null, but possibly empty list of query specification objects;
    • getTypeGuarantees

      public Set<TypeJudgement> getTypeGuarantees()
      Description copied from interface: PQuery
      Type information, expressed on query parameters, that all matches of the query are guaranteed to respect.

      At the very minimum, this should include the declared types of the parameters.

      The type judgement tuples shall contain the parameter index, NOT the PParameter object.

      Specified by:
      getTypeGuarantees in interface PQuery
      Returns:
      a non-null set of type judgements that the query guarantees for its matches
    • getDisjunctBodies

      public PDisjunction getDisjunctBodies()
      Description copied from interface: PQuery
      Returns all bodies associated with the query in their canonical form. If called multiple times, the same set with the same contents will be returned.
      Specified by:
      getDisjunctBodies in interface PQuery
    • ensureInitialized

      public final void ensureInitialized()
      Description copied from interface: PQuery
      If the query definition is uninitialized, initializes it.
      Specified by:
      ensureInitialized in interface PQuery
    • setBodies

      protected final void setBodies(Set<PBody> bodies)
    • doGetContainedBodies

      protected abstract Set<PBody> doGetContainedBodies()
      Creates and returns the bodies of the query. If recalled again, a new instance is created.
      Returns:
      Throws:
      InterpreterRuntimeException
    • toString

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

      public PVisibility getVisibility()
      Description copied from interface: PQueryHeader
      Returns the visibility information about the query.
      Specified by:
      getVisibility in interface PQueryHeader
      Since:
      2.0