MtasCQLParserBasicSentencePartCondition.java.html
5.2 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
<?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>MtasCQLParserBasicSentencePartCondition.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.cql.util</a> > <span class="el_source">MtasCQLParserBasicSentencePartCondition.java</span></div><h1>MtasCQLParserBasicSentencePartCondition.java</h1><pre class="source lang-java linenums">package mtas.parser.cql.util;
import mtas.parser.cql.ParseException;
import mtas.search.spans.util.MtasSpanQuery;
/**
* The Class MtasCQLParserBasicSentencePartCondition.
*/
<span class="fc" id="L9">public abstract class MtasCQLParserBasicSentencePartCondition {</span>
/** The minimum occurence. */
protected int minimumOccurence;
/** The maximum occurence. */
protected int maximumOccurence;
/** The optional. */
protected boolean optional;
/** The not. */
protected boolean not;
/**
* Gets the query.
*
* @return the query
* @throws ParseException the parse exception
*/
public abstract MtasSpanQuery getQuery() throws ParseException;
/**
* Gets the minimum occurence.
*
* @return the minimum occurence
*/
public int getMinimumOccurence() {
<span class="fc" id="L37"> return minimumOccurence;</span>
}
/**
* Gets the maximum occurence.
*
* @return the maximum occurence
*/
public int getMaximumOccurence() {
<span class="fc" id="L46"> return maximumOccurence;</span>
}
/**
* Sets the occurence.
*
* @param min the min
* @param max the max
* @throws ParseException the parse exception
*/
public void setOccurence(int min, int max) throws ParseException {
<span class="pc bpc" id="L57" title="3 of 6 branches missed."> if ((min < 0) || (min > max) || (max < 1)) {</span>
<span class="nc" id="L58"> throw new ParseException("Illegal number {" + min + "," + max + "}");</span>
}
<span class="fc bfc" id="L60" title="All 2 branches covered."> if (min == 0) {</span>
<span class="fc" id="L61"> optional = true;</span>
}
<span class="fc" id="L63"> minimumOccurence = Math.max(1, min);</span>
<span class="fc" id="L64"> maximumOccurence = max;</span>
<span class="fc" id="L65"> }</span>
/**
* Checks if is optional.
*
* @return true, if is optional
*/
public boolean isOptional() {
<span class="fc" id="L73"> return optional;</span>
}
/**
* Sets the optional.
*
* @param status the new optional
*/
public void setOptional(boolean status) {
<span class="fc" id="L82"> optional = status;</span>
<span class="fc" id="L83"> }</span>
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
<span class="nc" id="L92"> return toString("", "");</span>
}
/**
* To string.
*
* @param firstIndent the first indent
* @param indent the indent
* @return the string
*/
public String toString(String firstIndent, String indent) {
<span class="nc" id="L103"> String text = "";</span>
<span class="nc" id="L104"> text += firstIndent + "PART";</span>
<span class="nc bnc" id="L105" title="All 2 branches missed."> if (optional) {</span>
<span class="nc" id="L106"> text += " OPTIONAL";</span>
}
<span class="nc bnc" id="L108" title="All 4 branches missed."> if ((minimumOccurence > 1) || (minimumOccurence != maximumOccurence)) {</span>
<span class="nc bnc" id="L109" title="All 2 branches missed."> if (minimumOccurence != maximumOccurence) {</span>
<span class="nc" id="L110"> text += " {" + minimumOccurence + "," + maximumOccurence + "}";</span>
} else {
<span class="nc" id="L112"> text += " {" + minimumOccurence + "}";</span>
}
}
try {
<span class="nc" id="L116"> text += "\n" + indent + "- Query: "</span>
<span class="nc" id="L117"> + getQuery().toString(getQuery().getField());</span>
<span class="nc" id="L118"> } catch (ParseException e) {</span>
<span class="nc" id="L119"> text += "\n" + indent + "- Query: " + e.getMessage();</span>
<span class="nc" id="L120"> }</span>
<span class="nc" id="L121"> text += "\n";</span>
<span class="nc" id="L122"> return text;</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>