summaryrefslogtreecommitdiff
path: root/src/main/java/com/c2kernel/collection/Collection.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/c2kernel/collection/Collection.java')
-rw-r--r--src/main/java/com/c2kernel/collection/Collection.java46
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;
}
+
+
}