source: SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUVersion.java @ 7281

Last change on this file since 7281 was 7281, checked in by Oliver Schonefeld, 2 years ago
  • cleanup
  • Property svn:eol-style set to native
File size: 1.9 KB
Line 
1/**
2 * This software is copyright (c) 2012-2022 by
3 *  - Leibniz-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 Leibniz-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 */
17package eu.clarin.sru.client;
18
19/**
20 * SRU version
21 */
22public enum SRUVersion {
23    /**
24     * SRU/CQL version 1.1
25     */
26    VERSION_1_1 {
27        @Override
28        public int getVersionNumber() {
29            return ((1 << 16) | 1);
30        }
31    },
32
33    /**
34     * SRU/CQL version 1.2
35     */
36    VERSION_1_2 {
37        @Override
38        public int getVersionNumber() {
39            return ((1 << 16) | 2);
40        }
41    },
42
43    /**
44     * SRU/CQL version 2.0
45     */
46    VERSION_2_0 {
47        @Override
48        public int getVersionNumber() {
49            return ((2 << 16) | 0);
50        }
51    };
52
53
54    /**
55     * Get a numerical representation of the version.
56     *
57     * @return numerical representation of the version
58     */
59    public abstract int getVersionNumber();
60
61
62    public boolean isVersion(SRUVersion version) {
63        if (version == null) {
64            throw new NullPointerException("version == null");
65        }
66        return (this == version);
67    }
68
69
70    public boolean isVersion(SRUVersion min, SRUVersion max) {
71        if (min == null) {
72            throw new NullPointerException("min == null");
73        }
74        if (max == null) {
75            throw new NullPointerException("max == null");
76        }
77        return ((this.getVersionNumber() >= min.getVersionNumber()) &&
78                (this.getVersionNumber() <= max.getVersionNumber()));
79    }
80
81} // enum SRUVersion
Note: See TracBrowser for help on using the repository browser.