MtasCQLParserGroupFullCondition.java.html
6.89 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
<?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>MtasCQLParserGroupFullCondition.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">MtasCQLParserGroupFullCondition.java</span></div><h1>MtasCQLParserGroupFullCondition.java</h1><pre class="source lang-java linenums">package mtas.parser.cql.util;
import mtas.parser.cql.ParseException;
import mtas.search.spans.MtasSpanEndQuery;
import mtas.search.spans.MtasSpanStartQuery;
import mtas.search.spans.util.MtasSpanQuery;
/**
* The Class MtasCQLParserGroupFullCondition.
*/
public class MtasCQLParserGroupFullCondition
extends MtasCQLParserBasicSentencePartCondition {
/** The Constant GROUP_FULL. */
public static final String GROUP_FULL = "full";
/** The Constant GROUP_START. */
public static final String GROUP_START = "start";
/** The Constant GROUP_END. */
public static final String GROUP_END = "end";
/** The group condition. */
private MtasCQLParserGroupCondition groupCondition;
/** The type. */
private String type;
/**
* Instantiates a new mtas CQL parser group full condition.
*
* @param condition the condition
* @param type the type
*/
public MtasCQLParserGroupFullCondition(MtasCQLParserGroupCondition condition,
<span class="fc" id="L36"> String type) {</span>
<span class="fc" id="L37"> minimumOccurence = 1;</span>
<span class="fc" id="L38"> maximumOccurence = 1;</span>
<span class="fc" id="L39"> optional = false;</span>
<span class="fc" id="L40"> not = false;</span>
<span class="fc" id="L41"> groupCondition = condition;</span>
<span class="fc bfc" id="L42" title="All 2 branches covered."> if (type.equals(GROUP_START)) {</span>
<span class="fc" id="L43"> this.type = GROUP_START;</span>
<span class="fc bfc" id="L44" title="All 2 branches covered."> } else if (type.equals(GROUP_END)) {</span>
<span class="fc" id="L45"> this.type = GROUP_END;</span>
} else {
<span class="fc" id="L47"> this.type = GROUP_FULL;</span>
}
<span class="fc" id="L49"> }</span>
/**
* Gets the condition.
*
* @return the condition
*/
public MtasCQLParserGroupCondition getCondition() {
<span class="nc" id="L57"> return groupCondition;</span>
}
/*
* (non-Javadoc)
*
* @see mtas.parser.cql.util.MtasCQLParserBasicSentencePartCondition#
* getMinimumOccurence()
*/
@Override
public int getMinimumOccurence() {
<span class="fc" id="L68"> return minimumOccurence;</span>
}
/*
* (non-Javadoc)
*
* @see mtas.parser.cql.util.MtasCQLParserBasicSentencePartCondition#
* getMaximumOccurence()
*/
@Override
public int getMaximumOccurence() {
<span class="fc" id="L79"> return maximumOccurence;</span>
}
/*
* (non-Javadoc)
*
* @see
* mtas.parser.cql.util.MtasCQLParserBasicSentencePartCondition#setOccurence(
* int, int)
*/
@Override
public void setOccurence(int min, int max) throws ParseException {
<span class="pc bpc" id="L91" title="3 of 6 branches missed."> if ((min < 0) || (min > max) || (max < 1)) {</span>
<span class="nc" id="L92"> throw new ParseException("Illegal number {" + min + "," + max + "}");</span>
}
<span class="pc bpc" id="L94" title="1 of 2 branches missed."> if (min == 0) {</span>
<span class="nc" id="L95"> optional = true;</span>
}
<span class="fc" id="L97"> minimumOccurence = Math.max(1, min);</span>
<span class="fc" id="L98"> maximumOccurence = max;</span>
<span class="fc" id="L99"> }</span>
/*
* (non-Javadoc)
*
* @see
* mtas.parser.cql.util.MtasCQLParserBasicSentencePartCondition#isOptional()
*/
@Override
public boolean isOptional() {
<span class="fc" id="L109"> return optional;</span>
}
/*
* (non-Javadoc)
*
* @see
* mtas.parser.cql.util.MtasCQLParserBasicSentencePartCondition#setOptional(
* boolean)
*/
@Override
public void setOptional(boolean status) {
<span class="nc" id="L121"> optional = status;</span>
<span class="nc" id="L122"> }</span>
/*
* (non-Javadoc)
*
* @see
* mtas.parser.cql.util.MtasCQLParserBasicSentencePartCondition#getQuery()
*/
@Override
public MtasSpanQuery getQuery() throws ParseException {
<span class="fc bfc" id="L132" title="All 2 branches covered."> if (type.equals(MtasCQLParserGroupFullCondition.GROUP_START)) {</span>
<span class="fc" id="L133"> return new MtasSpanStartQuery(groupCondition.getQuery());</span>
<span class="fc bfc" id="L134" title="All 2 branches covered."> } else if (type.equals(MtasCQLParserGroupFullCondition.GROUP_END)) {</span>
<span class="fc" id="L135"> return new MtasSpanEndQuery(groupCondition.getQuery());</span>
} else {
<span class="fc" id="L137"> return groupCondition.getQuery();</span>
}
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object object) {
<span class="pc bpc" id="L148" title="1 of 2 branches missed."> if (object == null)</span>
<span class="nc" id="L149"> return false;</span>
<span class="fc bfc" id="L150" title="All 2 branches covered."> if (object instanceof MtasCQLParserGroupFullCondition) {</span>
<span class="fc" id="L151"> MtasCQLParserGroupFullCondition word = (MtasCQLParserGroupFullCondition) object;</span>
<span class="pc bpc" id="L152" title="2 of 4 branches missed."> return groupCondition.equals(word.groupCondition) && type.equals(word.type); </span>
} else {
<span class="fc" id="L154"> return false;</span>
}
}
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
<span class="nc" id="L163"> int h = this.getClass().getSimpleName().hashCode();</span>
<span class="nc" id="L164"> h = (h * 5) ^ groupCondition.hashCode();</span>
<span class="nc" id="L165"> h = (h * 7) ^ type.hashCode();</span>
<span class="nc" id="L166"> return h;</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>