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.Collections;
26  import java.util.List;
27  import java.util.Vector;
28  
29  import lotus.domino.Document;
30  import lotus.domino.NotesException;
31  import lotus.domino.ViewEntry;
32  import de.bea.domingo.DBase;
33  import de.bea.domingo.DDocument;
34  import de.bea.domingo.DNotesMonitor;
35  import de.bea.domingo.DViewEntry;
36  
37  /***
38   * Represents a view entry. A view entry describes a row in a view.
39   *
40   * @author <a href=mailto:kriede@users.sourceforge.net>Kurt Riede</a>
41   */
42  public final class ViewEntryProxy extends BaseProxy implements DViewEntry {
43  
44      /*** serial version ID for serialization. */
45      private static final long serialVersionUID = 3978430204404511538L;
46  
47      /***
48       * Constructor.
49       *
50       * @param theFactory the controlling factory
51       * @param theParent the parent object
52       * @param viewEntry a view entry
53       * @param monitor the monitor
54       */
55      private ViewEntryProxy(final NotesProxyFactory theFactory, final DBase theParent,
56                             final ViewEntry viewEntry, final DNotesMonitor monitor) {
57          super(theFactory, theParent, viewEntry, monitor);
58      }
59  
60      /***
61       * Creates an encapsulated notes session object.
62       *
63       * @param theFactory the controlling factory
64       * @param parent the parent object
65       * @param viewEntry the Notes ViewEntry
66       * @param monitor the monitor
67       * @return a session object
68       */
69      public static ViewEntryProxy getInstance(final NotesProxyFactory theFactory,  final DBase parent,
70                                               final ViewEntry viewEntry, final DNotesMonitor monitor) {
71          if (viewEntry == null) {
72              return null;
73          }
74          return new ViewEntryProxy(theFactory, parent, viewEntry, monitor);
75      }
76  
77      /***
78       * Returns the associated Notes view entry.
79       *
80       * @return associated notes view entry
81       */
82      private ViewEntry getViewEntry() {
83          return (ViewEntry) getNotesObject();
84      }
85  
86      /***
87       * @see java.lang.Object#toString()
88       * @return  a string representation of the object.
89       */
90      public String toString() {
91          return "ViewEntryProxy";
92      }
93  
94      /***
95       * {@inheritDoc}
96       * @see de.bea.domingo.DViewEntry#getColumnValues()
97       */
98      public List getColumnValues() {
99          getFactory().preprocessMethod();
100         try {
101             final Vector vector = getViewEntry().getColumnValues();
102             final List convertedValues = convertNotesDateTimesToCalendar(vector);
103             recycleDateTimeList(vector);
104             return Collections.unmodifiableList(convertedValues);
105         } catch (NotesException e) {
106             throw newRuntimeException("Cannot get column values", e);
107         }
108     }
109 
110     /***
111      * {@inheritDoc}
112      * @see de.bea.domingo.DViewEntry#getDocument()
113      */
114     public DDocument getDocument() {
115         getFactory().preprocessMethod();
116         try {
117             final Document doc = getViewEntry().getDocument();
118             final BaseDocumentProxy proxy = BaseDocumentProxy.getInstance(getFactory(), this, doc, getMonitor());
119             return (DDocument) proxy;
120         } catch (NotesException e) {
121             throw newRuntimeException("Cannot get document", e);
122         }
123     }
124 
125     /***
126      * {@inheritDoc}
127      * @see de.bea.domingo.DViewEntry#isCategory()
128      */
129     public boolean isCategory() {
130         getFactory().preprocessMethod();
131         try {
132             return getViewEntry().isCategory();
133         } catch (NotesException e) {
134             throw newRuntimeException("Cannot check if is category", e);
135         }
136     }
137 
138     /***
139      * {@inheritDoc}
140      * @see de.bea.domingo.DViewEntry#isDocument()
141      */
142     public boolean isDocument() {
143         getFactory().preprocessMethod();
144         try {
145             return getViewEntry().isDocument();
146         } catch (NotesException e) {
147             throw newRuntimeException("Cannot check if is document", e);
148         }
149     }
150 
151     /***
152      * {@inheritDoc}
153      * @see de.bea.domingo.DViewEntry#isTotal()
154      */
155     public boolean isTotal() {
156         getFactory().preprocessMethod();
157         try {
158             return getViewEntry().isTotal();
159         } catch (NotesException e) {
160             throw newRuntimeException("Cannot check if is total", e);
161         }
162     }
163 
164     /***
165      * {@inheritDoc}
166      * @see de.bea.domingo.DViewEntry#getUniversalID()
167      */
168     public String getUniversalID() {
169         getFactory().preprocessMethod();
170         try {
171             return getViewEntry().getUniversalID();
172         } catch (NotesException e) {
173             throw newRuntimeException("Cannot get universalID", e);
174         }
175     }
176 
177     /***
178      * {@inheritDoc}
179      * @see de.bea.domingo.DViewEntry#getChildCount()
180      */
181     public int getChildCount() {
182         getFactory().preprocessMethod();
183         try {
184             return getViewEntry().getChildCount();
185         } catch (NotesException e) {
186             throw newRuntimeException("Cannot get child count", e);
187         }
188     }
189 
190     /***
191      * {@inheritDoc}
192      * @see de.bea.domingo.DViewEntry#isConflict()
193      */
194     public boolean isConflict() {
195         getFactory().preprocessMethod();
196         try {
197             return getViewEntry().isConflict();
198         } catch (NotesException e) {
199             throw newRuntimeException("Cannot check if is conflict", e);
200         }
201     }
202 
203     /***
204      * {@inheritDoc}
205      * @see de.bea.domingo.DViewEntry#getDescendantCount()
206      */
207     public int getDescendantCount() {
208         getFactory().preprocessMethod();
209         try {
210             return getViewEntry().getDescendantCount();
211         } catch (NotesException e) {
212             throw newRuntimeException("Cannot get descendant count", e);
213         }
214     }
215 
216     /***
217      * {@inheritDoc}
218      * @see de.bea.domingo.DViewEntry#getSiblingCount()
219      */
220     public int getSiblingCount() {
221         getFactory().preprocessMethod();
222         try {
223             return getViewEntry().getSiblingCount();
224         } catch (NotesException e) {
225             throw newRuntimeException("Cannot get sibling count", e);
226         }
227     }
228 
229     /***
230      * {@inheritDoc}
231      * @see de.bea.domingo.DViewEntry#getSibblingCount()
232      * @deprecated use method {@link #getSiblingCount()} instead
233      */
234     public int getSibblingCount() {
235         getFactory().preprocessMethod();
236         try {
237             return getViewEntry().getSiblingCount();
238         } catch (NotesException e) {
239             throw newRuntimeException("Cannot get sibling count", e);
240         }
241     }
242 
243     /***
244      * {@inheritDoc}
245      * @see de.bea.domingo.DViewEntry#getIndentLevel()
246      */
247     public int getIndentLevel() {
248         getFactory().preprocessMethod();
249         try {
250             return getViewEntry().getIndentLevel();
251         } catch (NotesException e) {
252             throw newRuntimeException("Cannot get indent level", e);
253         }
254     }
255 
256     /***
257      * {@inheritDoc}
258      * @see de.bea.domingo.DViewEntry#isValid()
259      */
260     public boolean isValid() {
261         getFactory().preprocessMethod();
262         try {
263             return getViewEntry().isValid();
264         } catch (NotesException e) {
265             throw newRuntimeException("Cannot check if it valid", e);
266         }
267     }
268 
269     /***
270      * {@inheritDoc}
271      * @see de.bea.domingo.DViewEntry#getNoteID()
272      */
273     public String getNoteID() {
274         getFactory().preprocessMethod();
275         try {
276             return getViewEntry().getNoteID();
277         } catch (NotesException e) {
278             throw newRuntimeException("Cannot get NoteID", e);
279         }
280     }
281 
282     /***
283      * {@inheritDoc}
284      * @see de.bea.domingo.DViewEntry#getPosition(char)
285      */
286     public String getPosition(final char seperator) {
287         getFactory().preprocessMethod();
288         try {
289             return getViewEntry().getPosition(seperator);
290         } catch (NotesException e) {
291             throw newRuntimeException("Cannot get position", e);
292         }
293     }
294 }