org.jutil.structure
Class StructureElement

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

public class StructureElement
extends java.lang.Object

A class of "components" for inplementing a 1-n binding. This class is the n 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 B {
public B() {
$a = new StructureElement(this);
}

public A getA() {
return (A)$a.getOtherEnd();
}

StructureElement getALink() {
return $a;
}
private StructureElement $a;
}
 

The binding is controlled in class A. Of course you can add a setA(A a) method to class B.

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

Field Summary
static java.lang.String CVS_REVISION
           
 
Constructor Summary
StructureElement(java.lang.Object object)
          public invariant getStructureSet() != null =>
getStructureSet().contains(this);

public behavior

pre object != null;

post getObject() == object;
post getStructuredSet() == null;
Initialize a new StructureElement for the given object.
StructureElement(java.lang.Object object, StructureSet set)
          public behavior

pre object != null;

post getObject() == object;
post getStructuredSet() == set;
post set != null => set.contains(this);
Initialize a new StructureElement for the given object, connected to the given StructureSet.
 
Method Summary
 void connectTo(StructureSet set)
          public behavior

post getStructureSet() == set;
// If this StructureElement was connected before, and will now be
// connected to another StructureSet, it will be removed from the first one.
post \old(getStructureSet()) != null && \old(getStructureSet()) != set =>
! \old(getStructureSet()).contains(this);
post set != null ==> set.contains(this);
Set the 1 side of this 10n binding.
 java.lang.Object getObject()
          public behavior

post \result != null;
Return the object on the n side of the 1-n binding represented by this StructureElement
 java.lang.Object getOtherEnd()
          public behavior

post getStructureSet() == null => \result == null;
post getStructureSet() != null => \result == getStructureSet().getObject();
Return the Object at the other end of this double binding.
 StructureSet getStructureSet()
          return the set this StructureElement belongs to
 
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

StructureElement

public StructureElement(java.lang.Object object)
public invariant getStructureSet() != null =>
getStructureSet().contains(this);

public behavior

pre object != null;

post getObject() == object;
post getStructuredSet() == null;
Initialize a new StructureElement for the given object. The new StructureElement will be unconnected.
Parameters:
object - The object at the n side of the 1-n binding.

StructureElement

public StructureElement(java.lang.Object object,
                        StructureSet set)
public behavior

pre object != null;

post getObject() == object;
post getStructuredSet() == set;
post set != null => set.contains(this);
Initialize a new StructureElement for the given object, connected to the given StructureSet.
Parameters:
object - The object at the n side of the 1-n binding.
Method Detail

getOtherEnd

public java.lang.Object getOtherEnd()
public behavior

post getStructureSet() == null => \result == null;
post getStructureSet() != null => \result == getStructureSet().getObject();
Return the Object at the other end of this double binding.

connectTo

public void connectTo(StructureSet set)
public behavior

post getStructureSet() == set;
// If this StructureElement was connected before, and will now be
// connected to another StructureSet, it will be removed from the first one.
post \old(getStructureSet()) != null && \old(getStructureSet()) != set =>
! \old(getStructureSet()).contains(this);
post set != null ==> set.contains(this);
Set the 1 side of this 10n binding.
Parameters:
set - The new StructureSet this StructureElement will be connected to.

getObject

public java.lang.Object getObject()
public behavior

post \result != null;
Return the object on the n side of the 1-n binding represented by this StructureElement

getStructureSet

public StructureSet getStructureSet()
return the set this StructureElement belongs to