1 | /** |
---|
2 | * This software is copyright (c) 2013-2016 by |
---|
3 | * - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) |
---|
4 | * This is free software. You can redistribute it |
---|
5 | * and/or modify it under the terms described in |
---|
6 | * the GNU General Public License v3 of which you |
---|
7 | * should have received a copy. Otherwise you can download |
---|
8 | * it from |
---|
9 | * |
---|
10 | * http://www.gnu.org/licenses/gpl-3.0.txt |
---|
11 | * |
---|
12 | * @copyright Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) |
---|
13 | * |
---|
14 | * @license http://www.gnu.org/licenses/gpl-3.0.txt |
---|
15 | * GNU General Public License v3 |
---|
16 | */ |
---|
17 | package eu.clarin.sru.server.fcs.parser; |
---|
18 | |
---|
19 | |
---|
20 | /** |
---|
21 | * A FCS-QL expression tree SIMPLE WITHIN query node. |
---|
22 | */ |
---|
23 | public class SimpleWithin extends QueryNode { |
---|
24 | /** |
---|
25 | * The within scope. |
---|
26 | */ |
---|
27 | public enum Scope { |
---|
28 | /** |
---|
29 | * sentence scope (small). |
---|
30 | */ |
---|
31 | SENTENCE { |
---|
32 | @Override |
---|
33 | public String toDisplayString() { |
---|
34 | return "Sentence"; |
---|
35 | } |
---|
36 | |
---|
37 | }, |
---|
38 | /** |
---|
39 | * utterance scope (small). |
---|
40 | */ |
---|
41 | UTTERANCE { |
---|
42 | @Override |
---|
43 | public String toDisplayString() { |
---|
44 | return "Utterance"; |
---|
45 | } |
---|
46 | |
---|
47 | }, |
---|
48 | /** |
---|
49 | * paragraph scope (medium). |
---|
50 | */ |
---|
51 | PARAGRAPH { |
---|
52 | @Override |
---|
53 | public String toDisplayString() { |
---|
54 | return "Paragraph"; |
---|
55 | } |
---|
56 | |
---|
57 | }, |
---|
58 | /** |
---|
59 | * turn scope (medium). |
---|
60 | */ |
---|
61 | TURN { |
---|
62 | @Override |
---|
63 | public String toDisplayString() { |
---|
64 | return "Turn"; |
---|
65 | } |
---|
66 | }, |
---|
67 | /** |
---|
68 | * text scope (large). |
---|
69 | */ |
---|
70 | TEXT { |
---|
71 | @Override |
---|
72 | public String toDisplayString() { |
---|
73 | return "Text"; |
---|
74 | } |
---|
75 | }, |
---|
76 | /** |
---|
77 | * session scope (large). |
---|
78 | */ |
---|
79 | SESSION { |
---|
80 | @Override |
---|
81 | public String toDisplayString() { |
---|
82 | return "Session"; |
---|
83 | } |
---|
84 | }; |
---|
85 | |
---|
86 | abstract String toDisplayString(); |
---|
87 | } |
---|
88 | private final Scope scope; |
---|
89 | |
---|
90 | |
---|
91 | /** |
---|
92 | * Constructor. |
---|
93 | * |
---|
94 | * @param scope |
---|
95 | * the scope |
---|
96 | */ |
---|
97 | SimpleWithin(Scope scope) { |
---|
98 | super(QueryNodeType.SIMPLE_WITHIN); |
---|
99 | this.scope = scope; |
---|
100 | } |
---|
101 | |
---|
102 | |
---|
103 | /** |
---|
104 | * Get the simple within scope |
---|
105 | * |
---|
106 | * @return the simple within scope |
---|
107 | */ |
---|
108 | public Scope getScope() { |
---|
109 | return scope; |
---|
110 | } |
---|
111 | |
---|
112 | |
---|
113 | @Override |
---|
114 | public String toString() { |
---|
115 | StringBuilder sb = new StringBuilder(); |
---|
116 | sb.append("(") |
---|
117 | .append(nodeType.toDisplayString()) |
---|
118 | .append(" ") |
---|
119 | .append(scope.toDisplayString()) |
---|
120 | .append(")"); |
---|
121 | return sb.toString(); |
---|
122 | } |
---|
123 | |
---|
124 | |
---|
125 | @Override |
---|
126 | public void accept(QueryVisitor visitor) { |
---|
127 | visitor.visit(this); |
---|
128 | } |
---|
129 | |
---|
130 | } // class SimpleWithin |
---|