View Javadoc

1   /*
2    * This file is part of Domingo
3    * an Open Source Java-API to Lotus Notes/Domino
4    * hosted at http://domingo.sourceforge.net
5    *
6    * Copyright (c) 2003-2007 Beck et al. projects GmbH Munich, Germany (http://www.bea.de)
7    *
8    * This library is free software; you can redistribute it and/or
9    * modify it under the terms of the GNU Lesser General Public
10   * License as published by the Free Software Foundation; either
11   * version 2.1 of the License, or (at your option) any later version.
12   *
13   * This library is distributed in the hope that it will be useful,
14   * but WITHOUT ANY WARRANTY; without even the implied warranty of
15   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16   * Lesser General Public License for more details.
17   *
18   * You should have received a copy of the GNU Lesser General Public
19   * License along with this library; if not, write to the Free Software
20   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21   */
22  
23  package de.bea.domingo.proxy;
24  
25  import java.util.Iterator;
26  
27  import lotus.domino.DocumentCollection;
28  import lotus.domino.NotesException;
29  import de.bea.domingo.DBase;
30  import de.bea.domingo.DDocumentCollection;
31  import de.bea.domingo.DNotesMonitor;
32  
33  /***
34   * Represents the Domino-Class <code>DocumentCollection</code>.
35   */
36  public final class DocumentCollectionProxy extends BaseCollectionProxy implements DDocumentCollection {
37  
38      /*** serial version ID for serialization. */
39      private static final long serialVersionUID = 3977580290371827769L;
40  
41      /***
42       * Constructor.
43       *
44       * @param theFactory the controlling factory
45       * @param parent the parent object
46       * @param documentCollection the Notes DocumentCollection
47       * @param monitor the monitor
48       *
49       * @see DocumentCollection
50       */
51      public DocumentCollectionProxy(final NotesProxyFactory theFactory, final DBase parent,
52                                     final DocumentCollection documentCollection, final DNotesMonitor monitor) {
53          super(theFactory, parent, documentCollection, monitor);
54          getFactory().preprocessMethod();
55      }
56  
57      /***
58       * Returns the associated notes document collection object.
59       *
60       * @return notes database object
61       */
62      private DocumentCollection getDocumentCollection() {
63          return (DocumentCollection) getNotesObject();
64      }
65  
66      /***
67       * @see de.bea.domingo.proxy.BaseProxy#toString()
68       * @return "DocumentCollection"
69       */
70      public String toString() {
71          return "DocumentCollection";
72      }
73  
74      /***
75       * {@inheritDoc}
76       * @see de.bea.domingo.DDocumentCollection#getAllDocuments()
77       */
78      public Iterator getAllDocuments() {
79          return new DocumentCollectionIterator(getFactory(), getParent(), getDocumentCollection(), getMonitor());
80      }
81  
82      /***
83       * {@inheritDoc}
84       * @see de.bea.domingo.DDocumentCollection#fullTextSearch(java.lang.String)
85       */
86      public void fullTextSearch(final String query) {
87          getFactory().preprocessMethod();
88          try {
89              getDocumentCollection().FTSearch(query);
90          } catch (NotesException e) {
91              throw newRuntimeException("Cannot search documents in collection", e);
92          }
93      }
94  
95      /***
96       * {@inheritDoc}
97       * @see de.bea.domingo.DDocumentCollection#fullTextSearch(java.lang.String, int)
98       */
99      public void fullTextSearch(final String query, final int maxdocs) {
100         getFactory().preprocessMethod();
101         try {
102             getDocumentCollection().FTSearch(query, maxdocs);
103         } catch (NotesException e) {
104             throw newRuntimeException("Cannot search documents in collection", e);
105         }
106     }
107 }