MtasCQLParserSentencePartCondition.java.html
9.88 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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<?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>MtasCQLParserSentencePartCondition.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">MtasCQLParserSentencePartCondition.java</span></div><h1>MtasCQLParserSentencePartCondition.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 MtasCQLParserSentencePartCondition.
*/
public class MtasCQLParserSentencePartCondition {
/** The first sentence. */
<span class="fc" id="L12"> private MtasCQLParserSentenceCondition firstSentence = null;</span>
/** The first basic sentence. */
<span class="fc" id="L15"> private MtasCQLParserBasicSentenceCondition firstBasicSentence = null;</span>
/** The first minimum occurence. */
private int firstMinimumOccurence;
/** The first maximum occurence. */
private int firstMaximumOccurence;
/** The first optional. */
private boolean firstOptional;
/** The second sentence part. */
<span class="fc" id="L27"> MtasCQLParserSentencePartCondition secondSentencePart = null;</span>
/** The or operator. */
<span class="fc" id="L30"> private boolean orOperator = false;</span>
/** The full condition. */
<span class="fc" id="L33"> private MtasCQLParserSentenceCondition fullCondition = null;</span>
/** The ignore clause. */
private MtasSpanQuery ignoreClause;
/** The maximum ignore length. */
private Integer maximumIgnoreLength;
/**
* Instantiates a new mtas CQL parser sentence part condition.
*
* @param bs the bs
* @param ignore the ignore
* @param maximumIgnoreLength the maximum ignore length
*/
public MtasCQLParserSentencePartCondition(
MtasCQLParserBasicSentenceCondition bs, MtasSpanQuery ignore,
<span class="fc" id="L50"> Integer maximumIgnoreLength) {</span>
<span class="fc" id="L51"> firstMinimumOccurence = 1;</span>
<span class="fc" id="L52"> firstMaximumOccurence = 1;</span>
<span class="fc" id="L53"> firstOptional = false;</span>
<span class="fc" id="L54"> firstBasicSentence = bs;</span>
<span class="fc" id="L55"> this.ignoreClause = ignore;</span>
<span class="fc" id="L56"> this.maximumIgnoreLength = maximumIgnoreLength;</span>
<span class="fc" id="L57"> }</span>
/**
* Instantiates a new mtas CQL parser sentence part condition.
*
* @param s the s
* @param ignore the ignore
* @param maximumIgnoreLength the maximum ignore length
*/
public MtasCQLParserSentencePartCondition(MtasCQLParserSentenceCondition s,
<span class="fc" id="L67"> MtasSpanQuery ignore, Integer maximumIgnoreLength) {</span>
<span class="fc" id="L68"> firstMinimumOccurence = 1;</span>
<span class="fc" id="L69"> firstMaximumOccurence = 1;</span>
<span class="fc" id="L70"> firstOptional = false;</span>
<span class="fc" id="L71"> firstSentence = s;</span>
<span class="fc" id="L72"> this.ignoreClause = ignore;</span>
<span class="fc" id="L73"> this.maximumIgnoreLength = maximumIgnoreLength;</span>
<span class="fc" id="L74"> }</span>
/**
* Sets the first occurence.
*
* @param min the min
* @param max the max
* @throws ParseException the parse exception
*/
public void setFirstOccurence(int min, int max) throws ParseException {
<span class="pc bpc" id="L84" title="1 of 2 branches missed."> if (fullCondition == null) {</span>
<span class="pc bpc" id="L85" title="3 of 6 branches missed."> if ((min < 0) || (min > max) || (max < 1)) {</span>
<span class="nc" id="L86"> throw new ParseException("Illegal number {" + min + "," + max + "}");</span>
}
<span class="fc bfc" id="L88" title="All 2 branches covered."> if (min == 0) {</span>
<span class="fc" id="L89"> firstOptional = true;</span>
}
<span class="fc" id="L91"> firstMinimumOccurence = Math.max(1, min);</span>
<span class="fc" id="L92"> firstMaximumOccurence = max;</span>
} else {
<span class="nc" id="L94"> throw new ParseException("fullCondition already generated");</span>
}
<span class="fc" id="L96"> }</span>
/**
* Sets the first optional.
*
* @param status the new first optional
* @throws ParseException the parse exception
*/
public void setFirstOptional(boolean status) throws ParseException {
<span class="nc bnc" id="L105" title="All 2 branches missed."> if (fullCondition == null) {</span>
<span class="nc" id="L106"> firstOptional = status;</span>
} else {
<span class="nc" id="L108"> throw new ParseException("fullCondition already generated");</span>
}
<span class="nc" id="L110"> }</span>
/**
* Sets the or.
*
* @param status the new or
* @throws ParseException the parse exception
*/
public void setOr(boolean status) throws ParseException {
<span class="pc bpc" id="L119" title="1 of 2 branches missed."> if (fullCondition == null) {</span>
<span class="fc" id="L120"> orOperator = status;</span>
} else {
<span class="nc" id="L122"> throw new ParseException("fullCondition already generated");</span>
}
<span class="fc" id="L124"> }</span>
/**
* Sets the second part.
*
* @param sp the new second part
* @throws ParseException the parse exception
*/
public void setSecondPart(MtasCQLParserSentencePartCondition sp)
throws ParseException {
<span class="pc bpc" id="L134" title="1 of 2 branches missed."> if (fullCondition == null) {</span>
<span class="fc" id="L135"> secondSentencePart = sp;</span>
} else {
<span class="nc" id="L137"> throw new ParseException("fullCondition already generated");</span>
}
<span class="fc" id="L139"> }</span>
/**
* Creates the full sentence.
*
* @return the mtas CQL parser sentence condition
* @throws ParseException the parse exception
*/
public MtasCQLParserSentenceCondition createFullSentence()
throws ParseException {
<span class="pc bpc" id="L149" title="1 of 2 branches missed."> if (fullCondition == null) {</span>
<span class="fc bfc" id="L150" title="All 2 branches covered."> if (secondSentencePart == null) {</span>
<span class="fc bfc" id="L151" title="All 2 branches covered."> if (firstBasicSentence != null) {</span>
<span class="fc" id="L152"> fullCondition = new MtasCQLParserSentenceCondition(firstBasicSentence,</span>
ignoreClause, maximumIgnoreLength);
} else {
<span class="fc" id="L156"> fullCondition = firstSentence;</span>
}
<span class="fc" id="L158"> fullCondition.setOccurence(firstMinimumOccurence,</span>
firstMaximumOccurence);
<span class="fc bfc" id="L160" title="All 2 branches covered."> if (firstOptional) {</span>
<span class="fc" id="L161"> fullCondition.setOptional(firstOptional);</span>
}
<span class="fc" id="L163"> return fullCondition;</span>
} else {
<span class="fc bfc" id="L165" title="All 2 branches covered."> if (!orOperator) {</span>
<span class="fc bfc" id="L166" title="All 2 branches covered."> if (firstBasicSentence != null) {</span>
<span class="fc" id="L167"> firstBasicSentence.setOccurence(firstMinimumOccurence,</span>
firstMaximumOccurence);
<span class="fc" id="L169"> firstBasicSentence.setOptional(firstOptional);</span>
<span class="fc" id="L170"> fullCondition = new MtasCQLParserSentenceCondition(</span>
firstBasicSentence, ignoreClause, maximumIgnoreLength);
} else {
<span class="fc" id="L173"> firstSentence.setOccurence(firstMinimumOccurence,</span>
firstMaximumOccurence);
<span class="fc" id="L175"> firstSentence.setOptional(firstOptional);</span>
<span class="fc" id="L176"> fullCondition = new MtasCQLParserSentenceCondition(firstSentence,</span>
ignoreClause, maximumIgnoreLength);
}
<span class="fc" id="L179"> fullCondition.addSentenceToEndLatestSequence(</span>
<span class="fc" id="L180"> secondSentencePart.createFullSentence());</span>
} else {
<span class="fc" id="L182"> MtasCQLParserSentenceCondition sentence = secondSentencePart</span>
<span class="fc" id="L183"> .createFullSentence();</span>
<span class="fc bfc" id="L184" title="All 2 branches covered."> if (firstBasicSentence != null) {</span>
<span class="fc" id="L185"> sentence.addSentenceAsFirstOption(</span>
new MtasCQLParserSentenceCondition(firstBasicSentence,
ignoreClause, maximumIgnoreLength));
} else {
<span class="fc" id="L189"> sentence.addSentenceAsFirstOption(firstSentence);</span>
}
<span class="fc" id="L191"> fullCondition = sentence;</span>
}
<span class="fc" id="L193"> return fullCondition;</span>
}
} else {
<span class="nc" id="L196"> return fullCondition;</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>