javax.media.jai
Class ParameterListDescriptorImpl

java.lang.Object
  |
  +--javax.media.jai.ParameterListDescriptorImpl
All Implemented Interfaces:
ParameterListDescriptor, Serializable

public class ParameterListDescriptorImpl
extends Object
implements ParameterListDescriptor, Serializable

A concrete implementation of the ParameterListDescriptor interface.

Since:
JAI 1.1
See Also:
ParameterListDescriptor, Serialized Form

Fields inherited from interface javax.media.jai.ParameterListDescriptor
NO_PARAMETER_DEFAULT
 
Constructor Summary
ParameterListDescriptorImpl()
          Constructor for descriptors that dont have any parameters.
ParameterListDescriptorImpl(Object descriptor, String[] paramNames, Class[] paramClasses, Object[] paramDefaults, Object[] validParamValues)
          Constructor.
 
Method Summary
 String[] getEnumeratedParameterNames()
          Return an array of the names of all parameters the type of which is EnumeratedParameter.
 EnumeratedParameter[] getEnumeratedParameterValues(String parameterName)
          Return an array of EnumeratedParameter objects corresponding to the parameter with the specified name.
static Set getEnumeratedValues(Object descriptor, Class paramClass)
          Uses reflection to examine "descriptor" for public, static final Fields that are instances of "paramClass".
 int getNumParameters()
          Returns the total number of parameters.
 Class[] getParamClasses()
          Returns an array of Classes that describe the types of parameters.
 Object[] getParamDefaults()
          Returns an array of Objects that define the default values of the parameters.
 Object getParamDefaultValue(String parameterName)
          Returns the default value of a specified parameter.
 String[] getParamNames()
          Returns an array of Strings that are the names of the parameters associated with this descriptor.
 Range getParamValueRange(String parameterName)
          Returns the Range that represents the range of valid values for the specified parameter.
 boolean isParameterValueValid(String parameterName, Object value)
          Checks to see if the specified parameter can take on the specified value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParameterListDescriptorImpl

public ParameterListDescriptorImpl()
Constructor for descriptors that dont have any parameters.

ParameterListDescriptorImpl

public ParameterListDescriptorImpl(Object descriptor,
                                   String[] paramNames,
                                   Class[] paramClasses,
                                   Object[] paramDefaults,
                                   Object[] validParamValues)
Constructor.
Parameters:
descriptor - the object to be reflected upon for enumerated values
paramNames - the names of each parameter. can be null if there are no parameters.
paramClasses - the Class type of each parameter. can be null if there are no parameters.
paramDefaults - the default values for each parameter. can be null if there are no parameters or if there are no default values, in which case the parameter defaults are assumed to be ParameterListDescriptor.NO_PARAMETER_DEFAULT
validParamValues - defines the valid values for each parameter.

Each element of this array can be null (if the parameter can take on any value of its class or if it is an enumerated parameter whose values are to be auto-detected - see getEnumeratedValues ), or a Set (for user specified enumerated values) or a Range (for parameters that are Comparable.)

The valid set of values for an object which is neither an EnumeratedParameter nor Comparable should just be the set of all possible instances of the associated class, i.e., the parameter has to be an instance of the specified class.

If this array itself is null then it is treated as an array full of nulls as described above.

Throws:
IllegalArgumentException - if paramNames is non-null and the number of paramClasses or a non-null paramDefaults does not match the length of paramNames
IllegalArgumentException - if null is passed in for validParamValues for a parameter whose class is of EnumeratedParameter type.
Method Detail

getEnumeratedValues

public static Set getEnumeratedValues(Object descriptor,
                                      Class paramClass)
Uses reflection to examine "descriptor" for public, static final Fields that are instances of "paramClass".
Parameters:
descriptor - the object to be reflected upon.
paramClass - the parameter class
Returns:
a Set of enumerated values.
Throws:
IllegalArgumentException - if descriptor is null or paramClass is null
IllegalArgumentException - if "paramClass" is not an instance of EnumeratedParameter

getNumParameters

public int getNumParameters()
Returns the total number of parameters.
Specified by:
getNumParameters in interface ParameterListDescriptor

getParamClasses

public Class[] getParamClasses()
Returns an array of Classes that describe the types of parameters. If there are no parameters, this method returns null.
Specified by:
getParamClasses in interface ParameterListDescriptor

getParamNames

public String[] getParamNames()
Returns an array of Strings that are the names of the parameters associated with this descriptor. If there are no parameters, this method returns null.
Specified by:
getParamNames in interface ParameterListDescriptor

getParamDefaults

public Object[] getParamDefaults()
Returns an array of Objects that define the default values of the parameters. Default values may be null. The NO_PARAMETER_DEFAULT static Object indicates that a parameter has no default value. If there are no parameters, this method returns null.
Specified by:
getParamDefaults in interface ParameterListDescriptor

getParamDefaultValue

public Object getParamDefaultValue(String parameterName)
Returns the default value of a specified parameter. The default value may be null. If a parameter has no default value, this method returns NO_PARAMETER_DEFAULT.
Specified by:
getParamDefaultValue in interface ParameterListDescriptor
Parameters:
parameterName - The name of the parameter whose default value is queried.
Throws:
IllegalArgumentException - if parameterName is null or if the parameter does not exist.

getParamValueRange

public Range getParamValueRange(String parameterName)
Returns the Range that represents the range of valid values for the specified parameter. Returns null if the parameter can take on any value or if the valid values are not representable as a Range.
Specified by:
getParamValueRange in interface ParameterListDescriptor
Parameters:
parameterName - The name of the parameter whose valid range of values is to be determined.
Throws:
IllegalArgumentException - if parameterName is null or if the parameter does not exist.

getEnumeratedParameterNames

public String[] getEnumeratedParameterNames()
Return an array of the names of all parameters the type of which is EnumeratedParameter.
Specified by:
getEnumeratedParameterNames in interface ParameterListDescriptor
Returns:
The requested array of names or null if there are no parameters with EnumeratedParameter type.

getEnumeratedParameterValues

public EnumeratedParameter[] getEnumeratedParameterValues(String parameterName)
Return an array of EnumeratedParameter objects corresponding to the parameter with the specified name.
Specified by:
getEnumeratedParameterValues in interface ParameterListDescriptor
Parameters:
parameterName - The name of the parameter for which the EnumeratedParameter array is to be returned.
Returns:
An array of EnumeratedParameter objects representing the range of values for the named parameter.
Throws:
IllegalArgumentException - if parameterName is null or if the parameter does not exist.
UnsupportedOperationException - if there are no enumerated parameters associated with the descriptor.
IllegalArgumentException - if parameterName is a parameter the class of which is not a subclass of EnumeratedParameter.

isParameterValueValid

public boolean isParameterValueValid(String parameterName,
                                     Object value)
Checks to see if the specified parameter can take on the specified value.
Specified by:
isParameterValueValid in interface ParameterListDescriptor
Parameters:
parameterName - The name of the parameter for which the validity check is to be performed.
Returns:
true, if it is valid to pass this value in for this parameter, false otherwise.
Throws:
IllegalArgumentException - if parameterName is null or if the parameter does not exist.
IllegalArgumentException - if the class of the object "value" is not an instance of the class type of parameter pointed to by the parameterName