javax.media.jai.remote
Class NegotiableNumericRange

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

public class NegotiableNumericRange
extends Object
implements Negotiable

A class that wraps a Range which contains numeric elements, to implement the Negotiable interface. NegotiableNumericRange is a convenience class to specify a Negotiable parameter whose valid numeric values are specified by a Range.

Since:
JAI 1.1
See Also:
Serialized Form

Constructor Summary
NegotiableNumericRange(Range range)
          Creates a NegotiableNumericRange given an Range containing elements of a subclass of Number.
 
Method Summary
 Object getNegotiatedValue()
          Returns a single value that is valid for this NegotiableNumericRange.
 Class getNegotiatedValueClass()
          Returns the Class of the Object returned as the result of the negotiation.
 Range getRange()
          Returns the Range of values which are currently valid for this class, null if there are no valid values.
 Negotiable negotiate(Negotiable other)
          Returns a NegotiableNumericRange that contains the range of values that are common to this NegotiableNumericRange and the one supplied.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NegotiableNumericRange

public NegotiableNumericRange(Range range)
Creates a NegotiableNumericRange given an Range containing elements of a subclass of Number.

Throws:
IllegalArgumentException - if range is null.
IllegalArgumentException - if the elements of the supplied range are not a Number subclass.
Method Detail

getRange

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


negotiate

public Negotiable negotiate(Negotiable other)
Returns a NegotiableNumericRange that contains the range of values that are common to this NegotiableNumericRange and the one supplied. If the supplied Negotiable is not a NegotiableNumericRange with its elements being of the same Class as this class', or if there is no common range of values, the negotiation will fail and null 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 NegotiableNumericRange. The returned value is the lowest value contained in this NegotiableNumericRange if the range is not unbounded on the minimum end, or the highest value in the range, if the range is unbounded on the minimum end. If both ends are unbounded, 0 will be returned wrapped in the appropriate Number wrapper. Returns null if there are no valid elements in this NegotiableNumericRange.

Specified by:
getNegotiatedValue in interface Negotiable

getNegotiatedValueClass

public Class getNegotiatedValueClass()
Returns the Class of the Object returned as the result of the negotiation. This will be a subclass of Number.

Specified by:
getNegotiatedValueClass in interface Negotiable