1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package de.bea.domingo.proxy;
24
25 import lotus.domino.Item;
26 import lotus.domino.NotesException;
27 import lotus.domino.RichTextItem;
28 import de.bea.domingo.DBase;
29 import de.bea.domingo.DBaseItem;
30 import de.bea.domingo.DNotesMonitor;
31
32 /***
33 * This class represents the Domino-Class <code>Item</code>.
34 */
35 public abstract class BaseItemProxy extends BaseProxy implements DBaseItem {
36
37 /***
38 * Constructor for DItemImpl.
39 *
40 * @param theFactory the controlling factory
41 * @param parent the parent object
42 * @param item the Notes item object
43 * @param monitor the monitor
44 */
45 protected BaseItemProxy(final NotesProxyFactory theFactory, final DBase parent,
46 final Item item, final DNotesMonitor monitor) {
47 super(theFactory, parent, item, monitor);
48 }
49
50 /***
51 * Creates or returns a cached implementation of the requested item
52 * interface.
53 *
54 * @param theFactory the controlling factory
55 * @param parent the parent object
56 * @param item the associated Notes Item
57 * @param monitor the monitor
58 *
59 * @return implementation of interface DBaseItem or null
60 */
61 static BaseItemProxy getInstance(final NotesProxyFactory theFactory, final DBase parent,
62 final Item item, final DNotesMonitor monitor) {
63 if (item == null) {
64 return null;
65 }
66 BaseItemProxy itemProxy = (BaseItemProxy) theFactory.getBaseCache().get(item);
67 if (itemProxy == null) {
68 if (item instanceof RichTextItem) {
69 itemProxy = new RichTextItemProxy(theFactory, parent, (RichTextItem) item, monitor);
70 } else {
71 itemProxy = new ItemProxy(theFactory, parent, item, monitor);
72 }
73 itemProxy.setMonitor(monitor);
74 theFactory.getBaseCache().put(item, itemProxy);
75 }
76 return itemProxy;
77 }
78
79 /***
80 * Returns the associated notes item object.
81 *
82 * @return notes item object
83 */
84 protected final Item getItem() {
85 return (Item) getNotesObject();
86 }
87
88 /***
89 * {@inheritDoc}
90 * @see de.bea.domingo.DBaseItem#getName()
91 */
92 public final String getName() {
93 getFactory().preprocessMethod();
94 try {
95 return getItem().getName();
96 } catch (NotesException e) {
97 throw newRuntimeException("Cannot get name", e);
98 }
99 }
100
101 /***
102 * {@inheritDoc}
103 * @see de.bea.domingo.DBaseItem#remove()
104 */
105 public final void remove() {
106 getFactory().preprocessMethod();
107 try {
108 getItem().remove();
109 } catch (NotesException e) {
110 throw newRuntimeException("Cannot remove item", e);
111 }
112 }
113
114 /***
115 * @see de.bea.domingo.proxy.BaseProxy#toString()
116 * @return the name of the item
117 */
118 public final String toString() {
119 return getName();
120 }
121 }