this.numParams = 0;
this.paramNames = null;
this.paramClasses = null;
this.paramDefaults = null;
this.paramIndices = new CaselessStringArrayTable();
this.validParamValues = null;
} else {
if ((paramClasses == null) || (paramClasses.length != numParams))
throw new IllegalArgumentException("paramClasses" +
JaiI18N.getString("ParameterListDescriptorImpl3"));
this.numParams = numParams;
this.paramNames = paramNames;
this.paramClasses = paramClasses;
this.validParamValues = validParamValues;
//
// If the defaults are null, fill in NO_PARAMETER_DEFAULT
// Else, make sure they belong to the right class.
//
if (paramDefaults == null) {
this.paramDefaults = new Object[numParams];
for (int i = 0; i < numParams; i++)
this.paramDefaults[i] =
ParameterListDescriptor.NO_PARAMETER_DEFAULT;
} else {
this.paramDefaults = paramDefaults;
for (int i = 0; i < numParams; i++) {
if ((paramDefaults[i] == null) ||
(paramDefaults[i] ==
ParameterListDescriptor.NO_PARAMETER_DEFAULT))
continue;
if (!paramClasses[i].isInstance(paramDefaults[i])) {
throw new IllegalArgumentException(
JaiI18N.formatMsg("ParameterListDescriptorImpl4",
new Object[]
{ paramDefaults[i].getClass().getName(),
paramClasses [i].getName(),
paramNames[i] }));
}
}
}
//
// Make sure that validParamValues belongs to the right class.
//
if (validParamValues != null) {
Class enumeratedClass = EnumeratedParameter.class;
for (int i = 0; i < numParams; i++) {
if (validParamValues[i] == null)
continue;
if (enumeratedClass.isAssignableFrom(paramClasses[i])) {
// If paramClass[i] is an enumerated parameter, then
// the validParamValues[i] has to be a Set
if (!(validParamValues[i] instanceof Set))
throw new IllegalArgumentException(
JaiI18N.formatMsg("ParameterListDescriptorImpl5",
new Object[] { paramNames[i] }));
} else if (validParamValues[i] instanceof Range) {
Range range = (Range)validParamValues[i];
// If the validParamValues[i] is a Range, then
// the Range's class must match with paramClass[i]
if (!paramClasses[i].isAssignableFrom(
range.getElementClass()))
throw new IllegalArgumentException(
JaiI18N.formatMsg("ParameterListDescriptorImpl6",
new Object[]
{ range.getElementClass().getName(),
paramClasses[i].getName(),
paramNames[i] }));
} else {
// Otherwise, the validParamValues[i] has to be
// an instance of the paramClasses[i]
if (!paramClasses[i].isInstance(validParamValues[i]))
throw new IllegalArgumentException(
JaiI18N.formatMsg("ParameterListDescriptorImpl7",
new Object[]
{ validParamValues[i].getClass().getName(),
paramClasses[i].getName(),
paramNames[i] }));
}
}
}
paramIndices = new CaselessStringArrayTable(paramNames);
}
}