org.jutil.structure
Class StructureSet

java.lang.Object
  |
  +--org.jutil.structure.StructureSet

public class StructureSet
extends java.lang.Object

A class of "components" for inplementing a 1-n binding. This class is the 1 side of the binding (the side where the "n" is in a UML diagram).

This is actually a lightweight version of the APSet-APElement combination of the Beedra framework of Jan Dockx.

This class is typically using in the following way. See class StructureElement for class B.


public class A {

public A() {
$b= new StructureSet(this);
}

public Set getBs() {
return $b.getOtherEnds();
}

public void addB(B b) {
$b.add(b.getALink());
}

public void removeB(B b) {
$b.remove(b.getALink());
}

private StructureSet $b;
}
 

Version:
$Revision: 1.5 $
Author:
Marko van Dooren

Field Summary
static java.lang.String CVS_REVISION
           
 
Constructor Summary
StructureSet(java.lang.Object object)
          public invariant (\forall StructureElement e; contains(e);
e.getStructureSet() == this);

public behavior

pre object != null;

post getObject() == object;
post (\forall StructuredElement s;; !contains(s));
Initialize an empty StructureSet for the given object.
 
Method Summary
 void add(StructureElement element)
          public behavior

pre element != null;

post element.getStructuredSet() == this;
post \old(element.getStructuredSet()) != null &&
\old(element.getStructuredSet()) != this ==>
! \old(element.getStructuredSet()).contains(element);
post contains(element);
Remove the given StructureElement from this StructureSet.
 boolean contains(StructureElement element)
          Check whether or not the given element is connected to this StructureSet.
 java.lang.Object getObject()
          Return the object at the 1 side of the 1-n binding.
 java.util.Set getOtherEnds()
          public behavior

post (\forall Object o;;
\result.contains(o) <=>
(\exists StructureElement s; contains(s);
s.getObject().equals(o)));
post \result != null;
Return a set containing the objects at the n side of the 1-n binding.
 java.util.Set getStructureElements()
          public behavior

post (\forall StructuredElement s;;
contains(s) <=> \result.contains(s));
post \result != null;
Return a set containing the StructureElements at the n side of the 1-n binding.
 void remove(StructureElement element)
          public behavior

post contains(element) ==> element.getStructuredSet() == null;
post contains(element) ==> ! contains(element);
Add the given StructureElement to this StructureSet.
 int size()
          public behavior

post \reulst == (\num_of StructureElement e; contains(e); 1);
Return the size of the StructureSet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CVS_REVISION

public static final java.lang.String CVS_REVISION
Constructor Detail

StructureSet

public StructureSet(java.lang.Object object)
public invariant (\forall StructureElement e; contains(e);
e.getStructureSet() == this);

public behavior

pre object != null;

post getObject() == object;
post (\forall StructuredElement s;; !contains(s));
Initialize an empty StructureSet for the given object.
Parameters:
object - The 1 side of the 1-n binding
Method Detail

getObject

public java.lang.Object getObject()
Return the object at the 1 side of the 1-n binding.

remove

public void remove(StructureElement element)
public behavior

post contains(element) ==> element.getStructuredSet() == null;
post contains(element) ==> ! contains(element);
Add the given StructureElement to this StructureSet.
Parameters:
element - The StructureElement to be added.

add

public void add(StructureElement element)
public behavior

pre element != null;

post element.getStructuredSet() == this;
post \old(element.getStructuredSet()) != null &&
\old(element.getStructuredSet()) != this ==>
! \old(element.getStructuredSet()).contains(element);
post contains(element);
Remove the given StructureElement from this StructureSet.
Parameters:
element - The StructureElement to be removed.

getOtherEnds

public java.util.Set getOtherEnds()
public behavior

post (\forall Object o;;
\result.contains(o) <=>
(\exists StructureElement s; contains(s);
s.getObject().equals(o)));
post \result != null;
Return a set containing the objects at the n side of the 1-n binding.

getStructureElements

public java.util.Set getStructureElements()
public behavior

post (\forall StructuredElement s;;
contains(s) <=> \result.contains(s));
post \result != null;
Return a set containing the StructureElements at the n side of the 1-n binding.

size

public int size()
public behavior

post \reulst == (\num_of StructureElement e; contains(e); 1);
Return the size of the StructureSet

contains

public boolean contains(StructureElement element)
Check whether or not the given element is connected to this StructureSet.
Parameters:
element - The element of which one wants to know if it is in this StructureSet.