<?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>MtasFunctionParserFunction.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> > <a href="index.source.html" class="el_package">mtas.parser.function.util</a> > <span class="el_source">MtasFunctionParserFunction.java</span></div><h1>MtasFunctionParserFunction.java</h1><pre class="source lang-java linenums">package mtas.parser.function.util; import java.io.IOException; import java.util.HashSet; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import mtas.codec.util.CodecUtil; import mtas.parser.function.ParseException; /** * The Class MtasFunctionParserFunction. */ <span class="fc" id="L15">public abstract class MtasFunctionParserFunction {</span> /** The log. */ <span class="fc" id="L18"> private static Log log = LogFactory.getLog(MtasFunctionParserFunction.class);</span> /** The parser doubles. */ protected MtasFunctionParserFunction[] parserDoubles; /** The parser longs. */ protected MtasFunctionParserFunction[] parserLongs; /** The constant doubles. */ protected Double[] constantDoubles; /** The constant longs. */ protected long[] constantLongs; /** The data type. */ <span class="fc" id="L33"> protected String dataType = null;</span> /** The sum rule. */ <span class="fc" id="L36"> protected boolean sumRule = false;</span> /** The need positions. */ <span class="fc" id="L39"> protected boolean needPositions = false;</span> /** The degree. */ <span class="fc" id="L42"> protected Integer degree = null;</span> /** The need argument. */ <span class="fc" id="L45"> protected HashSet<Integer> needArgument = new HashSet<Integer>();</span> /** The defined. */ <span class="fc" id="L48"> private boolean defined = false;</span> /** * Gets the response. * * @param args the args * @param n the n * @return the response */ public final MtasFunctionParserFunctionResponse getResponse(long[] args, long n) { <span class="fc bfc" id="L59" title="All 2 branches covered."> if (dataType.equals(CodecUtil.DATA_TYPE_LONG)) {</span> try { <span class="fc" id="L61"> long l = getValueLong(args, n);</span> <span class="fc" id="L62"> return new MtasFunctionParserFunctionResponseLong(l, true);</span> <span class="nc" id="L63"> } catch (IOException e) {</span> <span class="nc" id="L64"> log.debug(e);</span> <span class="nc" id="L65"> return new MtasFunctionParserFunctionResponseLong(0, false);</span> } <span class="pc bpc" id="L67" title="1 of 2 branches missed."> } else if (dataType.equals(CodecUtil.DATA_TYPE_DOUBLE)) {</span> try { <span class="fc" id="L69"> double d = getValueDouble(args, n);</span> <span class="fc" id="L70"> return new MtasFunctionParserFunctionResponseDouble(d, true);</span> <span class="fc" id="L71"> } catch (IOException e) {</span> <span class="fc" id="L72"> log.debug(e);</span> <span class="fc" id="L73"> return new MtasFunctionParserFunctionResponseDouble(0, false);</span> } } else { <span class="nc" id="L76"> return null;</span> } } /** * Gets the value double. * * @param args the args * @param n the n * @return the value double * @throws IOException Signals that an I/O exception has occurred. */ public abstract double getValueDouble(long[] args, long n) throws IOException; /** * Gets the value long. * * @param args the args * @param n the n * @return the value long * @throws IOException Signals that an I/O exception has occurred. */ public abstract long getValueLong(long[] args, long n) throws IOException; /** * Close. * * @throws ParseException the parse exception */ public void close() throws ParseException { <span class="fc" id="L106"> defined = true;</span> <span class="fc" id="L107"> }</span> /** * Gets the type. * * @return the type */ public final String getType() { <span class="fc" id="L115"> return dataType;</span> } /** * Sum rule. * * @return the boolean */ public final Boolean sumRule() { <span class="fc" id="L124"> return sumRule;</span> } /** * Need positions. * * @return the boolean */ public final Boolean needPositions() { <span class="fc" id="L133"> return needPositions;</span> } /** * Need argument. * * @param i the i * @return the boolean */ public final Boolean needArgument(int i) { <span class="nc" id="L143"> return needArgument.contains(i);</span> } /** * Need arguments number. * * @return the int */ public final int needArgumentsNumber() { <span class="fc" id="L152"> int number = 0;</span> <span class="fc bfc" id="L153" title="All 2 branches covered."> for (int i : needArgument) {</span> <span class="fc" id="L154"> number = Math.max(number, (i + 1));</span> <span class="fc" id="L155"> }</span> <span class="fc" id="L156"> return number;</span> } /** * Need argument. * * @return the hash set */ public final HashSet<Integer> needArgument() { <span class="fc" id="L165"> return needArgument;</span> } /** * Defined. * * @return true, if successful */ protected final boolean defined() { <span class="fc" id="L174"> return defined;</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>