source: FCSSimpleEndpoint/trunk/src/main/java/eu/clarin/sru/server/fcs/parser/QueryGroup.java @ 6882

Last change on this file since 6882 was 6882, checked in by Oliver Schonefeld, 8 years ago
  • add FCS-QL expression tree classes
  • modify FCSQueryParser to use expression tree
  • Property svn:eol-style set to native
File size: 1.6 KB
Line 
1package eu.clarin.sru.server.fcs.parser;
2
3public class QueryGroup extends QueryNode {
4    private int minOccurs;
5    private int maxOccurs;
6
7
8    QueryGroup(QueryNode content, int minOccurs, int maxOccurs) {
9        super(QueryNodeType.QUERY_GROUP, content);
10        this.minOccurs = minOccurs;
11        this.maxOccurs = maxOccurs;
12    }
13
14
15    public QueryNode getContent() {
16        return children.get(0);
17    }
18
19
20    public int getMinOccurs() {
21        return minOccurs;
22    }
23
24
25    public int getMaxOccurs() {
26        return maxOccurs;
27    }
28
29
30    @Override
31    public String toString() {
32        StringBuilder sb = new StringBuilder();
33        sb.append("(")
34            .append(nodeType.toDisplayString())
35            .append(" ");
36        if (minOccurs != 1) {
37            sb.append("@min=");
38            if (minOccurs == Constants.OCCURS_UNBOUNDED) {
39                sb.append("*");
40            } else {
41                sb.append(minOccurs);
42            }
43            sb.append(" ");
44        }
45        if (maxOccurs != 1) {
46            sb.append("@max=");
47            if (maxOccurs == Constants.OCCURS_UNBOUNDED) {
48                sb.append("*");
49            } else {
50                sb.append(maxOccurs);
51            }
52            sb.append(" ");
53
54        }
55        sb.append(children.get(0));
56        sb.append(")");
57        return sb.toString();
58    }
59
60
61    @Override
62    public void accept(QueryVisitor visitor) {
63        if (!children.isEmpty()) {
64            for (QueryNode child : children) {
65                visitAnyNode(visitor, child);
66            }
67        }
68        visitor.visit(this);
69    }
70
71}
Note: See TracBrowser for help on using the repository browser.