1 package com.atlassian.user.search.query;
2
3 public class AbstractSingleTermQuery implements TermQuery
4 {
5 protected String matchingRule;
6 protected boolean matchingSubstring;
7 protected String term;
8
9 public AbstractSingleTermQuery(String term)
10 {
11 this.term = term;
12 }
13
14 public AbstractSingleTermQuery(String term, String matchingRule)
15 {
16 this.term = term;
17
18 if (matchingRule != TermQuery.SUBSTRING_CONTAINS &&
19 matchingRule != TermQuery.SUBSTRING_ENDS_WITH &&
20 matchingRule != TermQuery.SUBSTRING_STARTS_WITH)
21 throw new IllegalArgumentException("Invalid substring matching rule - please use " +
22 Query.class.getName() + "SUBSTRING_CONTAINS, SUBSTRING_ENDS_WITH, or " +
23 "SUBSTRING_STARTS_WITH");
24
25 this.matchingRule = matchingRule;
26 this.matchingSubstring = true;
27 }
28
29 /**
30 * @return a String holding the system indepdent value of the term to match for equality.
31 * <p/>
32 * For example, in a ColourQuery this term might be 'red' but, when rendered, would be
33 * represented as "select colour from colour_table where colour == 'red'"
34 */
35 public String getTerm()
36 {
37 return term;
38 }
39
40 public String getMatchingRule()
41 {
42 return matchingRule;
43 }
44
45 public boolean isMatchingSubstring()
46 {
47 return matchingSubstring;
48 }
49 }