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 lotus.domino.Base;
26  import lotus.domino.Database;
27  import lotus.domino.Document;
28  import lotus.domino.DocumentCollection;
29  import lotus.domino.DxlExporter;
30  import lotus.domino.NotesException;
31  import de.bea.domingo.DBase;
32  import de.bea.domingo.DDatabase;
33  import de.bea.domingo.DDocument;
34  import de.bea.domingo.DDocumentCollection;
35  import de.bea.domingo.DDxlExporter;
36  import de.bea.domingo.DNotesException;
37  import de.bea.domingo.DNotesMonitor;
38  
39  /***
40   * Represents a view entry. A view entry describes a row in a view.
41   *
42   * @author <a href=mailto:kriede@users.sourceforge.net>Kurt Riede</a>
43   */
44  public final class DxlExporterProxy extends BaseProxy implements DDxlExporter {
45  
46      /*** serial version ID for serialization. */
47      private static final long serialVersionUID = 3978430204404511538L;
48  
49      /***
50       * Constructor.
51       *
52       * @param theFactory the controlling factory
53       * @param theParent the parent object
54       * @param viewEntry a view entry
55       * @param monitor the monitor
56       */
57      private DxlExporterProxy(final NotesProxyFactory theFactory, final DBase theParent,
58                             final DxlExporter exporter, final DNotesMonitor monitor) {
59          super(theFactory, theParent, exporter, monitor);
60      }
61  
62      /***
63       * Creates an encapsulated notes session object.
64       *
65       * @param theFactory the controlling factory
66       * @param parent the parent object
67       * @param exporter the Notes ViewEntry
68       * @param monitor the monitor
69       * @return a session object
70       */
71      public static DxlExporterProxy getInstance(final NotesProxyFactory theFactory,  final DBase parent,
72                                               final DxlExporter exporter, final DNotesMonitor monitor) {
73          if (exporter == null) {
74              return null;
75          }
76          return new DxlExporterProxy(theFactory, parent, exporter, monitor);
77      }
78  
79      /***
80       * Returns the associated Notes view entry.
81       *
82       * @return associated notes view entry
83       */
84      private DxlExporter getDxlExporter() {
85          return (DxlExporter) getNotesObject();
86      }
87  
88      /***
89       * @see java.lang.Object#toString()
90       * @return "DxlExporterProxy"
91       */
92      public String toString() {
93          return "DxlExporterProxy";
94      }
95  
96      /***
97       * {@inheritDoc}
98       * @see de.bea.domingo.DDxlExporter#exportDxl(de.bea.domingo.DDatabase)
99       */
100     public String exportDxl(final DDatabase database) throws DNotesException {
101         if (!(database instanceof BaseProxy)) {
102             throw newRuntimeException("Cannot export DXL", new ClassCastException(database.getClass().getName()));
103         }
104         try {
105             final Base notesObject = ((BaseProxy) database).getNotesObject();
106             return this.getDxlExporter().exportDxl((Database) notesObject);
107         } catch (NotesException e) {
108             throw newRuntimeException("Cannot export DXL", e);
109         }
110     }
111 
112     /***
113      * {@inheritDoc}
114      * @see de.bea.domingo.DDxlExporter#exportDxl(de.bea.domingo.DDocument)
115      */
116     public String exportDxl(final DDocument document) throws DNotesException {
117         if (!(document instanceof BaseProxy)) {
118             throw newRuntimeException("Cannot rexport DXL", new ClassCastException(document.getClass().getName()));
119         }
120         try {
121             final Base notesObject = ((BaseProxy) document).getNotesObject();
122             return this.getDxlExporter().exportDxl((Document) notesObject);
123         } catch (NotesException e) {
124             throw newRuntimeException("Cannot set systemIdexporter", e);
125         }
126     }
127 
128     /***
129      * {@inheritDoc}
130      * @see de.bea.domingo.DDxlExporter#exportDxl(de.bea.domingo.DDocumentCollection)
131      */
132     public String exportDxl(final DDocumentCollection documentCollection) throws DNotesException {
133         if (!(documentCollection instanceof BaseProxy)) {
134             throw newRuntimeException("Cannot rexport DXL", new ClassCastException(documentCollection.getClass().getName()));
135         }
136         try {
137             final Base notesObject = ((BaseProxy) documentCollection).getNotesObject();
138             return this.getDxlExporter().exportDxl((DocumentCollection) notesObject);
139         } catch (NotesException e) {
140             throw newRuntimeException("Cannot export DXL", e);
141         }
142     }
143 
144     /***
145      * {@inheritDoc}
146      * @see de.bea.domingo.DDxlExporter#getOutputDOCTYPE()
147      */
148     public boolean getOutputDOCTYPE() {
149         try {
150             return this.getDxlExporter().getOutputDOCTYPE();
151         } catch (NotesException e) {
152             throw newRuntimeException("Cannot get output systemId", e);
153         }
154     }
155 
156     /***
157      * {@inheritDoc}
158      * @see de.bea.domingo.DDxlExporter#setOutputDoctype(boolean)
159      */
160     public void setOutputDoctype(final boolean flag) {
161         try {
162             this.getDxlExporter().setOutputDOCTYPE(flag);
163         } catch (NotesException e) {
164             throw newRuntimeException("Cannot set output systemId", e);
165         }
166     }
167 
168     /***
169      * {@inheritDoc}
170      * @see de.bea.domingo.DDxlExporter#getDoctypeSYSTEM()
171      */
172     public String getDoctypeSYSTEM() {
173         try {
174             return this.getDxlExporter().getDoctypeSYSTEM();
175         } catch (NotesException e) {
176             throw newRuntimeException("Cannot get systemIdexporter", e);
177         }
178     }
179 
180     /***
181      * {@inheritDoc}
182      * @see de.bea.domingo.DDxlExporter#setDoctypeSYSTEM(java.lang.String)
183      */
184     public void setDoctypeSYSTEM(final String systemId) {
185         try {
186             this.getDxlExporter().setDoctypeSYSTEM(systemId);
187         } catch (NotesException e) {
188             throw newRuntimeException("Cannot set systemIdexporter", e);
189         }
190     }
191 
192     /***
193      * {@inheritDoc}
194      * @see de.bea.domingo.DDxlExporter#setDoctypeSYSTEM(java.lang.String)
195      */
196     public void setConvertNotesBitmapsToGIF(final boolean flag) {
197         try {
198             this.getDxlExporter().setConvertNotesBitmapsToGIF(flag);
199         } catch (NotesException e) {
200             throw newRuntimeException("Cannot set systemIdexporter", e);
201         }
202     }
203 
204     /***
205      * {@inheritDoc}
206      * @see de.bea.domingo.DDxlExporter#getConvertNotesBitmapsToGIF()
207      */
208     public boolean getConvertNotesBitmapsToGIF() {
209         try {
210             return this.getDxlExporter().getConvertNotesBitmapsToGIF();
211         } catch (NotesException e) {
212             throw newRuntimeException("Cannot set systemIdexporter", e);
213         }
214     }
215 }