- Timestamp:
- 03/22/18 20:46:25 (6 years ago)
- Location:
- SRUClient/trunk/src/main/java/eu/clarin/sru/client
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUSimpleClient.java
r7094 r7171 511 511 // XXX: what to do with it? 512 512 SRURecordPacking recordPacking = null; 513 if (version == SRUVersion.VERSION_2_0) {513 if (version.isVersion(SRUVersion.VERSION_2_0)) { 514 514 recordPacking = parseRecordPacking(reader, 515 515 ns.sruNS(), strictMode); 516 516 } 517 517 518 // recordXmlEscaping (used to be recordPacking in SRU 1.0/1.2) 518 519 if (recordXmlEscaping == null) { 519 520 recordXmlEscaping = parseRecordXmlEscaping(reader, ns, … … 571 572 reader.readEnd(ns.sruNS(), "recordData", true); 572 573 573 if (version == SRUVersion.VERSION_1_2) { 574 if (version.isVersion(SRUVersion.VERSION_1_2, 575 SRUVersion.VERSION_2_0)) { 574 576 reader.readContent(ns.sruNS(), "recordIdentifier", false); 575 577 } … … 967 969 // XXX: what to do with it? 968 970 SRURecordPacking recordPacking = null; 969 if (version == SRUVersion.VERSION_2_0) {971 if (version.isVersion(SRUVersion.VERSION_2_0)) { 970 972 recordPacking = parseRecordPacking(reader, 971 973 ns.sruNS(), strictMode); … … 1085 1087 1086 1088 String identifier = null; 1087 if (version == SRUVersion.VERSION_1_2) { 1089 if (version.isVersion(SRUVersion.VERSION_1_2, 1090 SRUVersion.VERSION_2_0)) { 1088 1091 identifier = reader.readContent(ns.sruNS(), 1089 1092 "recordIdentifier", false); … … 1221 1224 } 1222 1225 1223 if (version == SRUVersion.VERSION_2_0) {1226 if (version.isVersion(SRUVersion.VERSION_2_0)) { 1224 1227 // SRU (2.0) arbitrary stuff 1225 1228 // SRU (2.0) resultSetTTL (replaces resultSetIdleTime) … … 1373 1376 throws XMLStreamException, SRUClientException { 1374 1377 1375 final String name = (version ==SRUVersion.VERSION_2_0)1378 final String name = version.isVersion(SRUVersion.VERSION_2_0) 1376 1379 ? "recordXMLEscaping" : "recordPacking"; 1377 1380 final String s = reader.readContent(ns.sruNS(), name, true); -
SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUVersion.java
r6938 r7171 24 24 * SRU/CQL version 1.1 25 25 */ 26 VERSION_1_1, 26 VERSION_1_1 { 27 @Override 28 public int getVersionNumber() { 29 return ((1 << 16) | 1); 30 } 31 }, 27 32 28 33 /** 29 34 * SRU/CQL version 1.2 30 35 */ 31 VERSION_1_2, 36 VERSION_1_2 { 37 @Override 38 public int getVersionNumber() { 39 return ((1 << 16) | 2); 40 } 41 }, 32 42 33 43 /** 34 44 * SRU/CQL version 2.0 35 45 */ 36 VERSION_2_0; 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 } 37 80 38 81 } // enum SRUVersion
Note: See TracChangeset
for help on using the changeset viewer.