Posted By

Mihi on 09/03/10


Tagged

java document notes attachments iterate enumerte attachmetns


Versions (?)

Iterate through Lotus Notes document attachments in JAVA


 / Published in: Java
 

Use this class to iterate through lotus notes documents attachments in java! A LotusScript version could be useful also!

  1. import java.util.Iterator;
  2.  
  3. import lotus.domino.*;
  4.  
  5. public final class DocAttachmentParser implements Iterator {
  6.  
  7. private Session s;
  8. private Document doc;
  9. private Double count ;
  10. private Iterator attIterator = null;
  11. public Double getCount() {
  12. return count;
  13. }
  14. public DocAttachmentParser(Session s, Document doc) throws NotesException {
  15. this.s = s;
  16. this.doc = doc;
  17. if (s!=null && doc !=null){
  18. this.count = (Double) s.evaluate("@Attachments", doc).elementAt(0);
  19. if (count.intValue() > 0){
  20. attIterator = s.evaluate("@AttachmentNames", doc).iterator();
  21. }
  22. }
  23.  
  24. }
  25. public boolean hasNext() {
  26. return count.intValue() > 0 ? attIterator.hasNext(): false;
  27. }
  28.  
  29. public Object next() {
  30. return count.intValue() > 0 ? attIterator.next(): null;
  31. }
  32. private String nextAttName(){
  33. return count.intValue() > 0 ? attIterator.next().toString(): null;
  34. }
  35.  
  36. public void remove() {
  37. if (count.intValue() > 0) attIterator.remove();
  38. }
  39.  
  40. public String getAll(){
  41.  
  42. StringBuilder sb = new StringBuilder();
  43. if (count.intValue()>0){
  44.  
  45. while (hasNext()) {
  46. sb.append(nextAttName());
  47. }
  48. }
  49.  
  50. return sb.toString();
  51. }
  52.  
  53. }

Report this snippet  

You need to login to post a comment.