/** Replace or add the provided parameter in the read parameters */ public static <T> GeneralParameterValue[] replaceParameter( GeneralParameterValue[] readParameters, Object value, ParameterDescriptor<T> pd) { // scan all the params looking for the one we want to add for (GeneralParameterValue gpv : readParameters) { // in case of match of any alias add a param value to the lot if (gpv.getDescriptor().getName().equals(pd.getName())) { ((ParameterValue) gpv).setValue(value); // leave return readParameters; } } // add it to the array // add to the list GeneralParameterValue[] readParametersClone = new GeneralParameterValue[readParameters.length + 1]; System.arraycopy(readParameters, 0, readParametersClone, 0, readParameters.length); final ParameterValue<T> pv = pd.createValue(); pv.setValue(value); readParametersClone[readParameters.length] = pv; return readParametersClone; } }
if (param.getDescriptor().equals(lparam.getDescriptor())) { it.remove(); break; String pdCode = pv.getDescriptor().getName().getCode(); if ("FILTER".equals(pdCode) || "Filter".equals(pdCode)) { replacedOriginalFilter = true;
parameter -> parameter .getDescriptor() .getName() .equals( parameter -> !parameter .getDescriptor() .getName() .equals(
final List<GridCoverage2D> returnValues = new ArrayList<GridCoverage2D>(); for (GeneralParameterValue p : params) { if (p.getDescriptor() .getName() .toString()
/** * Remove the value at the specified index. * * @param index The index of the value to remove. */ @Override public GeneralParameterValue remove(final int index) { return remove(values.get(index).getDescriptor(), index); }
private GeneralParameterValue[] mergeBandParam(GeneralParameterValue[] params, int[] bands) { // is it already there for some reason? if (params != null) { for (GeneralParameterValue param : params) { if (param.getDescriptor().getName().equals(AbstractGridFormat.BANDS.getName())) { ((ParameterValue) param).setValue(bands); return params; } } } // not found, need to add List<GeneralParameterValue> list = new ArrayList<>(params == null ? Collections.emptyList() : Arrays.asList(params)); ParameterValue<int[]> value = AbstractGridFormat.BANDS.createValue(); value.setValue(bands); list.add(value); return list.toArray(new GeneralParameterValue[list.size()]); }
/** * Work around for RFE #4093999 in Sun's bug database ("Relax constraint on placement of * this()/super() call in constructors"). * * @throws IllegalStateException if the number of {@linkplain ParameterValue parameter} * occurences doesn't matches the number declared in the {@linkplain * ParameterDescriptorGroup descriptor}. */ private static ParameterDescriptorGroup createDescriptor( final Map<String, ?> properties, final GeneralParameterValue[] values) { ensureNonNull("values", values); final Map<GeneralParameterDescriptor, int[]> occurences = new LinkedHashMap<GeneralParameterDescriptor, int[]>( Math.round(values.length / 0.75f) + 1, 0.75f); for (int i = 0; i < values.length; i++) { ensureNonNull("values", values, i); occurences.put(values[i].getDescriptor(), new int[1]); // The value 'int[1]' will be used by 'ensureValidOccurs' } ensureValidOccurs(values, occurences); final Set<GeneralParameterDescriptor> descriptors = occurences.keySet(); return new DefaultParameterDescriptorGroup( properties, descriptors.toArray(new GeneralParameterDescriptor[descriptors.size()])); }
/** Implementation of the search algorithm. The result is stored in the supplied set. */ private static void search( final GeneralParameterValue param, final String name, final int maxDepth, final Collection<Object> list) { if (maxDepth >= 0) { if (AbstractIdentifiedObject.nameMatches(param.getDescriptor(), name)) { list.add(param); } if ((maxDepth != 0) && (param instanceof ParameterValueGroup)) { for (final GeneralParameterValue value : ((ParameterValueGroup) param).values()) { search(value, name, maxDepth - 1, list); } } } }
for (final GeneralParameterValue value : values) { if (value instanceof ParameterValueGroup) { if (AbstractIdentifiedObject.nameMatches(value.getDescriptor(), name)) { groups.add((ParameterValueGroup) value);
/** * Remove the value at the specified index. * * @param type The descriptor of the value to remove. * @param index The index of the value to remove. */ private GeneralParameterValue remove(final GeneralParameterDescriptor type, final int index) { modCount++; int count = 0; final String name = type.getName().getCode(); for (final GeneralParameterValue value : values) { if (AbstractIdentifiedObject.nameMatches(value.getDescriptor(), name)) { count++; } } final int min = type.getMinimumOccurs(); if (count <= min) { final int max = type.getMaximumOccurs(); throw new InvalidParameterCardinalityException( Errors.format( ErrorKeys.ILLEGAL_OCCURS_FOR_PARAMETER_$4, name, count - 1, min, max), name); } final GeneralParameterValue value = values.remove(index); assert value != null && type.equals(value.getDescriptor()) : value; return value; } }
for (final Iterator it = values.iterator(); it.hasNext(); ) { final GeneralParameterValue value = (GeneralParameterValue) it.next(); if (AbstractIdentifiedObject.nameMatches(value.getDescriptor(), name)) { count++;
final String name = param.getDescriptor().getName().toString(); if (name.regionMatches(true, 0, prefix, 0, prefix.length())) { final int split = name.indexOf(separator, prefix.length());
@Override public GridCoverage2D read(GeneralParameterValue[] parameters) throws IllegalArgumentException, IOException { assertTrue( Arrays.stream(parameters) .anyMatch( p -> "Bands".equals(p.getDescriptor().getName().toString()) && Arrays.equals( expectedBands, (int[]) ((ParameterValue) p) .getValue()))); // Create a solid color single band coverage BufferedImage bi = new BufferedImage(100, 100, BufferedImage.TYPE_BYTE_GRAY); Graphics2D graphics = bi.createGraphics(); graphics.setColor(Color.WHITE); graphics.fillRect(0, 0, bi.getWidth(), bi.getHeight()); graphics.dispose(); GridCoverage2D coverage = CoverageFactoryFinder.getGridCoverageFactory(null) .create("test", bi, getOriginalEnvelope()); return coverage; } }
final GeneralParameterDescriptor descriptor = values[i].getDescriptor(); final int[] count = occurences.get(descriptor); if (count == null) {
@Override public GridCoverage2D read(GeneralParameterValue[] parameters) throws IllegalArgumentException, IOException { for (GeneralParameterValue parameter : parameters) { if ("Bands".equals(parameter.getDescriptor().getName().toString())) { assertTrue( Arrays.equals( expectedBands, (int[]) ((ParameterValue) parameter).getValue())); } } BufferedImage bi = image; GridCoverage2D coverage = CoverageFactoryFinder.getGridCoverageFactory(null) .create("test", bi, getOriginalEnvelope()); return coverage; } }
final ReferenceIdentifier name = param.getDescriptor().getName(); if (name.equals(AbstractGridFormat.READ_GRIDGEOMETRY2D.getName())) { final GridGeometry2D gg = (GridGeometry2D) ((ParameterValue) param).getValue();
/** * Copies all parameter values from {@code source} to {@code target}. A typical usage of this * method is for transfering values from an arbitrary implementation to some specific * implementation (e.g. a parameter group implementation backed by a {@link * java.awt.image.renderable.ParameterBlock} for image processing operations). * * @param source The parameters to copy. * @param target Where to copy the source parameters. * @since 2.2 */ public static void copy(final ParameterValueGroup source, final ParameterValueGroup target) { for (final GeneralParameterValue param : source.values()) { final String name = param.getDescriptor().getName().getCode(); if (param instanceof ParameterValueGroup) { copy((ParameterValueGroup) param, target.addGroup(name)); } else { target.parameter(name).setValue(((ParameterValue) param).getValue()); } } }
if (parameters != null) { for (GeneralParameterValue param : parameters) { final ReferenceIdentifier name = param.getDescriptor().getName(); if (name.equals(AbstractGridFormat.READ_GRIDGEOMETRY2D.getName())) { final GridGeometry2D gg = (GridGeometry2D) ((ParameterValue) param).getValue();
if (search instanceof ParameterDescriptor) { for (final GeneralParameterValue candidate : group.values()) { if (search.equals(candidate.getDescriptor())) { return Parameters.cast((ParameterValue) candidate, param.getValueClass());
formatter.append(conversionFromBase.getMethod()); for (final GeneralParameterValue param : conversionFromBase.getParameterValues().values()) { final GeneralParameterDescriptor desc = param.getDescriptor(); String name; if (nameMatches(desc, name = SEMI_MAJOR) || nameMatches(desc, name = SEMI_MINOR)) {