| java.lang.Object org.jpox.state.RelationshipManager
RelationshipManager | public class RelationshipManager (Code) | | Manager for relationships of a class.
Performs management of (bidirectional) relations.
If one side is set yet the other isnt, corrects the other side.
version: $Revision$ |
Method Summary | |
public void | checkConsistency() Method to check for consistency the managed relations of this object with the related objects. | protected void | checkManyToManyBidirectionalRelation(AbstractMemberMetaData mmd, ClassLoaderResolver clr, ObjectManager om, ArrayList changes) Method to check consistency of the passed field as M-N. | protected void | checkManyToOneBidirectionalRelation(AbstractMemberMetaData mmd, ClassLoaderResolver clr, ObjectManager om, Object oldValue, Object newValue) Method to check the consistency of the passed field as N-1.
Processes the case where we had an N-1 field set at this side previously to some value and now to
some other value.That is, this object was in some collection/map originally, and now should be in some
other collection/map. | protected void | checkOneToManyBidirectionalRelation(AbstractMemberMetaData mmd, ClassLoaderResolver clr, ObjectManager om, ArrayList changes) Method to check the consistency of the passed field as 1-N. | protected void | checkOneToOneBidirectionalRelation(AbstractMemberMetaData mmd, ClassLoaderResolver clr, ObjectManager om, Object oldValue, Object newValue) Method to check the consistency of the passed field as 1-1.
Processes the case where we had a 1-1 field set at this side previously to some value and now to
some other value. | public void | clearFields() Convenience method to clear all fields from being managed. | public void | process() Method to process the (bidirectional) relations for this object. | protected void | processManyToManyBidirectionalRelation(AbstractMemberMetaData mmd, ClassLoaderResolver clr, ObjectManager om, ArrayList changes) Method to process all M-N bidir fields. | protected void | processManyToOneBidirectionalRelation(AbstractMemberMetaData mmd, ClassLoaderResolver clr, ObjectManager om, Object oldValue, Object newValue) Method to process all N-1 bidir fields.
Processes the case where we had an N-1 field set at this side previously to some value and now to
some other value.That is, this object was in some collection/map originally, and now should be in some
other collection/map. | protected void | processOneToManyBidirectionalRelation(AbstractMemberMetaData mmd, ClassLoaderResolver clr, ObjectManager om, ArrayList changes) Method to process all 1-N bidir fields. | protected void | processOneToOneBidirectionalRelation(AbstractMemberMetaData mmd, ClassLoaderResolver clr, ObjectManager om, Object oldValue, Object newValue) Method to process all 1-1 bidir fields.
Processes the case where we had a 1-1 field set at this side previously to some value and now to
some other value. | public void | relationAdd(int fieldNumber, Object val) Method to register a change in the contents of a container field, with an object being added. | public void | relationChange(int fieldNumber, Object oldValue, Object newValue) Method that is called when the user calls setXXX() on a field. | public void | relationRemove(int fieldNumber, Object val) Method to register a change in the contents of a container field, with an object being removed. |
LOCALISER | final protected static Localiser LOCALISER(Code) | | Localiser for messages.
|
fieldChanges | final Map fieldChanges(Code) | | Map of bidirectional field "changes".
For 1-1, N-1 fields the "change" is actually the original value (for later comparison).
For 1-N, M-N fields the "change" is an ArrayList of RelationChange objects.
|
ownerSM | final StateManager ownerSM(Code) | | StateManager for the object we are managing the relationships for.
|
RelationshipManager | public RelationshipManager(StateManager sm)(Code) | | Constructor.
Parameters: sm - StateManager for the object that we are managing relations for. |
checkConsistency | public void checkConsistency()(Code) | | Method to check for consistency the managed relations of this object with the related objects.
|
checkManyToManyBidirectionalRelation | protected void checkManyToManyBidirectionalRelation(AbstractMemberMetaData mmd, ClassLoaderResolver clr, ObjectManager om, ArrayList changes)(Code) | | Method to check consistency of the passed field as M-N.
Parameters: mmd - MetaData for the field Parameters: clr - ClassLoader resolver Parameters: om - ObjectManager Parameters: changes - List of changes to the collection |
checkManyToOneBidirectionalRelation | protected void checkManyToOneBidirectionalRelation(AbstractMemberMetaData mmd, ClassLoaderResolver clr, ObjectManager om, Object oldValue, Object newValue)(Code) | | Method to check the consistency of the passed field as N-1.
Processes the case where we had an N-1 field set at this side previously to some value and now to
some other value.That is, this object was in some collection/map originally, and now should be in some
other collection/map. So in terms of an example this object "a" was in collection "b1.as" before and is
now in "b2.as". The following changes are likely to be necessary
- b1.getAs().remove(a) - remove it from b1.as if still present
- b2.getAs().add(a) - add it to b1.as if not present
Parameters: mmd - MetaData for the field Parameters: clr - ClassLoader resolver Parameters: om - ObjectManager Parameters: oldValue - The old value Parameters: newValue - The new value |
checkOneToManyBidirectionalRelation | protected void checkOneToManyBidirectionalRelation(AbstractMemberMetaData mmd, ClassLoaderResolver clr, ObjectManager om, ArrayList changes)(Code) | | Method to check the consistency of the passed field as 1-N.
Parameters: mmd - MetaData for the field Parameters: clr - ClassLoader resolver Parameters: om - ObjectManager Parameters: changes - List of changes to the collection |
checkOneToOneBidirectionalRelation | protected void checkOneToOneBidirectionalRelation(AbstractMemberMetaData mmd, ClassLoaderResolver clr, ObjectManager om, Object oldValue, Object newValue)(Code) | | Method to check the consistency of the passed field as 1-1.
Processes the case where we had a 1-1 field set at this side previously to some value and now to
some other value. We need to make sure that all of the affected objects are now related consistently.
Taking an example a.b = b1; a.b = b2; so A's b field is changed from b1 to b2.
The following changes are likely to be necessary
- b1.a = null - so we null out the old related objects link back to this object
- b2.oldA = null - if b2 was previously related to a different A, null out that objects link to b2
- b2.a = a - set the link from b2 back to a so it is bidirectional
Parameters: mmd - MetaData for the field Parameters: clr - ClassLoader resolver Parameters: om - ObjectManager Parameters: oldValue - The old value Parameters: newValue - The new value |
clearFields | public void clearFields()(Code) | | Convenience method to clear all fields from being managed.
|
process | public void process()(Code) | | Method to process the (bidirectional) relations for this object.
|
processManyToManyBidirectionalRelation | protected void processManyToManyBidirectionalRelation(AbstractMemberMetaData mmd, ClassLoaderResolver clr, ObjectManager om, ArrayList changes)(Code) | | Method to process all M-N bidir fields.
Parameters: mmd - MetaData for the field Parameters: clr - ClassLoader resolver Parameters: om - ObjectManager Parameters: changes - List of changes to the collection |
processManyToOneBidirectionalRelation | protected void processManyToOneBidirectionalRelation(AbstractMemberMetaData mmd, ClassLoaderResolver clr, ObjectManager om, Object oldValue, Object newValue)(Code) | | Method to process all N-1 bidir fields.
Processes the case where we had an N-1 field set at this side previously to some value and now to
some other value.That is, this object was in some collection/map originally, and now should be in some
other collection/map. So in terms of an example this object "a" was in collection "b1.as" before and is
now in "b2.as". The following changes are likely to be necessary
- b1.getAs().remove(a) - remove it from b1.as if still present
- b2.getAs().add(a) - add it to b1.as if not present
Parameters: mmd - MetaData for the field Parameters: clr - ClassLoader resolver Parameters: om - ObjectManager Parameters: oldValue - The old value Parameters: newValue - The new value |
processOneToManyBidirectionalRelation | protected void processOneToManyBidirectionalRelation(AbstractMemberMetaData mmd, ClassLoaderResolver clr, ObjectManager om, ArrayList changes)(Code) | | Method to process all 1-N bidir fields.
Parameters: mmd - MetaData for the field Parameters: clr - ClassLoader resolver Parameters: om - ObjectManager Parameters: changes - List of changes to the collection |
processOneToOneBidirectionalRelation | protected void processOneToOneBidirectionalRelation(AbstractMemberMetaData mmd, ClassLoaderResolver clr, ObjectManager om, Object oldValue, Object newValue)(Code) | | Method to process all 1-1 bidir fields.
Processes the case where we had a 1-1 field set at this side previously to some value and now to
some other value. We need to make sure that all of the affected objects are now related consistently.
Taking an example a.b = b1; a.b = b2; so A's b field is changed from b1 to b2.
The following changes are likely to be necessary
- b1.a = null - so we null out the old related objects link back to this object
- b2.oldA = null - if b2 was previously related to a different A, null out that objects link to b2
- b2.a = a - set the link from b2 back to a so it is bidirectional
Parameters: mmd - MetaData for the field Parameters: clr - ClassLoader resolver Parameters: om - ObjectManager Parameters: oldValue - The old value Parameters: newValue - The new value |
relationAdd | public void relationAdd(int fieldNumber, Object val)(Code) | | Method to register a change in the contents of a container field, with an object being added.
Parameters: fieldNumber - Number of the field Parameters: val - Value being added |
relationChange | public void relationChange(int fieldNumber, Object oldValue, Object newValue)(Code) | | Method that is called when the user calls setXXX() on a field.
Parameters: fieldNumber - Number of the field Parameters: oldValue - The old value Parameters: newValue - The new value |
relationRemove | public void relationRemove(int fieldNumber, Object val)(Code) | | Method to register a change in the contents of a container field, with an object being removed.
Parameters: fieldNumber - Number of the field Parameters: val - Value being removed |
|
|