diff options
| author | Andrew Branson <andrew.branson@cern.ch> | 2014-10-03 17:30:41 +0200 |
|---|---|---|
| committer | Andrew Branson <andrew.branson@cern.ch> | 2014-10-03 17:30:41 +0200 |
| commit | 275d0bbf555c8917be82ce4cc21eb4cabb00f4c5 (patch) | |
| tree | ddcc6b14077d90d1b970b67829f07120547dbb62 /src/main/java/com/c2kernel/collection/Collection.java | |
| parent | a139f95bfeca603333b8c0310ae09c6805e58584 (diff) | |
Huge exception overhaul: Merged ClusterStorageException with
PersistencyException. Replaced MembershipException with
InvalidCollectionModification CORBA Exception. Made all predef steps
throw more accurate exceptions when they go wrong, and let more
exceptions bubble through from underneath.
Diffstat (limited to 'src/main/java/com/c2kernel/collection/Collection.java')
| -rw-r--r-- | src/main/java/com/c2kernel/collection/Collection.java | 46 |
1 files changed, 35 insertions, 11 deletions
diff --git a/src/main/java/com/c2kernel/collection/Collection.java b/src/main/java/com/c2kernel/collection/Collection.java index 355fa1c..fa0230b 100644 --- a/src/main/java/com/c2kernel/collection/Collection.java +++ b/src/main/java/com/c2kernel/collection/Collection.java @@ -22,15 +22,39 @@ package com.c2kernel.collection; import java.util.Iterator;
-import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.common.InvalidCollectionModification;
+import com.c2kernel.common.ObjectAlreadyExists;
+import com.c2kernel.common.ObjectNotFound;
import com.c2kernel.entity.C2KLocalObject;
+import com.c2kernel.graph.model.GraphModel;
import com.c2kernel.lookup.ItemPath;
import com.c2kernel.persistency.ClusterStorage;
import com.c2kernel.utils.CastorHashMap;
/**
- * @version $Revision: 1.23 $ $Date: 2004/05/14 15:39:39 $
- * @author $Author: abranson $
+ * Collections are Item local objects that reference other Items.
+ *
+ * <p>In parallel with the OO meta-model, Items can be linked to other Items in
+ * different ways. These links are modelled with Collections, which are local
+ * objects stored in an Item which reference a number of other Items in the same
+ * server. The Collections holds a CollectionMember, sometimes known as a slot,
+ * to reference each Item and store additional information about the link.
+ *
+ * <p>Features:
+ * <ul>
+ * <li><b>Typing</b> - Collections can restrict membership of based on type
+ * information derived from Item, Property and Collection descriptions. This
+ * restriction may be per-slot or apply to the whole Collection.
+ *
+ * <li><b>Fixed or flexible slots</b> - The CollectionMember objects of a
+ * Collection may be empty, individually typed, or created and removed as
+ * required, simulating either array, structures or lists.
+ *
+ * <li><b>Layout</b> - Collections can include a {@link GraphModel} to lay out
+ * its slots on a two-dimensional canvas, for modelling real world compositions.
+ * </ul>
+ *
+ * <p>Collections are managed through predefined steps.
*/
abstract public class Collection<E extends CollectionMember> implements C2KLocalObject
{
@@ -131,12 +155,12 @@ abstract public class Collection<E extends CollectionMember> implements C2KLocal return true;
}
- public E getMember(int memberId) throws ObjectNotFoundException {
+ public E getMember(int memberId) throws ObjectNotFound {
for (E element : mMembers.list) {
if (element.getID() == memberId)
return element;
}
- throw new ObjectNotFoundException("Member "+memberId+" not found in "+mName, "");
+ throw new ObjectNotFound("Member "+memberId+" not found in "+mName);
}
public CollectionMemberList<E> getMembers()
@@ -144,12 +168,10 @@ abstract public class Collection<E extends CollectionMember> implements C2KLocal return mMembers;
}
- public abstract E addMember(ItemPath itemPath, CastorHashMap props, String classProps) throws MembershipException;
-
- public abstract E addMember(ItemPath itemPath) throws MembershipException;
-
- public abstract void removeMember(int memberId) throws MembershipException;
+ public abstract E addMember(ItemPath itemPath, CastorHashMap props, String classProps) throws InvalidCollectionModification, ObjectAlreadyExists;
+ public abstract void removeMember(int memberId) throws ObjectNotFound;
+
@Override
public boolean equals(Object other) {
if (!(other instanceof Collection<?>)) return false;
@@ -161,10 +183,12 @@ abstract public class Collection<E extends CollectionMember> implements C2KLocal E thisMem = i.next();
CollectionMember otherMem = otherColl.getMember(thisMem.getID());
if (!thisMem.equals(otherMem)) return false;
- } catch (ObjectNotFoundException ex) {
+ } catch (ObjectNotFound ex) {
return false;
}
}
return true;
}
+
+
}
|
