1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.caleigo.core;
20
21 import java.util.*;
22
23 import org.caleigo.core.event.*;
24
25 /*** IEntityCollection defines the interface to entity collection class that can
26 * store zero or more IEntity objects. The entities stored by this interface
27 * are type specified and must be defined by a single IEntityDescriptor.
28 *
29 * IEntityCollection is ordered and contained entities can be accesed by index.
30 * Implementations to this interface must not accept duplicate entities.
31 *
32 * @author Dennis Zikovic
33 * @version 1.00
34 *
35 *//*
36 *
37 * WHEN WHO WHY & WHAT
38 * ------------------------------------------------------------------------------
39 * 2001-10-10 Dennis Zikovic Creation
40 */
41 public interface ISelection extends IEntityPool
42 {
43
44
45 /*** Return true if any (one or more) of the collections's contained
46 * entities has the DIRTY flag set to true that is have unsaved changes.
47 */
48 public boolean isDirty();
49
50 /*** Stores all contained entities that have the DIRTY flag set to true.
51 * The entities are stored in a single transaction meaning that if one
52 * store fails then all fails.
53 */
54 public void storeAll();
55
56 /*** Deletes all contained entities. The entities are deleted in a single
57 * transaction meaning that if one delete fails then all fails.
58 * USE THIS METHOD WITH CAUTION.
59 */
60 public void deleteAll();
61
62 /*** Performs a refresh on all contained entities. The refresh is batched
63 * to save performance.
64 */
65 public void refreshAll();
66
67
68
69 /*** Adds the provided IEntity object to the end of selection object.
70 * If an entity with the same identity already exists in the selection the
71 * requeat is ignored and false is returned.
72 */
73 public boolean addEntity(IEntity entity);
74
75 /*** Adds the provided IEntity object to at the specified index in the
76 * selection object. If an entity with the same identity already exists
77 * in the selection the requeat is ignored and false is returned.
78 */
79 public boolean addEntity(int index, IEntity entity);
80
81 /*** Access method that returns the contained IEntity object with the
82 * specified index.
83 */
84 public IEntity getEntity(int index);
85
86 /*** Mutation method that removes the provided entity from the selection.
87 * Returns true if the entity was found and removed otherwise false is
88 * returned.
89 */
90 public boolean removeEntity(IEntity entity);
91
92 /*** Mutation method that removes the indexed entity from the selection.
93 * Returns the indexed entity if it was found and removed otherwise null
94 * is returned. The entities are not effecte in any other way.
95 */
96 public IEntity removeEntity(int index);
97
98 /*** Returns a java.util.Iterator object that iterates over all entities
99 * in the selection. The iterator should be read only and should not
100 * support the remove method. The entities are not effected in any other way.
101 */
102 public Iterator iterator();
103
104 /*** Mutation method the removes all entities currently stored in the
105 * selection. The entities are not effected in any other way.
106 */
107 public void clear();
108
109 /*** Access method that reurns the number entities currently contained in
110 * the selection object.
111 */
112 public int size();
113
114 /*** Boolean access method that return true if the selection is empty.
115 */
116 public boolean isEmpty();
117
118 /*** Access method that views the selection objct as a grid where row is
119 * the entity index and column is the field index for the stored entities.
120 */
121 public Object getData(int row, int column);
122
123 /*** Mutation method that views the selection objct as a grid where row is
124 * the entity index and column is the field index for the stored entities.
125 */
126 public void setData(int row, int column, Object dataValue);
127
128 /*** Access method that returns the IEntityDescriptor for the selection.
129 * The selection object will only support entities of that type.
130 */
131 public IEntityDescriptor getEntityDescriptor();
132
133 /*** Adds an IEntityCollectionListener to receive notifiactions of changes
134 * in the entity content of the collection object.
135 */
136 public void addSelectionListener(ISelectionListener listener);
137
138 /*** Removes an IEntityCollectionListener from the collection object.
139 */
140 public void removeSelectionListener(ISelectionListener listener);
141
142 /*** Adds IEntityListener to receive notifications of performed
143 * data operations on all entities contained in the collection object.
144 */
145 public void addEntityListener(IEntityListener listener);
146
147 /*** Removes the specified IEntityListener from the collection object.
148 */
149 public void removeEntityListener(IEntityListener listener);
150
151 /*** Adds IEntityChangeListener to receive notifications of performed
152 * data operations on all entities contained in the collection object.
153 * Note that changes can in specific situations like during end-user
154 * editation be very frequent.
155 */
156 public void addEntityChangeListener(IEntityChangeListener listener);
157
158 /*** Removes the specified IEntityListener from the collection object.
159 */
160 public void removeEntityChangeListener(IEntityChangeListener listener);
161
162
163
164 /*** Creates a sub selection with the indexed entities in the called
165 * selection. The created selection that should be independant of changes
166 * in the source/called selection after the time of creation.
167 */
168 public ISelection createSubSelection(int[] indexArray);
169
170 /*** Creates a sub selection with all qualified entities in the called
171 * selection. The created selection that should be independant of changes
172 * in the source/called selection after the time of creation.
173 */
174 public ISelection createSubSelection(Qualifier qualifier);
175
176 /*** Help method that returns true if the provided IEntity object exists in
177 * the selection otherwise false is returned.
178 */
179 public boolean contains(IEntity entity);
180
181 /*** Help method that returns the index of the provided IEntity object in
182 * the selection if it exists othewise a negative value is returned.
183 */
184 public int indexOf(IEntity entity);
185
186 /*** Help method that returns the index of the the first entity object in
187 * the selection with the specified field set to the specified value.
188 */
189 public int indexOf(IFieldDescriptor fieldDescriptor, Object fieldData);
190
191 /*** Help method that returns true if the provided IEntity object will be
192 * accepted by the selection if added or inserted to it. Reasons for not
193 * accepting an entity is wrong type (IEntityDescriptor), already included
194 * or if selection is qualified the entity may fail qualification.
195 */
196 public boolean doesAccept(IEntity entity);
197
198 /*** This method sorts the called selection using the provided comparator.
199 * One single content change event will be fired when this method is called.
200 * Note that if the provided Comparator does not support IEntity objects
201 * an exeption will be thrown.
202 * @see EntityCollator
203 */
204 public void sort(Comparator comparator);
205
206 /*** Returns a Set that acts as a wrapper for the selection. The Set object
207 * should reflect changes to and from the wrapped selection.
208 */
209 public Set asSet();
210
211 /*** Returns a List that acts as a wrapper for the selection. The List
212 * object should reflect changes to and from the wrapped selection.
213 */
214 public List asList();
215 }