ConstTermsQuery.java

  1. /*
  2.  *  TermQuery.java
  3.  *
  4.  *  Copyright (c) 2007-2011, The University of Sheffield.
  5.  *
  6.  *  This file is part of GATE Mímir (see http://gate.ac.uk/family/mimir.html),
  7.  *  and is free software, licenced under the GNU Lesser General Public License,
  8.  *  Version 3, June 2007 (also included with this distribution as file
  9.  *  LICENCE-LGPL3.html).
  10.  *
  11.  *  Valentin Tablan, 13 Aug 2013
  12.  *
  13.  *  $Id: ConstTermsQuery.java 16782 2013-08-14 08:40:44Z valyt $
  14.  */
  15. package gate.mimir.search.terms;

  16. import gate.mimir.search.QueryEngine;

  17. import java.io.IOException;

  18. /**
  19.  * A terms query that returns a pre-defined (constant) terms result set.
  20.  *
  21.  * One example usage for this is inserting externally computed terms result
  22.  * sets as operands into {@link CompoundTermsQuery}s.
  23.  */
  24. public class ConstTermsQuery implements TermsQuery {
  25.  
  26.   private static final long serialVersionUID = -1993516325057279128L;
  27.  
  28.   /**
  29.    * The {@link TermsResultSet} to be returned upon "execution".
  30.    */
  31.   protected TermsResultSet trs;
  32.  
  33.  
  34.  
  35.   /**
  36.    * Constructs a new instance of {@link ConstTermsQuery}.
  37.    * @param trs the terms result set to be returned by the constant terms query.
  38.    */
  39.   public ConstTermsQuery(TermsResultSet trs) {
  40.     this.trs = trs;
  41.   }



  42.   @Override
  43.   /**
  44.    * Returns the terms result set provided at construction time. This method
  45.    * performs no calculation.
  46.    */
  47.   public TermsResultSet execute(QueryEngine engine) throws IOException {
  48.     return trs;
  49.   }
  50. }