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.io.IOException;
26  import java.io.InputStream;
27  import java.io.Reader;
28  import java.util.Calendar;
29  import java.util.Collections;
30  import java.util.Iterator;
31  import java.util.List;
32  import java.util.TimeZone;
33  import java.util.Vector;
34  
35  import lotus.domino.DateRange;
36  import lotus.domino.DateTime;
37  import lotus.domino.Document;
38  import lotus.domino.Item;
39  import lotus.domino.NotesError;
40  import lotus.domino.NotesException;
41  import de.bea.domingo.DBase;
42  import de.bea.domingo.DDateRange;
43  import de.bea.domingo.DDocument;
44  import de.bea.domingo.DItem;
45  import de.bea.domingo.DNotesMonitor;
46  import de.bea.domingo.DNotesRuntimeException;
47  import de.bea.domingo.util.GregorianDateTimeRange;
48  import de.bea.domingo.util.Timezones;
49  
50  /***
51   * This class represents the Domino-Class <code>Item</code>.
52   */
53  public final class ItemProxy extends BaseItemProxy implements DItem {
54  
55      /*** serial version ID for serialization. */
56      private static final long serialVersionUID = 3761403097427162931L;
57  
58      /*** Maximum size of an items value. */
59      public static final int MAX_VALUE_SIZE = 15000;
60  
61      /*** Size of a multiple value separator. */
62      public static final int VALUE_SEPERATOR_SIZE = 2;
63  
64      /*** Value size of numeric value stored in a Notes item. */
65      public static final int VALUE_SIZE_NUMBER = 4;
66  
67      /*** Value size of date/time value stored in a Notes item. */
68      public static final int VALUE_SIZE_CALENDAR = 8;
69  
70      /***
71       * Constructor for DItemImpl.
72       *
73       * @param theFactory the controlling factory
74       * @param parent the parent object
75       * @param theItem the Notes item object
76       * @param monitor the monitor
77       */
78      protected ItemProxy(final NotesProxyFactory theFactory, final DBase parent,
79                          final Item theItem, final DNotesMonitor monitor) {
80          super(theFactory, parent, theItem, monitor);
81      }
82  
83      /***
84       * {@inheritDoc}
85       * @see de.bea.domingo.DItem#getValues()
86       */
87      public List getValues() {
88          getFactory().preprocessMethod();
89          try {
90              List vector = null;
91              if (getItem().getType() == Item.DATETIMES) {
92                  vector = getItem().getValueDateTimeArray();
93                  final List convertedValues = convertNotesDateTimesToCalendar(vector);
94                  recycleDateTimeList(vector);
95                  vector = convertedValues;
96              } else {
97                  vector = getItem().getValues();
98              }
99              if (vector == null) {
100                 vector = new Vector();
101             }
102             if (vector.size() == 0) {
103                 vector.add("");
104             }
105             return Collections.unmodifiableList(vector);
106         } catch (NotesException e) {
107             throw newRuntimeException("Cannot get values", e);
108         }
109     }
110 
111     /***
112      * {@inheritDoc}
113      * @see de.bea.domingo.DItem#getValueString()
114      */
115     public String getValueString() {
116         getFactory().preprocessMethod();
117         String result = "";
118         try {
119             result = getItem().getText();
120         } catch (NotesException e) {
121             throw newRuntimeException("Cannot get string value", e);
122         }
123         return result;
124     }
125 
126     /***
127      * {@inheritDoc}
128      * @see de.bea.domingo.DItem#getValueInteger()
129      */
130     public Integer getValueInteger() {
131         getFactory().preprocessMethod();
132         try {
133                 return new Integer(getItem().getValueInteger());
134         } catch (NotesException e) {
135             throw newRuntimeException("Cannot get integer value", e);
136         }
137     }
138 
139     /***
140      * {@inheritDoc}
141      * @see de.bea.domingo.DItem#getValueDouble()
142      */
143     public Double getValueDouble() {
144         getFactory().preprocessMethod();
145         try {
146             return new Double(getItem().getValueDouble());
147         } catch (NotesException e) {
148             throw newRuntimeException("Cannot get double value", e);
149         }
150     }
151 
152     /***
153      * {@inheritDoc}
154      * @see de.bea.domingo.DItem#getValueDateTime()
155      */
156     public Calendar getValueDateTime() {
157         getFactory().preprocessMethod();
158 
159         try {
160             Vector vector = ((Item) getNotesObject()).getValueDateTimeArray();
161             Calendar calendar = null;
162             if (vector != null && vector.size() > 0) {
163                 calendar = createCalendar((DateTime) vector.get(0));
164                 recycleDateTimeList(vector);
165             }
166             return calendar;
167         } catch (NotesException e) {
168             if (e.id == NotesError.NOTES_ERR_NOT_A_DATE_ITEM) {
169                 return null;
170             }
171             throw newRuntimeException("Cannot get calendar value of item", e);
172         }
173     }
174 
175     /***
176      * {@inheritDoc}
177      * @see de.bea.domingo.DItem#getValueDateRange()
178      */
179     public DDateRange getValueDateRange() {
180         getFactory().preprocessMethod();
181         try {
182             Vector vector = getItem().getValues();
183             if (vector == null || vector.size() == 0) {
184                 return null;
185             }
186             Calendar start = null;
187             Calendar end = null;
188             Object object = vector.get(0);
189             if (object instanceof DateRange) {
190                 start = createCalendar(((DateRange) object).getStartDateTime());
191                 end = createCalendar(((DateRange) object).getEndDateTime());
192             } else if (object instanceof DateTime) {
193                 start = createCalendar((DateTime) object);
194                 end = null;
195                 if (vector.size() > 1) {
196                     end = createCalendar((DateTime) vector.get(1));
197                 }
198             }
199             DDateRange range = null;
200             range = new GregorianDateTimeRange(start, end);
201             recycleDateTimeList(vector);
202             return range;
203         } catch (NotesException e) {
204             if (e.id == NotesError.NOTES_ERR_NOT_A_DATE_ITEM) {
205                 return null;
206             }
207             throw newRuntimeException("Cannot get calendar value of item", e);
208         }
209     }
210 
211     /***
212      * {@inheritDoc}
213      * @see de.bea.domingo.DItem#appendToTextList(java.lang.String)
214      */
215     public void appendToTextList(final String value) {
216         getFactory().preprocessMethod();
217         try {
218             final int size = getItem().getValueLength() + value.length();
219             if (size > MAX_VALUE_SIZE) {
220                 throw newRuntimeException("Value size cannot be bigger than 15k: " + size);
221             }
222         } catch (NotesException e) {
223             throw newRuntimeException("Cannot append to text list", e);
224         }
225         try {
226             getItem().appendToTextList(value);
227         } catch (NotesException e) {
228             throw newRuntimeException("Cannot append to text list", e);
229         }
230     }
231 
232     /***
233      * {@inheritDoc}
234      * @see de.bea.domingo.DItem#appendToTextList(java.util.List)
235      */
236     public void appendToTextList(final List values) {
237         getFactory().preprocessMethod();
238         try {
239             final int size = getItem().getValueLength() + getValueSize(values);
240             if (size > MAX_VALUE_SIZE) {
241                 throw newRuntimeException("Value size cannot be bigger than 15k: " + size);
242             }
243         } catch (NotesException e) {
244             throw newRuntimeException("Cannot append to text list", e);
245         }
246         final List convertedKeys = convertCalendarsToNotesDateTime(values);
247         final Vector vector = convertListToVector(convertedKeys);
248         try {
249             getItem().appendToTextList(vector);
250         } catch (NotesException e) {
251             throw newRuntimeException("Cannot append to text list", e);
252         } finally {
253             recycleDateTimeList(convertedKeys);
254         }
255     }
256 
257     /***
258      * {@inheritDoc}
259      * @see de.bea.domingo.DItem#containsValue(java.lang.String)
260      */
261     public boolean containsValue(final String value) {
262         getFactory().preprocessMethod();
263         try {
264             return getItem().containsValue(value);
265         } catch (NotesException e) {
266             throw newRuntimeException("Cannot check if item contains value " + value, e);
267         }
268     }
269 
270     /***
271      * {@inheritDoc}
272      * @see de.bea.domingo.DItem#containsValue(java.lang.Integer)
273      */
274     public boolean containsValue(final Integer value) {
275         getFactory().preprocessMethod();
276         try {
277             return getItem().containsValue(value);
278         } catch (NotesException e) {
279             throw newRuntimeException("Cannot check if item contains value " + value, e);
280         }
281     }
282 
283     /***
284      * {@inheritDoc}
285      * @see de.bea.domingo.DItem#containsValue(int)
286      */
287     public boolean containsValue(final int value) {
288         return containsValue(new Integer(value));
289     }
290 
291     /***
292      * {@inheritDoc}
293      * @see de.bea.domingo.DItem#containsValue(java.lang.Double)
294      */
295     public boolean containsValue(final Double value) {
296         getFactory().preprocessMethod();
297         try {
298             return getItem().containsValue(value);
299         } catch (NotesException e) {
300             throw newRuntimeException("Cannot check if item contains value " + value, e);
301         }
302     }
303 
304     /***
305      * {@inheritDoc}
306      * @see de.bea.domingo.DItem#containsValue(double)
307      */
308     public boolean containsValue(final double value) {
309         return containsValue(new Double(value));
310     }
311 
312     /***
313      * {@inheritDoc}
314      * @see de.bea.domingo.DItem#containsValue(java.util.Calendar)
315      */
316     public boolean containsValue(final Calendar value) {
317         getFactory().preprocessMethod();
318         try {
319             final DateTime dateTime = createDateTime(value);
320             final boolean result = getItem().containsValue(value);
321             getFactory().recycle(dateTime);
322             return result;
323         } catch (NotesException e) {
324             throw newRuntimeException("Cannot check if item contains value " + value, e);
325         }
326     }
327 
328     /***
329      * {@inheritDoc}
330      * @see de.bea.domingo.DItem#setValueDateTime(java.util.Calendar)
331      */
332     public void setValueDateTime(final Calendar value) {
333         if (value == null) {
334             setValueString("");
335         } else {
336             getFactory().preprocessMethod();
337             try {
338                 final DateTime dateTime = createDateTime(value);
339                 getItem().setDateTimeValue(dateTime);
340                 getFactory().recycle(dateTime);
341             } catch (NotesException e) {
342                 throw newRuntimeException("Cannot set calendar value", e);
343             }
344         }
345     }
346 
347     /***
348      * {@inheritDoc}
349      * @see de.bea.domingo.DItem#setValueDateRange(de.bea.domingo.DDateRange)
350      */
351     public void setValueDateRange(final DDateRange value) {
352         if (value == null) {
353             setValueString("");
354         } else {
355             setValueDateRange(value.getFrom(), value.getTo());
356         }
357     }
358 
359     /***
360      * {@inheritDoc}
361      * @see de.bea.domingo.DItem#setValueDateRange(java.util.Calendar, java.util.Calendar)
362      */
363     public void setValueDateRange(final Calendar calendar1, final Calendar calendar2) {
364         if (calendar1 == null && calendar2 == null) {
365             setValueString("");
366         } else if (calendar1 == null) {
367             setValueDateTime(calendar2);
368         } else if (calendar2 == null) {
369             setValueDateTime(calendar1);
370         } else {
371             getFactory().preprocessMethod();
372             try {
373                 final DateRange dateRange = createDateRange(calendar1, calendar2);
374                 final Vector vector = new Vector();
375                 vector.addElement(dateRange);
376                 getItem().setValues(vector);
377                 getFactory().recycle(dateRange);
378             } catch (NotesException e) {
379                 throw newRuntimeException("Cannot set calendar value", e);
380             }
381         }
382     }
383 
384     /***
385      * {@inheritDoc}
386      * @see de.bea.domingo.DItem#setValueDouble(double)
387      */
388     public void setValueDouble(final double d) {
389         getFactory().preprocessMethod();
390         try {
391             getItem().setValueDouble(d);
392         } catch (NotesException e) {
393             throw newRuntimeException("setValueDouble(double): ", e);
394         }
395     }
396 
397     /***
398      * {@inheritDoc}
399      * @see de.bea.domingo.DItem#setValueDouble(java.lang.Double)
400      */
401     public void setValueDouble(final Double d) {
402         if (d == null) {
403             setValueString("");
404         } else {
405             setValueDouble(d.doubleValue());
406         }
407     }
408 
409     /***
410      * {@inheritDoc}
411      * @see de.bea.domingo.DItem#setValueInteger(int)
412      */
413     public void setValueInteger(final int i) {
414         getFactory().preprocessMethod();
415         try {
416             getItem().setValueInteger(i);
417         } catch (NotesException e) {
418             throw newRuntimeException("Cannot set integer value", e);
419         }
420     }
421 
422     /***
423      * {@inheritDoc}
424      * @see de.bea.domingo.DItem#setValueInteger(java.lang.Integer)
425      */
426     public void setValueInteger(final Integer i) {
427         if (i == null) {
428             setValueString("");
429         } else {
430             setValueInteger(i.intValue());
431         }
432     }
433 
434     /***
435      * {@inheritDoc}
436      * @see de.bea.domingo.DItem#setValues(java.util.List)
437      */
438     public void setValues(final List values) {
439         if (values == null) {
440             setValueString("");
441             return;
442         }
443         getFactory().preprocessMethod();
444         final int size = getValueSize(values);
445         if (size > MAX_VALUE_SIZE) {
446             throw newRuntimeException("Value size cannot be bigger than 15k: " + size);
447         }
448         final List convertedKeys = convertCalendarsToNotesDateTime(values);
449         final Vector vector = convertListToVector(convertedKeys);
450         try {
451             getItem().setValues(vector);
452         } catch (NotesException e) {
453             throw newRuntimeException("Cannot set value list", e);
454         } finally {
455             recycleDateTimeList(convertedKeys);
456         }
457     }
458 
459     /***
460      * Estimates size of list of values.
461      *
462      * @param values a list of values
463      * @return estimated size of value.
464      */
465     private int getValueSize(final List values) {
466         final Iterator i = values.iterator();
467         int size = 0;
468         while (i.hasNext()) {
469             size = size + getValueSize(i.next()) + VALUE_SEPERATOR_SIZE;
470         }
471         return size;
472     }
473 
474     /***
475      * Estimates the size of a value.
476      *
477      * @param value a value
478      * @return estimated size a the value.
479      * @throws DNotesRuntimeException if the type the value is unknown
480      */
481     private int getValueSize(final Object value) throws DNotesRuntimeException {
482         if (value == null) {
483             return 0;
484         } else if (value instanceof String) {
485             return ((String) value).length();
486         } else if (value instanceof Integer) {
487             return VALUE_SIZE_NUMBER;
488         } else if (value instanceof Double) {
489             return VALUE_SIZE_NUMBER;
490         } else if (value instanceof Calendar) {
491             return VALUE_SIZE_CALENDAR;
492         } else {
493             throw newRuntimeException("Unknown value type: " + value.getClass().getName());
494         }
495     }
496 
497     /***
498      * {@inheritDoc}
499      * @see de.bea.domingo.DItem#setValueString(java.lang.String)
500      */
501     public void setValueString(final String value) {
502         getFactory().preprocessMethod();
503         final int size = getValueSize(value);
504         if (size > MAX_VALUE_SIZE) {
505             throw newRuntimeException("Value size cannot be bigger than 15k: " + size);
506         }
507         try {
508             getItem().setValueString(value);
509         } catch (NotesException e) {
510             throw newRuntimeException("Cannot set string value", e);
511         }
512     }
513 
514     /***
515      * {@inheritDoc}
516      * @see de.bea.domingo.DItem#isSummary()
517      */
518     public boolean isSummary() {
519         getFactory().preprocessMethod();
520         try {
521             return getItem().isSummary();
522         } catch (NotesException e) {
523             throw newRuntimeException("Cannot get summary flag", e);
524         }
525     }
526 
527     /***
528      * {@inheritDoc}
529      * @see de.bea.domingo.DItem#setSummary(boolean)
530      */
531     public void setSummary(final boolean flag) {
532         getFactory().preprocessMethod();
533         try {
534             getItem().setSummary(flag);
535         } catch (NotesException e) {
536             throw newRuntimeException("Cannot set summary flag", e);
537         }
538     }
539 
540     /***
541      * {@inheritDoc}
542      * @see de.bea.domingo.DItem#isNames()
543      */
544     public boolean isNames() {
545         getFactory().preprocessMethod();
546         try {
547             return getItem().isNames();
548         } catch (NotesException e) {
549             throw newRuntimeException("Cannot get names flag", e);
550         }
551     }
552 
553     /***
554      * {@inheritDoc}
555      * @see de.bea.domingo.DItem#setNames(boolean)
556      */
557     public void setNames(final boolean flag) {
558         getFactory().preprocessMethod();
559         try {
560             getItem().setNames(flag);
561         } catch (NotesException e) {
562             throw newRuntimeException("Cannot set names flag", e);
563         }
564     }
565 
566     /***
567      * {@inheritDoc}
568      * @see de.bea.domingo.DItem#isReaders()
569      */
570     public boolean isReaders() {
571         getFactory().preprocessMethod();
572         try {
573             return getItem().isReaders();
574         } catch (NotesException e) {
575             throw newRuntimeException("Cannot get readers flag", e);
576         }
577     }
578 
579     /***
580      * {@inheritDoc}
581      * @see de.bea.domingo.DItem#setReaders(boolean)
582      */
583     public void setReaders(final boolean flag) {
584         getFactory().preprocessMethod();
585         try {
586             getItem().setReaders(flag);
587         } catch (NotesException e) {
588             throw newRuntimeException("Cannot set readers flag", e);
589         }
590     }
591 
592     /***
593      * {@inheritDoc}
594      * @see de.bea.domingo.DItem#isAuthors()
595      */
596     public boolean isAuthors() {
597         getFactory().preprocessMethod();
598         try {
599             return getItem().isAuthors();
600         } catch (NotesException e) {
601             throw newRuntimeException("Cannot get authors flag", e);
602         }
603     }
604 
605     /***
606      * {@inheritDoc}
607      * @see de.bea.domingo.DItem#setAuthors(boolean)
608      */
609     public void setAuthors(final boolean flag) {
610         getFactory().preprocessMethod();
611         try {
612             getItem().setAuthors(flag);
613         } catch (NotesException e) {
614             throw newRuntimeException("Cannot set authors flag", e);
615         }
616     }
617 
618     /***
619      * {@inheritDoc}
620      * @see de.bea.domingo.DItem#getSize()
621      */
622     public int getSize() {
623         getFactory().preprocessMethod();
624         try {
625             return getItem().getValues().size();
626         } catch (NotesException e) {
627             throw newRuntimeException("Cannot get item size", e);
628         }
629     }
630 
631     /***
632      * {@inheritDoc}
633      * @see de.bea.domingo.DItem#isProtected()
634      */
635     public boolean isProtected() {
636         getFactory().preprocessMethod();
637         try {
638             return getItem().isProtected();
639         } catch (NotesException e) {
640             throw newRuntimeException("Cannot set protection flag", e);
641         }
642     }
643 
644     /***
645      * {@inheritDoc}
646      * @see de.bea.domingo.DItem#setProtected(boolean)
647      */
648     public void setProtected(final boolean flag) {
649         getFactory().preprocessMethod();
650         try {
651             getItem().setProtected(flag);
652         } catch (NotesException e) {
653             throw newRuntimeException("Cannot get protection flag", e);
654         }
655     }
656 
657     /***
658      * {@inheritDoc}
659      * @see de.bea.domingo.DItem#abstractText(int, boolean, boolean)
660      */
661     public String abstractText(final int maxlen, final boolean dropVowels, final boolean userDict) {
662         getFactory().preprocessMethod();
663         try {
664             return getItem().abstractText(maxlen, dropVowels, userDict);
665         } catch (NotesException e) {
666             throw newRuntimeException("Cannot abstract text", e);
667         }
668     }
669 
670     /***
671      * {@inheritDoc}
672      * @see de.bea.domingo.DItem#copyItemToDocument(de.bea.domingo.DDocument)
673      */
674     public DItem copyItemToDocument(final DDocument document) {
675         getFactory().preprocessMethod();
676         if (!(document instanceof DocumentProxy)) {
677             throw newRuntimeException("invalid document");
678         }
679         try {
680             Document notesDocument = (Document) ((DocumentProxy) document).getNotesObject();
681             Item item = ((Item) getNotesObject()).copyItemToDocument(notesDocument);
682             return (DItem) ItemProxy.getInstance(getFactory(), document, item, getMonitor());
683         } catch (NotesException e) {
684             throw newRuntimeException("Cannot copy to document", e);
685         }
686     }
687 
688     /***
689      * {@inheritDoc}
690      * @see de.bea.domingo.DItem#copyItemToDocument(de.bea.domingo.DDocument, java.lang.String)
691      */
692     public DItem copyItemToDocument(final DDocument document, final String newName) {
693         getFactory().preprocessMethod();
694         try {
695             Document notesDocument = (Document) ((DocumentProxy) document).getNotesObject();
696             Item item = ((Item) getNotesObject()).copyItemToDocument(notesDocument, newName);
697             return (DItem) ItemProxy.getInstance(getFactory(), document, item, getMonitor());
698         } catch (NotesException e) {
699             throw newRuntimeException("Cannot copy to document", e);
700         }
701     }
702 
703     /***
704      * {@inheritDoc}
705      * @see de.bea.domingo.DItem#getLastModified()
706      */
707     public Calendar getLastModified() {
708         getFactory().preprocessMethod();
709         try {
710             DateTime dateTime = getItem().getLastModified();
711             if (dateTime != null) {
712                 final Calendar calendar = createCalendar(dateTime);
713                 getFactory().recycle(dateTime);
714                 return calendar;
715             }
716         } catch (NotesException e) {
717             throw newRuntimeException("Cannot get last modified date", e);
718         }
719         return null;
720     }
721 
722     /***
723      * {@inheritDoc}
724      * @see de.bea.domingo.DItem#getText()
725      */
726     public String getText() {
727         getFactory().preprocessMethod();
728         try {
729             return getItem().getText();
730         } catch (NotesException e) {
731             throw newRuntimeException("Cannot get text", e);
732         }
733     }
734 
735     /***
736      * {@inheritDoc}
737      * @see de.bea.domingo.DItem#getText(int)
738      */
739     public String getText(final int maxLen) {
740         getFactory().preprocessMethod();
741         try {
742             return getItem().getText(maxLen);
743         } catch (NotesException e) {
744             throw newRuntimeException("Cannot get text", e);
745         }
746     }
747 
748     /***
749      * {@inheritDoc}
750      * @see de.bea.domingo.DItem#getType()
751      */
752     public int getType() {
753         getFactory().preprocessMethod();
754         try {
755             return getItem().getType();
756         } catch (NotesException e) {
757             throw newRuntimeException("Cannot get type", e);
758         }
759     }
760 
761     /***
762      * {@inheritDoc}
763      * @see de.bea.domingo.DItem#getValueLength()
764      */
765     public int getValueLength() {
766         getFactory().preprocessMethod();
767         try {
768             return getItem().getValueLength();
769         } catch (NotesException e) {
770             throw newRuntimeException("Cannot get value length", e);
771         }
772     }
773 
774     /***
775      * {@inheritDoc}
776      * @see de.bea.domingo.DItem#setValueCustomData(java.lang.String, java.lang.Object)
777      */
778     public void setValueCustomData(final String type, final Object obj) {
779         getFactory().preprocessMethod();
780         try {
781             getItem().setValueCustomData(type, obj);
782         } catch (NotesException e) {
783             throw newRuntimeException("Cannot set custom data", e);
784         } catch (IOException e) {
785             throw newRuntimeException("Cannot set custom data", e);
786         }
787     }
788 
789     /***
790      * {@inheritDoc}
791      * @see de.bea.domingo.DItem#setValueCustomData(java.lang.Object)
792      */
793     public void setValueCustomData(final Object obj) {
794         getFactory().preprocessMethod();
795         try {
796             getItem().setValueCustomData(obj);
797         } catch (NotesException e) {
798             throw newRuntimeException("Cannot set custom data", e);
799         } catch (IOException e) {
800             throw newRuntimeException("Cannot set custom data", e);
801         }
802     }
803 
804     /***
805      * {@inheritDoc}
806      * @see de.bea.domingo.DItem#setValueCustomDataBytes(java.lang.String, byte[])
807      */
808     public void setValueCustomDataBytes(final String type, final byte[] bytes) {
809         getFactory().preprocessMethod();
810         try {
811             getItem().setValueCustomData(type, bytes);
812         } catch (NotesException e) {
813             throw newRuntimeException("Cannot set custom data bytes", e);
814         } catch (IOException e) {
815             throw newRuntimeException("Cannot set custom data bytes", e);
816         }
817     }
818 
819     /***
820      * {@inheritDoc}
821      * @see de.bea.domingo.DItem#getValueCustomData(java.lang.String)
822      */
823     public Object getValueCustomData(final String type) {
824         getFactory().preprocessMethod();
825         try {
826             return getItem().getValueCustomData(type);
827         } catch (NotesException e) {
828             throw newRuntimeException("Cannot get custom data", e);
829         } catch (IOException e) {
830             throw newRuntimeException("Cannot get custom data", e);
831         } catch (ClassNotFoundException e) {
832             throw newRuntimeException("Cannot get custom data", e);
833         }
834     }
835 
836     /***
837      * {@inheritDoc}
838      * @see de.bea.domingo.DItem#getValueCustomData()
839      */
840     public Object getValueCustomData() {
841         getFactory().preprocessMethod();
842         try {
843             return getItem().getValueCustomData();
844         } catch (NotesException e) {
845             throw newRuntimeException("Cannot get custom data", e);
846         } catch (IOException e) {
847             throw newRuntimeException("Cannot get custom data", e);
848         } catch (ClassNotFoundException e) {
849             throw newRuntimeException("Cannot get custom data", e);
850         }
851     }
852 
853     /***
854      * {@inheritDoc}
855      * @see de.bea.domingo.DItem#getValueCustomDataBytes(java.lang.String)
856      */
857     public byte[] getValueCustomDataBytes(final String type) {
858         getFactory().preprocessMethod();
859         try {
860             return getItem().getValueCustomDataBytes(type);
861         } catch (NotesException e) {
862             throw newRuntimeException("Cannot get custom data bytes", e);
863         } catch (IOException e) {
864             throw newRuntimeException("Cannot get custom data bytes", e);
865         }
866     }
867 
868     /***
869      * {@inheritDoc}
870      * @see de.bea.domingo.DItem#isEncrypted()
871      */
872     public boolean isEncrypted() {
873         getFactory().preprocessMethod();
874         try {
875             return getItem().isEncrypted();
876         } catch (NotesException e) {
877             throw newRuntimeException("Cannot check if is encrypted", e);
878         }
879     }
880 
881     /***
882      * {@inheritDoc}
883      * @see de.bea.domingo.DItem#setEncrypted(boolean)
884      */
885     public void setEncrypted(final boolean flag) {
886         getFactory().preprocessMethod();
887         try {
888             getItem().setEncrypted(flag);
889         } catch (NotesException e) {
890             throw newRuntimeException("Cannot set encrypted", e);
891         }
892     }
893 
894     /***
895      * {@inheritDoc}
896      * @see de.bea.domingo.DItem#isSaveToDisk()
897      */
898     public boolean isSaveToDisk() {
899         getFactory().preprocessMethod();
900         try {
901             return getItem().isSaveToDisk();
902         } catch (NotesException e) {
903             throw newRuntimeException("Cannot check if is saved to disk", e);
904         }
905     }
906 
907     /***
908      * {@inheritDoc}
909      * @see de.bea.domingo.DItem#setSaveToDisk(boolean)
910      */
911     public void setSaveToDisk(final boolean flag) {
912         getFactory().preprocessMethod();
913         try {
914             getItem().setSaveToDisk(flag);
915         } catch (NotesException e) {
916             throw newRuntimeException("Cannot set saved to disk", e);
917         }
918     }
919 
920     /***
921      * {@inheritDoc}
922      * @see de.bea.domingo.DItem#isSigned()
923      */
924     public boolean isSigned() {
925         getFactory().preprocessMethod();
926         try {
927             return getItem().isSigned();
928         } catch (NotesException e) {
929             throw newRuntimeException("Cannot check if is signed", e);
930         }
931     }
932     /***
933      * {@inheritDoc}
934      * @see de.bea.domingo.DItem#setSigned(boolean)
935      */
936     public void setSigned(final boolean flag) {
937         getFactory().preprocessMethod();
938         try {
939             getItem().setSigned(flag);
940         } catch (NotesException e) {
941             throw newRuntimeException("Cannot set signed", e);
942         }
943     }
944 
945     /***
946      * {@inheritDoc}
947      * @see de.bea.domingo.DItem#getReader()
948      */
949     public Reader getReader() {
950         getFactory().preprocessMethod();
951         try {
952             return getItem().getReader();
953         } catch (NotesException e) {
954             throw newRuntimeException("Cannot get reader", e);
955         }
956     }
957 
958     /***
959      * {@inheritDoc}
960      * @see de.bea.domingo.DItem#getInputStream()
961      */
962     public InputStream getInputStream() {
963         getFactory().preprocessMethod();
964         try {
965             return getItem().getInputStream();
966         } catch (NotesException e) {
967             throw newRuntimeException("Cannot get input stream", e);
968         }
969     }
970 
971     /***
972      * {@inheritDoc}
973      * @see de.bea.domingo.DItem#setValueDateTime(java.util.TimeZone)
974      */
975     public void setValueDateTime(final TimeZone value) {
976         String s = "";
977         if (value == null) {
978             getMonitor().warn("time zone is null; storing an empty string");
979         } else {
980             s = Timezones.getLotusTimeZoneString(value);
981             if (s.startsWith("Unknown")) {
982                 getMonitor().warn("Unknown time zone identifier (using default): " + value.getID());
983                 s = TimeZone.getDefault().getID();
984                 s = Timezones.getLotusTimeZoneString(s);
985             }
986         }
987         setValueString(s);
988     }
989 }