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 München (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.samples;
24
25 import java.util.Iterator;
26
27 import de.bea.domingo.DDatabase;
28 import de.bea.domingo.DNotesException;
29 import de.bea.domingo.DNotesFactory;
30 import de.bea.domingo.DSession;
31 import de.bea.domingo.DView;
32 import de.bea.domingo.DViewEntry;
33
34 /***
35 * A simple example accessing the local NAB.
36 *
37 * <p>The file notes.jar from the Lotus Notes client installation must be in the
38 * classpath to run this test.</p>
39 *
40 * @author <a href=mailto:kriede@users.sourceforge.net>Kurt Riede</a>
41 */
42 public final class LocalCallNAB {
43
44 /***
45 * Main method of sample.
46 *
47 * @param args arguments
48 * @throws DNotesException if the sample fails
49 */
50 public static void main(String[] args) throws DNotesException {
51
52 // get an instance of the domingo factory
53 DNotesFactory factory = DNotesFactory.getInstance();
54
55 // create a session to the local Lotus Notes client
56 DSession session = factory.getSession();
57
58 // get the local database names.nsf
59 DDatabase database = session.getDatabase("", "names.nsf");
60
61 // print the view ($Users) to the console
62 DView view = database.getView("($Users)");
63 Iterator allEntries = view.getAllEntries();
64 System.out.println("Content of view ($Users)");
65 while (allEntries.hasNext()) {
66 DViewEntry entry = (DViewEntry) allEntries.next();
67 for (int i = 0; i < entry.getColumnValues().size(); i++) {
68 System.out.print(entry.getColumnValues().get(i) + ", ");
69 }
70 System.out.println();
71 }
72 }
73 }