public class RelationSet
extends java.lang.Object
implements java.util.Set, java.io.Serializable
Represents a "to many" relationship, where a particular MBean attribute defines a link between that MBean and many other MBeans. All of the elements returned from a RelationSet should be of the type ObjectNameLink.
Once the initial state of a RelationSet has been obtained, it can be kept up to date with the server by registering the NotificationListener returned by the getNotificationListener() method and the NotificationFilter returned by the getNotificationFilter() method with the MBean server (e.g. mbeanServer.addNotificationListener(objectName,
relationSet.getNotificationListener(), relationSet.getNotificationFilter(), null);). Updates to the RelationSet can be handled by registering a RelationSetUpdateListener via the addUpdateListener(RelationSetUpdateListener) method.
| Constructor and Description |
|---|
RelationSet(javax.management.ObjectName sourceObjectName,
java.lang.String attributeName)
Constructs a RelationSet with the specified source ObjectName and attribte name.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(java.lang.Object object)
Adds the specified element to this set if it is not already present.
|
boolean |
addAll(java.util.Collection collection)
Adds all of the elements in the specified collection to this set if they're not already present.
|
boolean |
addUpdateListener(RelationSetUpdateListener updateListener)
Adds the specified RelationSetUpdateListener to the RelationSet.
|
void |
clear()
Removes all of the elements from this set.
|
boolean |
contains(java.lang.Object object)
Returns
true if this set contains the specified element. |
boolean |
containsAll(java.util.Collection collection)
Returns
true if this set contains all of the elements of the specified collection. |
javax.management.NotificationFilter |
getNotificationFilter()
Gets a notification filter that will only enable notifications that apply to this RelationSet.
|
javax.management.NotificationListener |
getNotificationListener()
Gets a notification listener that will automatically process any Notifications it receives to update this RelationSet's internal state.
|
boolean |
isEmpty()
Returns
true if this set contains no elements. |
java.util.Iterator |
iterator()
Returns an iterator over the elements in this set.
|
boolean |
remove(java.lang.Object object)
Removes the specified element from this set if it is present.
|
boolean |
removeAll(java.util.Collection collection)
Removes from this set all of its elements that are contained in the specified collection.
|
boolean |
removeUpdateListener(RelationSetUpdateListener updateListener)
Removes the specified RelationSetUpdateListener from the RelationSet.
|
boolean |
retainAll(java.util.Collection collection)
Retains only the elements in this set that are contained in the specified collection.
|
int |
size()
Returns the number of elements in this set (its cardinality).
|
java.lang.Object[] |
toArray()
Returns an array containing all of the elements in this set.
|
java.lang.Object[] |
toArray(java.lang.Object[] array)
Returns an array containing all of the elements in this set; the runtime type of the returned array is that of the specified array.
|
public RelationSet(javax.management.ObjectName sourceObjectName,
java.lang.String attributeName)
Constructs a RelationSet with the specified source ObjectName and attribte name.
sourceObjectName - The ObjectName of the MBean that the RelationSet belongs to.attributeName - The name of the attribute the RelationSet was obtained from.java.lang.IllegalArgumentException - If either the sourceObjectName or attributeName arguments are null.public int size()
Returns the number of elements in this set (its cardinality).
size in interface java.util.Collectionsize in interface java.util.Setpublic boolean isEmpty()
Returns true if this set contains no elements.
isEmpty in interface java.util.CollectionisEmpty in interface java.util.Settrue if this set contains no elements.public boolean contains(java.lang.Object object)
Returns true if this set contains the specified element.
contains in interface java.util.Collectioncontains in interface java.util.Setobject - Element whose presence in this set is to be tested.true if this set contains the specified element.public java.util.Iterator iterator()
Returns an iterator over the elements in this set. The elements are returned in no particular order.
iterator in interface java.lang.Iterableiterator in interface java.util.Collectioniterator in interface java.util.Setpublic java.lang.Object[] toArray()
Returns an array containing all of the elements in this set. Obeys the general contract of the Collection.toArray method.
toArray in interface java.util.CollectiontoArray in interface java.util.Setpublic java.lang.Object[] toArray(java.lang.Object[] array)
Returns an array containing all of the elements in this set; the runtime type of the returned array is that of the specified array. Obeys the general contract of the Collection.toArray(Object[]) method.
toArray in interface java.util.CollectiontoArray in interface java.util.Setarray - the array into which the elements of this set are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.java.lang.ArrayStoreException - If the runtime type of a is not a supertype of the runtime type of every element in this set.java.lang.NullPointerException - If the specified array is null.public boolean add(java.lang.Object object)
Adds the specified element to this set if it is not already present.
add in interface java.util.Collectionadd in interface java.util.Setobject - element to be added to this set.true if the set did not already contain the specified element.public boolean remove(java.lang.Object object)
Removes the specified element from this set if it is present.
remove in interface java.util.Collectionremove in interface java.util.Setobject - Object to be removed from this set, if present.true if the set contained the specified element.public boolean containsAll(java.util.Collection collection)
Returns true if this set contains all of the elements of the specified collection. If the specified collection is also a set, this method returns true if it is a subset of this set.
containsAll in interface java.util.CollectioncontainsAll in interface java.util.Setcollection - Collection to be checked for containment in this set.true if this set contains all of the elements of the specified collection.java.lang.NullPointerException - if the specified collection is null.contains(Object)public boolean addAll(java.util.Collection collection)
Adds all of the elements in the specified collection to this set if they're not already present. If the specified collection is also a set, the addAll operation effectively modifies this set so that its value is the union of the two sets. The behavior of this operation is unspecified if the specified collection is modified while the operation is in progress.
addAll in interface java.util.CollectionaddAll in interface java.util.Setcollection - Collection whose elements are to be added to this set.true if this set changed as a result of the call.java.lang.IllegalArgumentException - If some aspect of some element of the specified collection prevents it from being added to this set.add(Object)public boolean retainAll(java.util.Collection collection)
Retains only the elements in this set that are contained in the specified collection. In other words, removes from this set all of its elements that are not contained in the specified collection. If the specified collection is also a set, this operation effectively modifies this set so that its value is the intersection of the two sets.
retainAll in interface java.util.CollectionretainAll in interface java.util.Setcollection - Collection that defines which elements this set will retain.true if this collection changed as a result of the call.java.lang.NullPointerException - If the specified collection is null.remove(Object)public boolean removeAll(java.util.Collection collection)
Removes from this set all of its elements that are contained in the specified collection. If the specified collection is also a set, this operation effectively modifies this set so that its value is the asymmetric set difference of the two sets.
removeAll in interface java.util.CollectionremoveAll in interface java.util.Setcollection - Collection that defines which elements will be removed from this set.true if this set changed as a result of the call.java.lang.NullPointerException - If the specified collection is null.remove(Object)public void clear()
Removes all of the elements from this set.
clear in interface java.util.Collectionclear in interface java.util.Setpublic javax.management.NotificationFilter getNotificationFilter()
Gets a notification filter that will only enable notifications that apply to this RelationSet. It is recommended that this is used in conjunction with the NotificationListener returned by getNotificationListener().
public javax.management.NotificationListener getNotificationListener()
Gets a notification listener that will automatically process any Notifications it receives to update this RelationSet's internal state. It is recommended that this is used in conjunction with the NotificationFilter returned by getNotificationFilter().
public boolean addUpdateListener(RelationSetUpdateListener updateListener)
Adds the specified RelationSetUpdateListener to the RelationSet. Every update listener that has been registered with the RelationSet will be informed whenever the RelationSet receives a notification that an element has been added or removed.
updateListener - The update listener to add to the RelationSet.true if the specified update listener has not previously been added to the RelationSet, otherwise false.java.lang.IllegalArgumentException - If the updateListener argument is null.public boolean removeUpdateListener(RelationSetUpdateListener updateListener)
Removes the specified RelationSetUpdateListener from the RelationSet. The update listener will no longer be informed of any element added/removed changes to the RelationSet.
updateListener - The update listener to remove from the RelationSet.true if the specified update listener had been registered with the RelationSet, otherwise false.java.lang.IllegalArgumentException - If the updateListener argument is null.Please send bug reports and comments to Caplin support