MtasExtendedSpanAndQuery.java.html 4.28 KB
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>MtasExtendedSpanAndQuery.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">MTAS</a> &gt; <a href="index.source.html" class="el_package">mtas.search.spans.util</a> &gt; <span class="el_source">MtasExtendedSpanAndQuery.java</span></div><h1>MtasExtendedSpanAndQuery.java</h1><pre class="source lang-java linenums">package mtas.search.spans.util;

import java.util.HashSet;
import java.util.Iterator;
import org.apache.lucene.search.spans.SpanNearQuery;
import org.apache.lucene.search.spans.SpanQuery;

/**
 * The Class MtasExtendedSpanAndQuery.
 */
public class MtasExtendedSpanAndQuery extends SpanNearQuery {

  /** The local clauses. */
  private HashSet&lt;SpanQuery&gt; localClauses;

  /**
   * Instantiates a new mtas extended span and query.
   *
   * @param clauses the clauses
   */
  public MtasExtendedSpanAndQuery(SpanQuery... clauses) {
<span class="fc" id="L22">    super(clauses, -1 * (clauses.length - 1), false);</span>
<span class="fc" id="L23">    this.localClauses = new HashSet&lt;&gt;();</span>
<span class="fc bfc" id="L24" title="All 2 branches covered.">    for (SpanQuery clause : clauses) {</span>
<span class="fc" id="L25">      this.localClauses.add(clause);</span>
    }
<span class="fc" id="L27">  }</span>

  /*
   * (non-Javadoc)
   * 
   * @see
   * org.apache.lucene.search.spans.SpanNearQuery#toString(java.lang.String)
   */
  @Override
  public String toString(String field) {
<span class="nc" id="L37">    StringBuilder buffer = new StringBuilder();</span>
<span class="nc" id="L38">    buffer.append(this.getClass().getSimpleName() + &quot;([&quot;);</span>
<span class="nc" id="L39">    Iterator&lt;SpanQuery&gt; i = localClauses.iterator();</span>
<span class="nc bnc" id="L40" title="All 2 branches missed.">    while (i.hasNext()) {</span>
<span class="nc" id="L41">      SpanQuery clause = i.next();</span>
<span class="nc" id="L42">      buffer.append(clause.toString(field));</span>
<span class="nc bnc" id="L43" title="All 2 branches missed.">      if (i.hasNext()) {</span>
<span class="nc" id="L44">        buffer.append(&quot;, &quot;);</span>
      }
<span class="nc" id="L46">    }</span>
<span class="nc" id="L47">    buffer.append(&quot;])&quot;);</span>
<span class="nc" id="L48">    return buffer.toString();</span>
  }

  /*
   * (non-Javadoc)
   * 
   * @see org.apache.lucene.search.spans.SpanNearQuery#equals(java.lang.Object)
   */
  @Override
  public boolean equals(Object obj) {
<span class="pc bpc" id="L58" title="1 of 2 branches missed.">    if (this == obj)</span>
<span class="nc" id="L59">      return true;</span>
<span class="pc bpc" id="L60" title="1 of 2 branches missed.">    if (obj == null)</span>
<span class="nc" id="L61">      return false;</span>
<span class="pc bpc" id="L62" title="1 of 2 branches missed.">    if (getClass() != obj.getClass())</span>
<span class="nc" id="L63">      return false;</span>
<span class="fc" id="L64">    final MtasExtendedSpanAndQuery that = (MtasExtendedSpanAndQuery) obj;</span>
<span class="fc" id="L65">    return localClauses.equals(that.localClauses);</span>
  }

  /*
   * (non-Javadoc)
   * 
   * @see org.apache.lucene.search.spans.SpanNearQuery#hashCode()
   */
  @Override
  public int hashCode() {
<span class="nc" id="L75">    int h = this.getClass().getSimpleName().hashCode();</span>
<span class="nc" id="L76">    h = (h * 7) ^ super.hashCode();</span>
<span class="nc" id="L77">    return h;</span>
  }

}
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.7.9.201702052155</span></div></body></html>