1 | /** |
---|
2 | * This software is copyright (c) 2011-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; |
---|
18 | |
---|
19 | /** |
---|
20 | * Base class for implementing for a parsed query to be returned from a |
---|
21 | * {@link SRUQueryParser}. |
---|
22 | * |
---|
23 | * @param <T> |
---|
24 | * abstract syntax tree (object) for parsed queries. |
---|
25 | */ |
---|
26 | public abstract class SRUQueryBase<T> implements SRUQuery<T> { |
---|
27 | protected final String rawQuery; |
---|
28 | protected final T parsedQuery; |
---|
29 | |
---|
30 | |
---|
31 | /** |
---|
32 | * Constructor. |
---|
33 | * |
---|
34 | * @param rawQuery |
---|
35 | * the raw and unparsed query as String |
---|
36 | * @param parsedQuery |
---|
37 | * the query parsed into an abstract syntax tree object |
---|
38 | */ |
---|
39 | protected SRUQueryBase(String rawQuery, T parsedQuery) { |
---|
40 | if (rawQuery == null) { |
---|
41 | throw new NullPointerException("rawQuery == null"); |
---|
42 | } |
---|
43 | this.rawQuery = rawQuery; |
---|
44 | if (parsedQuery == null) { |
---|
45 | throw new NullPointerException("parsedQuery == null"); |
---|
46 | } |
---|
47 | this.parsedQuery = parsedQuery; |
---|
48 | } |
---|
49 | |
---|
50 | |
---|
51 | @Override |
---|
52 | public String getRawQuery() { |
---|
53 | return rawQuery; |
---|
54 | } |
---|
55 | |
---|
56 | |
---|
57 | @Override |
---|
58 | public T getParsedQuery() { |
---|
59 | return parsedQuery; |
---|
60 | } |
---|
61 | |
---|
62 | } // abstract class SRUQueryBase |
---|