/** * Constructs a parameter value from the specified descriptor and value. * * @param descriptor The abstract definition of this parameter. * @param value The parameter value. * @throws InvalidParameterValueException if the type of {@code value} is inappropriate for this * parameter, or if the value is illegal for some other reason (for example the value is * numeric and out of range). */ public Parameter(final ParameterDescriptor<T> descriptor, final T value) throws InvalidParameterValueException { super(descriptor); unit = descriptor.getUnit(); setValue(value); }
private GeneralParameterValue[] applyBandsSelectionParameter( GridCoverageReader reader, GeneralParameterValue[] readParams, RasterSymbolizer symbolizer) { int[] bandIndices = ChannelSelectionUpdateStyleVisitor.getBandIndicesFromSelectionChannels(symbolizer); Parameter<int[]> bandIndicesParam = null; bandIndicesParam = (Parameter<int[]>) AbstractGridFormat.BANDS.createValue(); bandIndicesParam.setValue(bandIndices); List<GeneralParameterValue> paramList = new ArrayList<GeneralParameterValue>(); if (readParams != null) { paramList.addAll(Arrays.asList(readParams)); } paramList.add(bandIndicesParam); return paramList.toArray(new GeneralParameterValue[paramList.size()]); }
/** * Sets the parameter value as an integer. * * @param value The parameter value. * @throws InvalidParameterValueException if the integer type is inappropriate for this * parameter, or if the value is illegal for some other reason (for example a value out of * range). * @see #intValue */ public void setValue(final int value) throws InvalidParameterValueException { @SuppressWarnings("unchecked") // Checked by constructor. final ParameterDescriptor<T> descriptor = (ParameterDescriptor) this.descriptor; final Class<T> type = descriptor.getValueClass(); if (Double.class.equals(type) || Double.TYPE.equals(type)) { setValue((double) value); return; } final Integer check = value; this.value = ensureValidValue(descriptor, check); }
/** * Returns a clone of this parameter. Actually returns a different classes, since this parameter * is not really cloneable (it would requires a clone of {@link #parameters} first). */ @Override public Parameter<T> clone() { final Parameter<T> parameter = new Parameter<T>(getDescriptor()); parameter.setValue(getValue()); return parameter; } }
readGGParam.setValue(new GridGeometry2D(gg));
op.getValidValues()); assertNull("defaultValue", op.getDefaultValue()); param.setValue(AxisDirection.DOWN); try { param.setValue(VerticalDatumType.ELLIPSOIDAL); fail("setValue(VerticalDatumType)"); } catch (InvalidParameterValueException exception) { param.setValue(dummy); fail("setValue(AxisDirection)"); } catch (InvalidParameterValueException exception) { param.setValue(dummy); // Should not fails. assertEquals("equals(clone)", param, param.clone());
assertEquals("intValue", 15, param.intValue()); assertEquals("doubleValue", 15, param.doubleValue(), 0.0); param.setValue(12); assertEquals("intValue", 12, param.intValue()); assertEquals("doubleValue", 12, param.doubleValue(), 0.0); try { param.setValue(50); fail("setValue(> max)"); } catch (InvalidParameterValueException exception) { param.setValue(-40); fail("setValue(< min)"); } catch (InvalidParameterValueException exception) { param.setValue(10.0); fail("setValue(double)"); } catch (InvalidParameterValueException exception) {
assertEquals("intValue", 15, param.intValue()); assertEquals("doubleValue", 15, param.doubleValue(), 0.0); param.setValue(12.0); assertEquals("intValue", 12, param.intValue()); assertEquals("doubleValue", 12, param.doubleValue(), 0.0); try { param.setValue(50.0); fail("setValue(> max)"); } catch (InvalidParameterValueException exception) { param.setValue(-40.0); fail("setValue(< min)"); } catch (InvalidParameterValueException exception) { param.setValue("12"); fail("setValue(String)"); } catch (InvalidParameterValueException exception) {
v1.setValue(10); v2 = new Parameter<Integer>(p2); v2.setValue(20); v3 = new Parameter<Integer>(p3); v3.setValue(30); v4 = new Parameter<Integer>(p4); v4.setValue(40); v1b = new Parameter<Integer>(p1); v1b.setValue(-10); v2b = new Parameter<Integer>(p2); v2b.setValue(-20); v3b = new Parameter<Integer>(p3); v3b.setValue(-30); v4b = new Parameter<Integer>(p4); v4b.setValue(-40);
(Parameter<GridGeometry2D>) AbstractGridFormat.READ_GRIDGEOMETRY2D.createValue(); readGG.setValue(new GridGeometry2D(new GridEnvelope2D(requestedRasterArea), envelope)); readInterpolation.setValue(interpolation); bgColorParam.setValue(bgColor); } else { bgColorParam = null; if (bandIndices != null) { bandIndicesParam = (Parameter<int[]>) AbstractGridFormat.BANDS.createValue(); bandIndicesParam.setValue(bandIndices); final String paramName = readParams[i].getDescriptor().getName().toString(); if (paramName.equalsIgnoreCase(readGGName) && readGG != null) { ((Parameter) readParams[i]).setValue(readGG); foundGG = true; } else if (paramName.equalsIgnoreCase(readInterpolationName)) { ((Parameter) readParams[i]).setValue(interpolation); foundInterpolation = true; } else if (paramName.equalsIgnoreCase(bgColorName) && bgColor != null) { ((Parameter) readParams[i]).setValue(bgColor); foundBgColor = true; } else if (paramName.equalsIgnoreCase(bandsListName) && bandIndices != null) { ((Parameter) readParams[i]).setValue(bandIndices); foundBandIndices = true;
readGGParam.setValue(readGG); readInterpolation.setValue(interpolation); readOverview.setValue(overviewPolicy); final String paramName = readParams[i].getDescriptor().getName().toString(); if (paramName.equalsIgnoreCase(readGGName)) { ((Parameter) readParams[i]).setValue(readGG); foundGG = true; } else if (paramName.equalsIgnoreCase(readInterpolationName)) { ((Parameter) readParams[i]).setValue(interpolation); foundInterpolation = true; } else if (paramName.equalsIgnoreCase(overviewPolicyName)) { ((Parameter) readParams[i]).setValue(overviewPolicy); foundOverviewPolicy = true;
bandIndicesParam.setValue(bandIndices);
bandIndicesParam.setValue(bandIndices);
bandIndicesParam.setValue(bandIndices); List<GeneralParameterValue> paramList = new ArrayList<GeneralParameterValue>(); paramList.add(bandIndicesParam);