MtasDataItem.java.html 6.65 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="../.resources/report.css" type="text/css"/><link rel="shortcut icon" href="../.resources/report.gif" type="image/gif"/><title>MtasDataItem.java</title><link rel="stylesheet" href="../.resources/prettify.css" type="text/css"/><script type="text/javascript" src="../.resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../.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.codec.util.collector</a> &gt; <span class="el_source">MtasDataItem.java</span></div><h1>MtasDataItem.java</h1><pre class="source lang-java linenums">package mtas.codec.util.collector;

import java.io.IOException;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;

/**
 * The Class MtasDataItem.
 *
 * @param &lt;T1&gt;
 *          the generic type
 * @param &lt;T2&gt;
 *          the generic type
 */
public abstract class MtasDataItem&lt;T1 extends Number &amp; Comparable&lt;T1&gt;, T2 extends Number &amp; Comparable&lt;T2&gt;&gt;
    implements Serializable, Comparable&lt;MtasDataItem&lt;T1, T2&gt;&gt; {

  /** The Constant serialVersionUID. */
  private static final long serialVersionUID = 1L;

  /** The sub. */
  protected MtasDataCollector&lt;?, ?&gt; sub;

  /** The stats items. */
  protected Set&lt;String&gt; statsItems;

  /** The sort direction. */
  protected String sortType;
  protected String sortDirection;

  /** The error number. */
  protected int errorNumber;

  /** The error list. */
  protected Map&lt;String, Integer&gt; errorList;

  /** The comparable sort value. */
  protected MtasDataItemNumberComparator&lt;?&gt; comparableSortValue;

  /** The recompute comparable sort value. */
  protected boolean recomputeComparableSortValue;

  /** The source number. */
  protected int sourceNumber;

  /**
   * Instantiates a new mtas data item.
   *
   * @param sub
   *          the sub
   * @param statsItems
   *          the stats items
   * @param sortType
   *          the sort type
   * @param sortDirection
   *          the sort direction
   * @param errorNumber
   *          the error number
   * @param errorList
   *          the error list
   * @param sourceNumber
   *          the source number
   */
  public MtasDataItem(MtasDataCollector&lt;?, ?&gt; sub, Set&lt;String&gt; statsItems,
      String sortType, String sortDirection, int errorNumber,
<span class="fc" id="L69">      Map&lt;String, Integer&gt; errorList, int sourceNumber) {</span>
<span class="fc" id="L70">    this.sub = sub;</span>
<span class="fc" id="L71">    this.statsItems = statsItems;</span>
<span class="fc" id="L72">    this.sortType = sortType;</span>
<span class="fc" id="L73">    this.sortDirection = sortDirection;</span>
<span class="fc" id="L74">    this.errorNumber = errorNumber;</span>
<span class="fc" id="L75">    this.errorList = errorList;</span>
<span class="fc" id="L76">    this.sourceNumber = sourceNumber;</span>
<span class="fc" id="L77">    this.comparableSortValue = null;</span>
<span class="fc" id="L78">    this.recomputeComparableSortValue = true;</span>
<span class="fc" id="L79">  }</span>

  /**
   * Adds the.
   *
   * @param newItem
   *          the new item
   * @throws IOException
   *           Signals that an I/O exception has occurred.
   */
  public abstract void add(MtasDataItem&lt;T1, T2&gt; newItem) throws IOException;

  /**
   * Rewrite.
   *
   * @param showDebugInfo
   *          the show debug info
   * @return the map
   * @throws IOException
   *           Signals that an I/O exception has occurred.
   */
  public abstract Map&lt;String, Object&gt; rewrite(boolean showDebugInfo)
      throws IOException;

  /**
   * Gets the sub.
   *
   * @return the sub
   */
  public MtasDataCollector&lt;?, ?&gt; getSub() {
<span class="nc" id="L109">    return sub;</span>
  }

  /**
   * Gets the compare value type.
   *
   * @return the compare value type
   * @throws IOException
   *           Signals that an I/O exception has occurred.
   */
  protected abstract int getCompareValueType() throws IOException;

  /**
   * Compute comparable value.
   */
  private void computeComparableValue() {
<span class="fc" id="L125">    recomputeComparableSortValue = false;</span>
    try {
<span class="fc" id="L127">      int type = getCompareValueType();</span>
<span class="pc bpc" id="L128" title="3 of 4 branches missed.">      switch (type) {</span>
      case 0:
<span class="nc" id="L130">        comparableSortValue = getCompareValue0();</span>
<span class="nc" id="L131">        break;</span>
      case 1:
<span class="fc" id="L133">        comparableSortValue = getCompareValue1();</span>
<span class="fc" id="L134">        break;</span>
      case 2:
<span class="nc" id="L136">        comparableSortValue = getCompareValue2();</span>
<span class="nc" id="L137">        break;</span>
      default:
<span class="nc" id="L139">        comparableSortValue = null;</span>
        break;
      }
<span class="nc" id="L142">    } catch (IOException e) {</span>
<span class="nc" id="L143">      comparableSortValue = null;</span>
<span class="fc" id="L144">    }</span>
<span class="fc" id="L145">  }</span>

  /**
   * Gets the comparable value.
   *
   * @return the comparable value
   */
  protected final MtasDataItemNumberComparator&lt;?&gt; getComparableValue() {
<span class="fc bfc" id="L153" title="All 2 branches covered.">    if (recomputeComparableSortValue) {</span>
<span class="fc" id="L154">      computeComparableValue();</span>
    }
<span class="fc" id="L156">    return comparableSortValue;</span>
  }

  /**
   * Gets the compare value0.
   *
   * @return the compare value0
   */
  protected abstract MtasDataItemNumberComparator&lt;Long&gt; getCompareValue0();

  /**
   * Gets the compare value1.
   *
   * @return the compare value1
   */
  protected abstract MtasDataItemNumberComparator&lt;T1&gt; getCompareValue1();

  /**
   * Gets the compare value2.
   *
   * @return the compare value2
   */
  protected abstract MtasDataItemNumberComparator&lt;T2&gt; getCompareValue2();

  /**
   * The Class NumberComparator.
   *
   * @param &lt;T&gt;
   *          the generic type
   */

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