All Downloads are FREE. Search and download functionalities are using the official Maven repository.

querqy.model.BooleanQuery Maven / Gradle / Ivy

There is a newer version: 3.18.1
Show newest version
/**
 * 
 */
package querqy.model;

/**
 * @author René Kriegler, @renekrie
 *
 */
public class BooleanQuery extends SubQuery implements DisjunctionMaxClause,
      BooleanClause, BooleanParent, QuerqyQuery {

   public BooleanQuery(final BooleanParent parentQuery, final Occur occur, final boolean generated) {
      super(parentQuery, occur, generated);
   }

   @Override
   public  T accept(final NodeVisitor visitor) {
      return visitor.visit(this);
   }

   @Override
   public String toString() {
      return "BooleanQuery [occur=" + occur
            + ", clauses=" + clauses + "]";
   }

   @Override
   public BooleanQuery clone(final BooleanParent newParent) {
       return clone(newParent, this.occur, this.generated);
   }

   @Override
   public BooleanQuery clone(final DisjunctionMaxQuery newParent, boolean generated) {
      return clone((BooleanParent) newParent, generated);
   }

   @Override
   public BooleanClause clone(final BooleanQuery newParent) {
      return clone((BooleanParent) newParent);
   }

   @Override
   public BooleanQuery clone(final BooleanParent newParent, final boolean generated) {
       return clone(newParent, this.occur, generated);
   }

   @Override
   public BooleanClause clone(final BooleanQuery newParent, final boolean generated) {
       return clone((BooleanParent) newParent, generated);
   }

    @Override
    public BooleanClause clone(final BooleanQuery newParent, final Occur occur) {
        return clone((BooleanParent) newParent, occur, this.generated);
    }

    @Override
    public BooleanClause clone(final BooleanQuery newParent, final Occur occur, final boolean generated) {
        return clone((BooleanParent) newParent, occur, generated);
    }

    public BooleanQuery clone(final BooleanParent newParent, final Occur occur, final boolean generated) {
        final BooleanQuery bq = new BooleanQuery(newParent, occur, generated);
        for (final BooleanClause clause : clauses) {
            bq.addClause(clause.clone(bq, generated));
        }
        return bq;
    }


    @Override
    public void removeClauseAndTraverseTree(final BooleanClause clause) {
        super.removeClause(clause);

        if (this.clauses.isEmpty() && this.getParent() != null) {
            this.getParent().removeClauseAndTraverseTree(this);
        }
    }

    @Override
    public void removeClauseAndTraverseTree(final BooleanQuery clause) {
        removeClauseAndTraverseTree((BooleanClause) clause);
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy