javax.media.jai.remote
Class NegotiableCollection

java.lang.Object
  extended byjavax.media.jai.remote.NegotiableCollection
All Implemented Interfaces:
Negotiable, Serializable

public class NegotiableCollection
extends Object
implements Negotiable

A class that wraps an Collection to implement the Negotiable interface. NegotiableCollection is a convenience class to specify a Negotiable value for a parameter whose valid values are contained in an Collection.

Since:
JAI 1.1
See Also:
Serialized Form

Constructor Summary
NegotiableCollection(Collection collection)
          Creates a NegotiableCollection given an Collection.
NegotiableCollection(Object[] objects)
          Creates a NegotiableCollection given an array of Objects.
 
Method Summary
 Collection getCollection()
          Returns the Collection of values which are currently valid for this class, null if there are no valid values.
 Object getNegotiatedValue()
          Returns a single value that is valid for this NegotiableCollection.
 Class getNegotiatedValueClass()
          Returns the Class of the Object returned as the result of the negotiation.
 Negotiable negotiate(Negotiable other)
          Returns a NegotiableCollection that contains those elements that are common to this NegotiableCollection and the one supplied.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NegotiableCollection

public NegotiableCollection(Collection collection)
Creates a NegotiableCollection given an Collection.

Throws:
IllegalArgumentException - if collection is null.
IllegalArgumentException - if all the elements of collection are not of the same Class type.

NegotiableCollection

public NegotiableCollection(Object[] objects)
Creates a NegotiableCollection given an array of Objects. The elements of the Object array are treated as being the elements of an Collection.

Throws:
IllegalArgumentException - if objects is null.
IllegalArgumentException - if all the elements of objects are not of the same Class type.
Method Detail

getCollection

public Collection getCollection()
Returns the Collection of values which are currently valid for this class, null if there are no valid values.


negotiate

public Negotiable negotiate(Negotiable other)
Returns a NegotiableCollection that contains those elements that are common to this NegotiableCollection and the one supplied. If the supplied Negotiable is not a NegotiableCollection with its elements being of the same Class as this class', or if there are no common elements, the negotiation will fail and null (signifying the failure of the negotiation) will be returned.

Specified by:
negotiate in interface Negotiable
Parameters:
other - The Negotiable to negotiate with.

getNegotiatedValue

public Object getNegotiatedValue()
Returns a single value that is valid for this NegotiableCollection. The returned value is the first element contained in this NegotiableCollection. Returns null if there are no valid elements in this NegotiableCollection.

Specified by:
getNegotiatedValue in interface Negotiable

getNegotiatedValueClass

public Class getNegotiatedValueClass()
Returns the Class of the Object returned as the result of the negotiation. If the Collection used to construct this NegotiableCollection was empty, i.e. had no elements, the Class of the elements is indeterminate, therefore null will be returned from this method in such a case.

Specified by:
getNegotiatedValueClass in interface Negotiable