MtasFunctionParserFunction.java.html
6.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<?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>