- Timestamp:
- 05/28/13 09:20:03 (11 years ago)
- Location:
- SRUClient/trunk/src/main/java/eu/clarin/sru/client
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUAbstractRequest.java
r2880 r2942 111 111 /** The URL of the endpoint. */ 112 112 protected final String endpointURI; 113 /** The version to be sued for this request. */ 113 /** The request should be performed in strict SRU protocol conformance mode */ 114 private boolean strictMode; 115 /** The version to be used for this request. */ 114 116 protected SRUVersion version; 115 117 /** A map of extra request data parameters. */ … … 141 143 public String getEndpointURI() { 142 144 return endpointURI; 145 } 146 147 148 /** 149 * Get the SRU protocol conformance mode for this request 150 * 151 * @return <code>true</code> if the request will be performed in strict 152 * mode, <code>false</code> if the request will be performed in a 153 * more tolerant mode 154 */ 155 public boolean isStrictMode() { 156 return strictMode; 157 } 158 159 160 /** 161 * Set the SRU protocol conformance mode for this request 162 * 163 * @param strictMode 164 * <code>true</code> if the request should be performed in strict 165 * mode, <code>false</code> if the request should be performed 166 * client should in a more tolerant mode 167 */ 168 public void setStrictMode(boolean strictMode) { 169 this.strictMode = strictMode; 143 170 } 144 171 -
SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUClient.java
r2936 r2942 80 80 * use the default SRU version. 81 81 * 82 * @see #SRUClient(SRUVersion, boolean)83 82 * @see SRUSimpleClient#DEFAULT_SRU_VERSION 84 83 */ 85 84 public SRUClient() { 86 this(SRUSimpleClient.DEFAULT_SRU_VERSION, true); 85 this(SRUSimpleClient.DEFAULT_SRU_VERSION, 86 new HashMap<String, SRURecordDataParser>(), 87 DocumentBuilderFactory.newInstance()); 87 88 } 88 89 … … 94 95 * the default version to use for SRU requests; may be overridden 95 96 * by individual requests 96 * @see #SRUClient(SRUVersion, boolean)97 97 */ 98 98 public SRUClient(SRUVersion defaultVersion) { 99 this(defaultVersion, true); 99 this(defaultVersion, 100 new HashMap<String, SRURecordDataParser>(), 101 DocumentBuilderFactory.newInstance()); 100 102 } 101 103 … … 103 105 /** 104 106 * Constructor. 107 * 108 * <p> 109 * For internal use only. 110 * </p> 105 111 * 106 112 * @param defaultVersion 107 113 * the default version to use for SRU requests; may be overridden 108 114 * by individual requests 109 * @param strictMode110 * if <code>true</code> the client will strictly adhere to the111 * SRU standard and raise fatal errors on violations, if112 * <code>false</code> it will act more forgiving and ignore113 * certain violations114 */115 public SRUClient(SRUVersion defaultVersion, boolean strictMode) {116 this(defaultVersion, strictMode,117 new HashMap<String, SRURecordDataParser>(),118 DocumentBuilderFactory.newInstance());119 }120 121 122 /**123 * Constructor.124 *125 * <p>126 * For internal use only.127 * </p>128 *129 * @param defaultVersion130 * the default version to use for SRU requests; may be overridden131 * by individual requests132 * @param strictMode133 * if <code>true</code> the client will strictly adhere to the134 * SRU standard and raise fatal errors on violations, if135 * <code>false</code> it will act more forgiving and ignore136 * certain violations137 115 * @param parsers 138 116 * a <code>Map</code> to store record schema to record data 139 117 * parser mappings 140 */ 141 SRUClient(SRUVersion defaultVersion, boolean strictMode, 118 * @param documentBuilderFactory 119 * the Document Builder factory to be used to create Document 120 * Builders 121 */ 122 SRUClient(SRUVersion defaultVersion, 142 123 Map<String, SRURecordDataParser> parsers, 143 124 DocumentBuilderFactory documentBuilderFactory) { … … 148 129 throw new NullPointerException("parsers == null"); 149 130 } 150 this.client = new SRUSimpleClient(defaultVersion, strictMode, parsers); 131 if (documentBuilderFactory == null) { 132 throw new NullPointerException("documentBuilderFactory == null"); 133 } 134 this.client = new SRUSimpleClient(defaultVersion, parsers); 151 135 this.handler = new Handler(); 152 136 try { … … 166 150 /** 167 151 * Register a record data parser. 168 * 152 * 169 153 * @param parser 170 154 * a parser instance -
SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUSimpleClient.java
r2939 r2942 80 80 LoggerFactory.getLogger(SRUSimpleClient.class); 81 81 private final SRUVersion defaultVersion; 82 private boolean strictMode;83 82 private final Map<String, SRURecordDataParser> parsers; 84 83 private final HttpClient httpClient; … … 91 90 * use the default SRU version. 92 91 * 93 * @see #SRUSimpleClient(SRUVersion, boolean)94 92 * @see #DEFAULT_SRU_VERSION 95 93 */ 96 94 public SRUSimpleClient() { 97 this(DEFAULT_SRU_VERSION, true);95 this(DEFAULT_SRU_VERSION, new HashMap<String, SRURecordDataParser>()); 98 96 } 99 97 … … 105 103 * the default version to use for SRU requests; may be overridden 106 104 * by individual requests 107 * @see #SRUSimpleClient(SRUVersion, boolean)108 105 */ 109 106 public SRUSimpleClient(SRUVersion defaultVersion) { 110 this(defaultVersion, true); 111 } 112 113 114 /** 115 * Constructor. 116 * 117 * @param defaultVersion 118 * the default version to use for SRU requests; may be overridden 119 * by individual requests 120 * @param strictMode 121 * if <code>true</code> the client will strictly adhere to the 122 * SRU standard and raise fatal errors on violations, if 123 * <code>false</code> it will act more forgiving and ignore 124 * certain violations 125 */ 126 public SRUSimpleClient(SRUVersion defaultVersion, boolean strictMode) { 127 this(defaultVersion, strictMode, 128 new HashMap<String, SRURecordDataParser>()); 107 this(defaultVersion, new HashMap<String, SRURecordDataParser>()); 129 108 } 130 109 … … 149 128 * parser mappings 150 129 */ 151 SRUSimpleClient(SRUVersion defaultVersion, boolean strictMode,130 SRUSimpleClient(SRUVersion defaultVersion, 152 131 Map<String, SRURecordDataParser> parsers) { 153 132 if (defaultVersion == null) { … … 158 137 } 159 138 this.defaultVersion = defaultVersion; 160 this.strictMode = strictMode;161 139 this.parsers = parsers; 162 this.httpClient = new DefaultHttpClient();140 this.httpClient = new DefaultHttpClient(); 163 141 this.httpClient.getParams().setParameter(CoreProtocolPNames.USER_AGENT, 164 142 "eu.clarin.sru.client/0.0.1"); 165 }166 167 168 /**169 * Get the SRU protocol conformance mode of the client.170 *171 * @return <code>true</code> if the client operation in strict mode,172 * <code>false</code> otherwise173 */174 public boolean isStrictMode() {175 return strictMode;176 }177 178 179 /**180 * Set the SRU protocol conformance mode of the client.181 *182 * @param strictMode183 * <code>true</code> if the client should operate in strict mode,184 * <code>false</code> if the client should be more tolerant185 */186 public void setStrictMode(boolean strictMode) {187 this.strictMode = strictMode;188 143 } 189 144 … … 548 503 boolean parseRecordData) throws SRUClientException { 549 504 try { 505 final boolean strictMode = request.isStrictMode(); 506 550 507 // explainResponse 551 508 reader.readStart(SRU_NS, "explainResponse", true); … … 755 712 } else { 756 713 logger.debug("parsing 'scanResponse' response"); 714 715 final boolean strictMode = request.isStrictMode(); 757 716 758 717 // scanResponse … … 931 890 } else { 932 891 logger.debug("parsing 'searchRetrieve' response"); 892 893 final boolean strictMode = request.isStrictMode(); 933 894 934 895 // searchRetrieveResponse -
SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUThreadedClient.java
r2936 r2942 55 55 * use the default SRU version. 56 56 * 57 * @see #SRUThreadedClient(SRUVersion, boolean)58 57 * @see SRUSimpleClient#DEFAULT_SRU_VERSION 59 58 */ 60 59 public SRUThreadedClient() { 61 this(SRUSimpleClient.DEFAULT_SRU_VERSION , true);62 } 63 64 65 /** 66 * Constructor. This constructor will create a <em>strict</em> client.60 this(SRUSimpleClient.DEFAULT_SRU_VERSION); 61 } 62 63 64 /** 65 * Constructor. 67 66 * 68 67 * @param defaultVersion 69 68 * the default version to use for SRU requests; may be overridden 70 69 * by individual requests 71 * @see #SRUThreadedClient(SRUVersion, boolean) 72 */ 73 public SRUThreadedClient(SRUVersion defaultVersion) { 74 this(defaultVersion, true); 75 } 76 77 78 /** 79 * Constructor. 80 * 81 * @param defaultVersion 82 * the default version to use for SRU requests; may be overridden 83 * by individual requests 84 * @param strictMode 85 * if <code>true</code> the client will strictly adhere to the 86 * SRU standard and raise fatal errors on violations, if 87 * <code>false</code> it will act more forgiving and ignore 88 * certain violations 89 */ 90 public SRUThreadedClient(final SRUVersion defaultVersion, 91 final boolean strictMode) { 70 */ 71 public SRUThreadedClient(final SRUVersion defaultVersion) { 92 72 client = new ThreadLocal<SRUClient>() { 93 73 @Override 94 74 protected SRUClient initialValue() { 95 75 logger.debug("instantiated new sru client"); 96 return new SRUClient(defaultVersion, strictMode,parsers,76 return new SRUClient(defaultVersion, parsers, 97 77 documentBuilderFactory); 98 78 } … … 107 87 /** 108 88 * Register a record data parser. 109 * 89 * 110 90 * @param parser 111 91 * a parser instance
Note: See TracChangeset
for help on using the changeset viewer.