Révision 2447
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/MemCqiClient.java (revision 2447) | ||
---|---|---|
32 | 32 |
*/ |
33 | 33 |
public class MemCqiClient extends AbstractCqiClient { |
34 | 34 |
|
35 |
MemCqiServer server; |
|
35 |
/** |
|
36 |
* The server to deal with. |
|
37 |
*/ |
|
38 |
protected MemCqiServer server; |
|
36 | 39 |
|
40 |
/** |
|
41 |
* |
|
42 |
* @param server |
|
43 |
* @throws Exception |
|
44 |
*/ |
|
37 | 45 |
public MemCqiClient(MemCqiServer server) throws Exception { |
38 | 46 |
super(); |
39 | 47 |
this.server = server; |
... | ... | |
43 | 51 |
return true; |
44 | 52 |
} |
45 | 53 |
|
46 |
public void stop() { |
|
54 |
public synchronized void stop() {
|
|
47 | 55 |
server.stop(); |
48 | 56 |
} |
49 | 57 |
|
... | ... | |
190 | 198 |
} |
191 | 199 |
|
192 | 200 |
@Override |
193 |
public int[] alg2Cpos(String arg0, int arg1) throws UnexpectedAnswerException, IOException, CqiServerError { |
|
201 |
public synchronized int[] alg2Cpos(String arg0, int arg1) throws UnexpectedAnswerException, IOException, CqiServerError {
|
|
194 | 202 |
if (arg0 == null) { |
195 | 203 |
throw new CqiServerError("alg2Cpos called with NULL parameter."); |
196 | 204 |
} |
... | ... | |
202 | 210 |
} |
203 | 211 |
|
204 | 212 |
@Override |
205 |
public int attributeSize(String arg0) throws IOException, UnexpectedAnswerException, CqiServerError { |
|
213 |
public synchronized int attributeSize(String arg0) throws IOException, UnexpectedAnswerException, CqiServerError {
|
|
206 | 214 |
if (arg0 == null) { |
207 | 215 |
throw new CqiServerError("attributeSize called with NULL parameter."); |
208 | 216 |
} |
... | ... | |
215 | 223 |
} |
216 | 224 |
|
217 | 225 |
@Override |
218 |
public boolean connect(String arg0, String arg1) { |
|
226 |
public synchronized boolean connect(String arg0, String arg1) {
|
|
219 | 227 |
return server.isLoaded; |
220 | 228 |
}; |
221 | 229 |
|
222 | 230 |
@Override |
223 |
public String[] corpusAlignementAttributes(String arg0) throws UnexpectedAnswerException, IOException, CqiServerError { |
|
231 |
public synchronized String[] corpusAlignementAttributes(String arg0) throws UnexpectedAnswerException, IOException, CqiServerError {
|
|
224 | 232 |
if (arg0 == null) { |
225 | 233 |
throw new CqiServerError("corpusAlignementAttributes called with NULL parameter."); |
226 | 234 |
} |
... | ... | |
232 | 240 |
} |
233 | 241 |
|
234 | 242 |
@Override |
235 |
public String corpusCharset(String arg0) throws UnexpectedAnswerException, IOException, CqiServerError { |
|
243 |
public synchronized String corpusCharset(String arg0) throws UnexpectedAnswerException, IOException, CqiServerError {
|
|
236 | 244 |
if (arg0 == null) { |
237 | 245 |
throw new CqiServerError("corpusCharset called with NULL parameter."); |
238 | 246 |
} |
... | ... | |
244 | 252 |
} |
245 | 253 |
|
246 | 254 |
@Override |
247 |
public String corpusFullName(String arg0) throws UnexpectedAnswerException, IOException, CqiServerError { |
|
255 |
public synchronized String corpusFullName(String arg0) throws UnexpectedAnswerException, IOException, CqiServerError {
|
|
248 | 256 |
if (arg0 == null) { |
249 | 257 |
throw new CqiServerError("corpusFullName called with NULL parameter."); |
250 | 258 |
} |
... | ... | |
268 | 276 |
} |
269 | 277 |
|
270 | 278 |
@Override |
271 |
public String[] corpusPositionalAttributes(String arg0) throws UnexpectedAnswerException, IOException, CqiServerError { |
|
279 |
public synchronized String[] corpusPositionalAttributes(String arg0) throws UnexpectedAnswerException, IOException, CqiServerError {
|
|
272 | 280 |
if (arg0 == null) { |
273 | 281 |
throw new CqiServerError("corpusPositionalAttributes called with NULL parameter."); |
274 | 282 |
} |
... | ... | |
280 | 288 |
} |
281 | 289 |
|
282 | 290 |
@Override |
283 |
public String[] corpusProperties(String arg0) throws UnexpectedAnswerException, IOException, CqiServerError { |
|
291 |
public synchronized String[] corpusProperties(String arg0) throws UnexpectedAnswerException, IOException, CqiServerError {
|
|
284 | 292 |
if (arg0 == null) { |
285 | 293 |
throw new CqiServerError("corpusProperties called with NULL parameter."); |
286 | 294 |
} |
... | ... | |
292 | 300 |
} |
293 | 301 |
|
294 | 302 |
@Override |
295 |
public boolean corpusStructuralAttributeHasValues(String arg0) throws UnexpectedAnswerException, IOException, CqiServerError { |
|
303 |
public synchronized boolean corpusStructuralAttributeHasValues(String arg0) throws UnexpectedAnswerException, IOException, CqiServerError {
|
|
296 | 304 |
if (arg0 == null) { |
297 | 305 |
throw new CqiServerError("corpusStructuralAttributeHasValues called with NULL parameter."); |
298 | 306 |
} |
... | ... | |
304 | 312 |
} |
305 | 313 |
|
306 | 314 |
@Override |
307 |
public String[] corpusStructuralAttributes(String arg0) throws UnexpectedAnswerException, IOException, CqiServerError { |
|
315 |
public synchronized String[] corpusStructuralAttributes(String arg0) throws UnexpectedAnswerException, IOException, CqiServerError {
|
|
308 | 316 |
if (arg0 == null) { |
309 | 317 |
throw new CqiServerError("corpusStructuralAttributes called with NULL parameter."); |
310 | 318 |
} |
... | ... | |
316 | 324 |
} |
317 | 325 |
|
318 | 326 |
@Override |
319 |
public int[] cpos2Alg(String arg0, int[] arg1) throws UnexpectedAnswerException, IOException, CqiServerError { |
|
327 |
public synchronized int[] cpos2Alg(String arg0, int[] arg1) throws UnexpectedAnswerException, IOException, CqiServerError {
|
|
320 | 328 |
if (arg0 == null || arg1 == null) { |
321 | 329 |
throw new CqiServerError("cpos2Alg called with NULL parameter."); |
322 | 330 |
} |
... | ... | |
328 | 336 |
} |
329 | 337 |
|
330 | 338 |
@Override |
331 |
public int[] cpos2Id(String arg0, int[] arg1) throws UnexpectedAnswerException, IOException, CqiServerError { |
|
339 |
public synchronized int[] cpos2Id(String arg0, int[] arg1) throws UnexpectedAnswerException, IOException, CqiServerError {
|
|
332 | 340 |
if (arg0 == null || arg1 == null) { |
333 | 341 |
throw new CqiServerError("cpos2Id called with NULL parameter."); |
334 | 342 |
} |
... | ... | |
340 | 348 |
} |
341 | 349 |
|
342 | 350 |
@Override |
343 |
public int[] cpos2LBound(String arg0, int[] arg1) throws UnexpectedAnswerException, IOException, CqiServerError { |
|
351 |
public synchronized int[] cpos2LBound(String arg0, int[] arg1) throws UnexpectedAnswerException, IOException, CqiServerError {
|
|
344 | 352 |
if (arg0 == null || arg1 == null) { |
345 | 353 |
throw new CqiServerError("cpos2LBound called with NULL parameter."); |
346 | 354 |
} |
... | ... | |
352 | 360 |
} |
353 | 361 |
|
354 | 362 |
@Override |
355 |
public int[] cpos2RBound(String arg0, int[] arg1) throws UnexpectedAnswerException, IOException, CqiServerError { |
|
363 |
public synchronized int[] cpos2RBound(String arg0, int[] arg1) throws UnexpectedAnswerException, IOException, CqiServerError {
|
|
356 | 364 |
if (arg0 == null || arg1 == null) { |
357 | 365 |
throw new CqiServerError("cpos2RBound called with NULL parameter."); |
358 | 366 |
} |
... | ... | |
364 | 372 |
} |
365 | 373 |
|
366 | 374 |
@Override |
367 |
public String[] cpos2Str(String arg0, int[] arg1) throws UnexpectedAnswerException, IOException, CqiServerError { |
|
375 |
public synchronized String[] cpos2Str(String arg0, int[] arg1) throws UnexpectedAnswerException, IOException, CqiServerError {
|
|
368 | 376 |
if (arg0 == null || arg1 == null) { |
369 | 377 |
throw new CqiServerError("cpos2Str called with NULL parameter."); |
370 | 378 |
} |
... | ... | |
376 | 384 |
} |
377 | 385 |
|
378 | 386 |
@Override |
379 |
public int[] cpos2Struc(String arg0, int[] arg1) throws UnexpectedAnswerException, IOException, CqiServerError { |
|
387 |
public synchronized int[] cpos2Struc(String arg0, int[] arg1) throws UnexpectedAnswerException, IOException, CqiServerError {
|
|
380 | 388 |
if (arg0 == null || arg1 == null) { |
381 | 389 |
throw new CqiServerError("cpos2Struc called with NULL parameter."); |
382 | 390 |
} |
... | ... | |
388 | 396 |
} |
389 | 397 |
|
390 | 398 |
@Override |
391 |
public void cqpQuery(String arg0, String arg1, String arg2) |
|
399 |
public synchronized void cqpQuery(String arg0, String arg1, String arg2)
|
|
392 | 400 |
throws IOException, UnexpectedAnswerException, CqiServerError { |
393 | 401 |
if (arg0 == null || arg1 == null || arg2 == null) { |
394 | 402 |
throw new CqiServerError("cqpQuery called with NULL parameter."); |
... | ... | |
403 | 411 |
} |
404 | 412 |
|
405 | 413 |
@Override |
406 |
public void query(String arg0) |
|
414 |
public synchronized void query(String arg0)
|
|
407 | 415 |
throws IOException, UnexpectedAnswerException, CqiServerError { |
408 | 416 |
if (arg0 == null) { |
409 | 417 |
throw new CqiServerError("query called with NULL parameter."); |
... | ... | |
430 | 438 |
} |
431 | 439 |
|
432 | 440 |
@Override |
433 |
public void dropCorpus(String arg0) throws Exception { |
|
441 |
public synchronized void dropCorpus(String arg0) throws Exception {
|
|
434 | 442 |
Log.finest(NLS.bind("Droping corpus {0}...", arg0)); //$NON-NLS-1$ |
435 | 443 |
if (arg0 == null) { |
436 | 444 |
throw new Exception("dropCorpus called with NULL parameter."); |
... | ... | |
442 | 450 |
} |
443 | 451 |
|
444 | 452 |
@Override |
445 |
public void dropSubCorpus(String arg0) throws IOException, UnexpectedAnswerException, CqiServerError { |
|
453 |
public synchronized void dropSubCorpus(String arg0) throws IOException, UnexpectedAnswerException, CqiServerError {
|
|
446 | 454 |
Log.finest(NLS.bind("Droping subcorpus {0}...", arg0)); //$NON-NLS-1$ |
447 | 455 |
if (arg0 == null) { |
448 | 456 |
throw new CqiServerError("dropSubCorpus called with NULL parameter."); |
... | ... | |
454 | 462 |
} |
455 | 463 |
|
456 | 464 |
@Override |
457 |
public int[] dumpSubCorpus(String arg0, byte arg1, int arg2, int arg3) |
|
465 |
public synchronized int[] dumpSubCorpus(String arg0, byte arg1, int arg2, int arg3)
|
|
458 | 466 |
throws IOException, UnexpectedAnswerException, CqiServerError { |
459 | 467 |
if (arg0 == null) { |
460 | 468 |
throw new CqiServerError("dumpSubCorpus called with NULL parameter."); |
... | ... | |
484 | 492 |
|
485 | 493 |
} |
486 | 494 |
|
487 |
public int[] nfdist1(String arg0, int arg1, byte arg2, String arg3) |
|
495 |
public synchronized int[] nfdist1(String arg0, int arg1, byte arg2, String arg3)
|
|
488 | 496 |
throws IOException, UnexpectedAnswerException, CqiServerError { |
489 | 497 |
if (arg0 == null || arg3 == null) { |
490 | 498 |
throw new CqiServerError("nfdist1 called with NULL parameter."); |
... | ... | |
517 | 525 |
return freqs; |
518 | 526 |
} |
519 | 527 |
|
520 |
public int[] nfdist2(String arg0, int arg1, byte arg2, String arg3, |
|
528 |
public synchronized int[] nfdist2(String arg0, int arg1, byte arg2, String arg3,
|
|
521 | 529 |
byte arg4, String arg5) throws IOException, UnexpectedAnswerException, CqiServerError { |
522 | 530 |
if (arg0 == null || arg3 == null || arg5 == null) { |
523 | 531 |
throw new CqiServerError("nfdist2 called with NULL parameter."); |
... | ... | |
530 | 538 |
} |
531 | 539 |
|
532 | 540 |
@Override |
533 |
public String getLastCQPError() throws UnexpectedAnswerException, IOException, CqiServerError { |
|
541 |
public synchronized String getLastCQPError() throws UnexpectedAnswerException, IOException, CqiServerError {
|
|
534 | 542 |
String rez = server.getLastCQPError(); |
535 | 543 |
if (rez == null) { |
536 | 544 |
throwExceptionFromCqi(server.getErrorCode()); |
... | ... | |
548 | 556 |
} |
549 | 557 |
|
550 | 558 |
@Override |
551 |
public int[] id2Cpos(String arg0, int arg1) throws UnexpectedAnswerException, IOException, CqiServerError { |
|
559 |
public synchronized int[] id2Cpos(String arg0, int arg1) throws UnexpectedAnswerException, IOException, CqiServerError {
|
|
552 | 560 |
if (arg0 == null) { |
553 | 561 |
throw new CqiServerError("id2Cpos called with NULL parameter."); |
554 | 562 |
} |
... | ... | |
560 | 568 |
} |
561 | 569 |
|
562 | 570 |
@Override |
563 |
public int[] id2Freq(String arg0, int[] arg1) throws UnexpectedAnswerException, IOException, CqiServerError { |
|
571 |
public synchronized int[] id2Freq(String arg0, int[] arg1) throws UnexpectedAnswerException, IOException, CqiServerError {
|
|
564 | 572 |
if (arg0 == null || arg1 == null) { |
565 | 573 |
throw new CqiServerError("id2Freq called with NULL parameter."); |
566 | 574 |
} |
... | ... | |
572 | 580 |
} |
573 | 581 |
|
574 | 582 |
@Override |
575 |
public String[] id2Str(String arg0, int[] arg1) throws UnexpectedAnswerException, IOException, CqiServerError { |
|
583 |
public synchronized String[] id2Str(String arg0, int[] arg1) throws UnexpectedAnswerException, IOException, CqiServerError {
|
|
576 | 584 |
if (arg0 == null || arg1 == null) { |
577 | 585 |
throw new CqiServerError("id2Str called with NULL parameter."); |
578 | 586 |
} |
... | ... | |
584 | 592 |
} |
585 | 593 |
|
586 | 594 |
@Override |
587 |
public int[] idList2Cpos(String arg0, int[] arg1) throws UnexpectedAnswerException, IOException, CqiServerError { |
|
595 |
public synchronized int[] idList2Cpos(String arg0, int[] arg1) throws UnexpectedAnswerException, IOException, CqiServerError {
|
|
588 | 596 |
if (arg0 == null || arg1 == null) { |
589 | 597 |
throw new CqiServerError("idList2Cpos called with NULL parameter."); |
590 | 598 |
} |
... | ... | |
596 | 604 |
} |
597 | 605 |
|
598 | 606 |
@Override |
599 |
public int lexiconSize(String arg0) throws IOException, UnexpectedAnswerException, CqiServerError { |
|
607 |
public synchronized int lexiconSize(String arg0) throws IOException, UnexpectedAnswerException, CqiServerError {
|
|
600 | 608 |
if (arg0 == null) { |
601 | 609 |
throw new CqiServerError("lexiconSize called with NULL parameter."); |
602 | 610 |
} |
... | ... | |
608 | 616 |
} |
609 | 617 |
|
610 | 618 |
@Override |
611 |
public String[] listCorpora() throws UnexpectedAnswerException, IOException, CqiServerError { |
|
619 |
public synchronized String[] listCorpora() throws UnexpectedAnswerException, IOException, CqiServerError {
|
|
612 | 620 |
String[] rez = server.listCorpora(); |
613 | 621 |
if (rez == null) { |
614 | 622 |
throwExceptionFromCqi(server.getErrorCode()); |
... | ... | |
617 | 625 |
} |
618 | 626 |
|
619 | 627 |
@Override |
620 |
public String[] listSubcorpora(String arg0) throws UnexpectedAnswerException, IOException, CqiServerError { |
|
628 |
public synchronized String[] listSubcorpora(String arg0) throws UnexpectedAnswerException, IOException, CqiServerError {
|
|
621 | 629 |
if (arg0 == null) { |
622 | 630 |
throw new CqiServerError("listSubcorpora called with NULL parameter."); |
623 | 631 |
} |
... | ... | |
634 | 642 |
}; |
635 | 643 |
|
636 | 644 |
@Override |
637 |
public int[] regex2Id(String arg0, String arg1) throws UnexpectedAnswerException, IOException, CqiServerError { |
|
645 |
public synchronized int[] regex2Id(String arg0, String arg1) throws UnexpectedAnswerException, IOException, CqiServerError {
|
|
638 | 646 |
if (arg0 == null || arg1 == null) { |
639 | 647 |
throw new CqiServerError("regex2Id called with NULL parameter."); |
640 | 648 |
} |
... | ... | |
646 | 654 |
} |
647 | 655 |
|
648 | 656 |
@Override |
649 |
public int[] str2Id(String arg0, String[] arg1) throws IOException, UnexpectedAnswerException, CqiServerError { |
|
657 |
public synchronized int[] str2Id(String arg0, String[] arg1) throws IOException, UnexpectedAnswerException, CqiServerError {
|
|
650 | 658 |
if (arg0 == null || arg1 == null) { |
651 | 659 |
throw new CqiServerError("str2Id called with NULL parameter."); |
652 | 660 |
} |
... | ... | |
659 | 667 |
} |
660 | 668 |
|
661 | 669 |
@Override |
662 |
public int[] struc2Cpos(String arg0, int arg1) throws UnexpectedAnswerException, IOException, CqiServerError { |
|
670 |
public synchronized int[] struc2Cpos(String arg0, int arg1) throws UnexpectedAnswerException, IOException, CqiServerError {
|
|
663 | 671 |
if (arg0 == null) { |
664 | 672 |
throw new CqiServerError("struc2Cpos called with NULL parameter."); |
665 | 673 |
} |
... | ... | |
671 | 679 |
} |
672 | 680 |
|
673 | 681 |
@Override |
674 |
public String[] struc2Str(String arg0, int[] arg1) throws UnexpectedAnswerException, IOException, CqiServerError { |
|
682 |
public synchronized String[] struc2Str(String arg0, int[] arg1) throws UnexpectedAnswerException, IOException, CqiServerError {
|
|
675 | 683 |
if (arg0 == null || arg1 == null) { |
676 | 684 |
throw new CqiServerError("struc2Str called with NULL parameter."); |
677 | 685 |
} |
... | ... | |
683 | 691 |
} |
684 | 692 |
|
685 | 693 |
@Override |
686 |
public boolean subCorpusHasField(String arg0, byte arg1) throws IOException, UnexpectedAnswerException, CqiServerError { |
|
694 |
public synchronized boolean subCorpusHasField(String arg0, byte arg1) throws IOException, UnexpectedAnswerException, CqiServerError {
|
|
687 | 695 |
Boolean rez = server.subCorpusHasField(arg0, arg1); |
688 | 696 |
if (rez == null || !rez) { |
689 | 697 |
throwExceptionFromCqi(server.getErrorCode()); |
... | ... | |
692 | 700 |
} |
693 | 701 |
|
694 | 702 |
@Override |
695 |
public int subCorpusSize(String arg0) throws IOException, UnexpectedAnswerException, CqiServerError { |
|
703 |
public synchronized int subCorpusSize(String arg0) throws IOException, UnexpectedAnswerException, CqiServerError {
|
|
696 | 704 |
if (arg0 == null) { |
697 | 705 |
throw new CqiServerError("subCorpusSize called with NULL parameter."); |
698 | 706 |
} |
... | ... | |
704 | 712 |
} |
705 | 713 |
|
706 | 714 |
@Override |
707 |
public boolean load_a_system_corpus(String regfilepath, String entry) throws IOException, UnexpectedAnswerException, CqiServerError { |
|
715 |
public synchronized boolean load_a_system_corpus(String regfilepath, String entry) throws IOException, UnexpectedAnswerException, CqiServerError {
|
|
708 | 716 |
if (regfilepath == null) { |
709 | 717 |
throw new CqiServerError("load_a_system_corpus called with NULL regfilepath parameter."); |
710 | 718 |
} |
Formats disponibles : Unified diff