MtasCQLParserGroupFullCondition.java.html 6.96 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>MtasCQLParserGroupFullCondition.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.parser.cql.util</a> &gt; <span class="el_source">MtasCQLParserGroupFullCondition.java</span></div><h1>MtasCQLParserGroupFullCondition.java</h1><pre class="source lang-java linenums">package mtas.parser.cql.util;

import mtas.parser.cql.ParseException;
import mtas.search.spans.MtasSpanEndQuery;
import mtas.search.spans.MtasSpanStartQuery;
import mtas.search.spans.util.MtasSpanQuery;

/**
 * The Class MtasCQLParserGroupFullCondition.
 */
public class MtasCQLParserGroupFullCondition
    extends MtasCQLParserBasicSentencePartCondition {

  /** The Constant GROUP_FULL. */
  public static final String GROUP_FULL = &quot;full&quot;;

  /** The Constant GROUP_START. */
  public static final String GROUP_START = &quot;start&quot;;

  /** The Constant GROUP_END. */
  public static final String GROUP_END = &quot;end&quot;;

  /** The group condition. */
  private MtasCQLParserGroupCondition groupCondition;

  /** The type. */
  private String type;

  /**
   * Instantiates a new mtas CQL parser group full condition.
   *
   * @param condition the condition
   * @param type the type
   */
  public MtasCQLParserGroupFullCondition(MtasCQLParserGroupCondition condition,
<span class="fc" id="L36">      String type) {</span>
<span class="fc" id="L37">    minimumOccurence = 1;</span>
<span class="fc" id="L38">    maximumOccurence = 1;</span>
<span class="fc" id="L39">    optional = false;</span>
<span class="fc" id="L40">    not = false;</span>
<span class="fc" id="L41">    groupCondition = condition;</span>
<span class="fc bfc" id="L42" title="All 2 branches covered.">    if (type.equals(GROUP_START)) {</span>
<span class="fc" id="L43">      this.type = GROUP_START;</span>
<span class="fc bfc" id="L44" title="All 2 branches covered.">    } else if (type.equals(GROUP_END)) {</span>
<span class="fc" id="L45">      this.type = GROUP_END;</span>
    } else {
<span class="fc" id="L47">      this.type = GROUP_FULL;</span>
    }
<span class="fc" id="L49">  }</span>

  /**
   * Gets the condition.
   *
   * @return the condition
   */
  public MtasCQLParserGroupCondition getCondition() {
<span class="nc" id="L57">    return groupCondition;</span>
  }

  /*
   * (non-Javadoc)
   * 
   * @see mtas.parser.cql.util.MtasCQLParserBasicSentencePartCondition#
   * getMinimumOccurence()
   */
  @Override
  public int getMinimumOccurence() {
<span class="fc" id="L68">    return minimumOccurence;</span>
  }

  /*
   * (non-Javadoc)
   * 
   * @see mtas.parser.cql.util.MtasCQLParserBasicSentencePartCondition#
   * getMaximumOccurence()
   */
  @Override
  public int getMaximumOccurence() {
<span class="fc" id="L79">    return maximumOccurence;</span>
  }

  /*
   * (non-Javadoc)
   * 
   * @see
   * mtas.parser.cql.util.MtasCQLParserBasicSentencePartCondition#setOccurence(
   * int, int)
   */
  @Override
  public void setOccurence(int min, int max) throws ParseException {
<span class="pc bpc" id="L91" title="3 of 6 branches missed.">    if ((min &lt; 0) || (min &gt; max) || (max &lt; 1)) {</span>
<span class="nc" id="L92">      throw new ParseException(&quot;Illegal number {&quot; + min + &quot;,&quot; + max + &quot;}&quot;);</span>
    }
<span class="pc bpc" id="L94" title="1 of 2 branches missed.">    if (min == 0) {</span>
<span class="nc" id="L95">      optional = true;</span>
    }
<span class="fc" id="L97">    minimumOccurence = Math.max(1, min);</span>
<span class="fc" id="L98">    maximumOccurence = max;</span>
<span class="fc" id="L99">  }</span>

  /*
   * (non-Javadoc)
   * 
   * @see
   * mtas.parser.cql.util.MtasCQLParserBasicSentencePartCondition#isOptional()
   */
  @Override
  public boolean isOptional() {
<span class="fc" id="L109">    return optional;</span>
  }

  /*
   * (non-Javadoc)
   * 
   * @see
   * mtas.parser.cql.util.MtasCQLParserBasicSentencePartCondition#setOptional(
   * boolean)
   */
  @Override
  public void setOptional(boolean status) {
<span class="nc" id="L121">    optional = status;</span>
<span class="nc" id="L122">  }</span>

  /*
   * (non-Javadoc)
   * 
   * @see
   * mtas.parser.cql.util.MtasCQLParserBasicSentencePartCondition#getQuery()
   */
  @Override
  public MtasSpanQuery getQuery() throws ParseException {
<span class="fc bfc" id="L132" title="All 2 branches covered.">    if (type.equals(MtasCQLParserGroupFullCondition.GROUP_START)) {</span>
<span class="fc" id="L133">      return new MtasSpanStartQuery(groupCondition.getQuery());</span>
<span class="fc bfc" id="L134" title="All 2 branches covered.">    } else if (type.equals(MtasCQLParserGroupFullCondition.GROUP_END)) {</span>
<span class="fc" id="L135">      return new MtasSpanEndQuery(groupCondition.getQuery());</span>
    } else {
<span class="fc" id="L137">      return groupCondition.getQuery();</span>
    }
  }

  /*
   * (non-Javadoc)
   * 
   * @see java.lang.Object#equals(java.lang.Object)
   */
  @Override
  public boolean equals(Object object) {
<span class="pc bpc" id="L148" title="1 of 2 branches missed.">    if (object == null)</span>
<span class="nc" id="L149">      return false;</span>
<span class="fc bfc" id="L150" title="All 2 branches covered.">    if (object instanceof MtasCQLParserGroupFullCondition) {</span>
<span class="fc" id="L151">      MtasCQLParserGroupFullCondition word = (MtasCQLParserGroupFullCondition) object;</span>
<span class="pc bpc" id="L152" title="1 of 2 branches missed.">      return groupCondition.equals(word.groupCondition)</span>
<span class="pc bpc" id="L153" title="1 of 2 branches missed.">          &amp;&amp; type.equals(word.type);</span>
    } else {
<span class="fc" id="L155">      return false;</span>
    }
  }

  /*
   * (non-Javadoc)
   * 
   * @see java.lang.Object#hashCode()
   */
  @Override
  public int hashCode() {
<span class="nc" id="L166">    int h = this.getClass().getSimpleName().hashCode();</span>
<span class="nc" id="L167">    h = (h * 5) ^ groupCondition.hashCode();</span>
<span class="nc" id="L168">    h = (h * 7) ^ type.hashCode();</span>
<span class="nc" id="L169">    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>