![]() |
|||||
|
How to set/retrieve reference values?The way you retrieve the objects of a reference is very similar to the way you retrieve attribute values. refGetValue() returns a collection of all referenced objects. The collection operations add(), remove(), iterator() allow you to process the objects contained in the collection. The following example shows how to retrieve referenced objects. Example 6-6. Retrieve group instances of the reference group of a Person instance // retrieve all group instances Collection groups = (Collection)person.refGetValue( "org:openmdx:example:lab1:Person:group" ); // in case the reference is stored as attribute and is indexed, // the group instance at the specified index can be retrieved like this List groups = (List)person.refGetValue( "org:openmdx:example:lab1:Person:group" ); Group group = groups.get(index); The following example shows how to add a new object to a given reference. Example 6-7. Add a group instance to the reference group of a Person instance // add a specified group instance Collection groups = (Collection)person.refGetValue( "org:openmdx:example:lab1:Person:group" ); groups.add(group); // in case the reference is stored as attribute and is indexed, // a group instance can be added at a specified index List groups = (List)person.refGetValue( "org:openmdx:example:lab1:Person:group" ); groups.add(index, group); The following example shows how to remove an existing object. Example 6-8. Remove a group instance from the reference group of a Person instance // remove a specified group instance Collection groups = (Collection)person.refGetValue( "org:openmdx:example:lab1:Person:group" ); groups.remove(group); // in case the reference is stored as attribute and is indexed, // a group instance can be remove at a specified index List groups = (List)person.refGetValue( "org:openmdx:example:lab1:Person:group" ); groups.remove(index);
The openMDX RefObject_1_0 interface extends the JMI RefObject interface which defines the additional operations:
|
||||