Check whether this folder really exists on the server.
()
| 556 | * Check whether this folder really exists on the server. |
| 557 | */ |
| 558 | @Override |
| 559 | public synchronized boolean exists() throws MessagingException { |
| 560 | // Check whether this folder exists .. |
| 561 | ListInfo[] li = null; |
| 562 | final String lname; |
| 563 | if (isNamespace && separator != '\0') |
| 564 | lname = fullName + separator; |
| 565 | else |
| 566 | lname = fullName; |
| 567 | |
| 568 | li = (ListInfo[])doCommand(new ProtocolCommand() { |
| 569 | @Override |
| 570 | public Object doCommand(IMAPProtocol p) throws ProtocolException { |
| 571 | return p.list("", lname); |
| 572 | } |
| 573 | }); |
| 574 | |
| 575 | if (li != null) { |
| 576 | int i = findName(li, lname); |
| 577 | fullName = li[i].name; |
| 578 | separator = li[i].separator; |
| 579 | int len = fullName.length(); |
| 580 | if (separator != '\0' && len > 0 && |
| 581 | fullName.charAt(len - 1) == separator) { |
| 582 | fullName = fullName.substring(0, len - 1); |
| 583 | } |
| 584 | type = 0; |
| 585 | if (li[i].hasInferiors) |
| 586 | type |= HOLDS_FOLDERS; |
| 587 | if (li[i].canOpen) |
| 588 | type |= HOLDS_MESSAGES; |
| 589 | exists = true; |
| 590 | attributes = li[i].attrs; |
| 591 | } else { |
| 592 | exists = opened; |
| 593 | attributes = null; |
| 594 | } |
| 595 | |
| 596 | return exists; |
| 597 | } |
| 598 | |
| 599 | /** |
| 600 | * Which entry in <code>li</code> matches <code>lname</code>? |
no test coverage detected