In this commit:
OperationParameter
→ ParameterDescriptor
.
Reverting this changes causes compilation errors, which can be fixed only be re-applying the same change.ParameterRealValue
→ ParameterReal
. SIS uses different naming
convention. This class is renamed MeasurementParameter
.toString()
method implementation: this contribution has been removed from Geotk/SIS.
It is replaced by WKT 2 formatting.Command line:
svn diff --extensions "--unified --ignore-space-change --ignore-all-space --ignore-eol-style" -r7705:7857 https://svn.osgeo.org/geotools/trunk/modules/library/referencing/src/main/java/org/geotools/parameter/FloatParameter.java
Revision 7705 | Revision 7857 |
---|---|
*/ package org.geotools.parameter; // J2SE dependencies import java.net.URL; import java.util.Set; import java.util.Arrays; import java.util.Locale; import javax.units.Unit; import javax.units.SI; import javax.units.NonSI; import javax.units.Converter; // OpenGIS dependencies import org.opengis.util.CodeList; import org.opengis.parameter.OperationParameter; import org.opengis.parameter.GeneralOperationParameter; import org.opengis.parameter.InvalidParameterTypeException; import org.opengis.parameter.InvalidParameterValueException; // Geotools dependencies import org.geotools.resources.Utilities; import org.geotools.resources.cts.Resources; import org.geotools.resources.cts.ResourceKeys; /** * A parameter value as a real number. This class provides the same functionalities than * {@link ParameterValue}, except that: * <ul> * <li>Values are always floating point numbers of type <code>double</code>.</li> * <li>Units are the same than the {@linkplain OperationParameter#getUnit default units}.</li> * </ul> * When those conditions are meet, <code>ParameterRealValue</code> is slightly more efficient * than <code>ParameterValue</code> since it avoid the creation of {@link Double} objects. |
*/ package org.geotools.parameter; import org.opengis.parameter.ParameterDescriptor; // J2SE dependencies import java.lang.reflect.Array; import java.net.URL; import javax.units.Unit; import org.geotools.resources.Utilities; import org.geotools.resources.cts.ResourceKeys; import org.geotools.resources.cts.Resources; import org.opengis.parameter.InvalidParameterTypeException; import org.opengis.parameter.InvalidParameterValueException; /** * A parameter value as a real number. This class provides the same functionalities than * {@link Parameter}, except that: * <ul> * <li>Values are always floating point numbers of type <code>double</code>.</li> * <li>Units are the same than the {@linkplain ParameterDescriptor#getUnit default units}.</li> * </ul> * When those conditions are meet, <code>ParameterRealValue</code> is slightly more efficient * than <code>ParameterValue</code> since it avoid the creation of {@link Double} objects. |
* @version $Id$ * @author Martin Desruisseaux * * @see org.geotools.parameter.OperationParameter * @see org.geotools.parameter.ParameterValueGroup */ public class ParameterRealValue extends GeneralParameterValue implements org.opengis.parameter.ParameterValue { /** |
* @version $Id$ * @author Martin Desruisseaux * * @see org.geotools.parameter.ParameterDescriptor * @see org.geotools.parameter.ParameterGroup */ public class ParameterReal extends AbstractParameter implements org.opengis.parameter.ParameterValue { /** |
/** * Construct a parameter from the specified descriptor. The descriptor * {@linkplain org.geotools.parameter.OperationParameter#getValueClass() value class} * must be <code>{@linkplain Double}.class</code>. * * @param descriptor The abstract definition of this parameter. * @throws IllegalArgumentException if the value class is not <code>Double.class</code>. */ public ParameterRealValue(final OperationParameter descriptor) { super(descriptor); final Class type = descriptor.getValueClass(); final Class expected = Double.class; |
/** * Construct a parameter from the specified descriptor. The descriptor * {@linkplain org.geotools.parameter.ParameterDescriptor#getValueClass() value class} * must be <code>{@linkplain Double}.class</code>. * * @param descriptor The abstract definition of this parameter. * @throws IllegalArgumentException if the value class is not <code>Double.class</code>. */ public ParameterReal(final ParameterDescriptor descriptor) { super(descriptor); final Class type = descriptor.getValueClass(); final Class expected = Double.class; |
* @param value The parameter value.
* @throws IllegalArgumentException if the value class is not <code>Double.class</code>.
*/
public ParameterRealValue(final OperationParameter descriptor, final double value) {
this(descriptor);
setValue(value);
} |
* @param value The parameter value.
* @throws IllegalArgumentException if the value class is not <code>Double.class</code>.
*/
public ParameterReal(final ParameterDescriptor descriptor, final double value) {
this(descriptor);
setValue(value);
} |
/** * Returns the unit of measure of the {@linkplain #doubleValue() parameter value}. The default * implementation always delegates to {@link org.geotools.parameter.OperationParameter#getUnit}. * * @return The unit of measure, or <code>null</code> if none. */ public Unit getUnit() { return ((OperationParameter) descriptor).getUnit(); } /** |
/** * Returns the unit of measure of the {@linkplain #doubleValue() parameter value}. The default * implementation always delegates to {@link org.geotools.parameter.ParameterDescriptor#getUnit}. * * @return The unit of measure, or <code>null</code> if none. */ public Unit getUnit() { return ((ParameterDescriptor) descriptor).getUnit(); } /** |
final Unit thisUnit = getUnit(); if (thisUnit == null) { throw new IllegalStateException(Resources.format( ResourceKeys.ERROR_UNITLESS_PARAMETER_$1, ParameterValue.getName(descriptor))); } final int expectedID = ParameterValue.getUnitMessageID(thisUnit); if (ParameterValue.getUnitMessageID(unit) != expectedID) { throw new IllegalArgumentException(Resources.format(expectedID, unit)); } return thisUnit.getConverterTo(unit).convert(value); |
final Unit thisUnit = getUnit(); if (thisUnit == null) { throw new IllegalStateException(Resources.format( ResourceKeys.ERROR_UNITLESS_PARAMETER_$1, Parameter.getName(descriptor))); } final int expectedID = Parameter.getUnitMessageID(thisUnit); if (Parameter.getUnitMessageID(unit) != expectedID) { throw new IllegalArgumentException(Resources.format(expectedID, unit)); } return thisUnit.getConverterTo(unit).convert(value); |
*/
public URL valueFile() throws InvalidParameterTypeException {
throw new InvalidParameterTypeException(getClassTypeError(),
ParameterValue.getName(descriptor));
}
/** |
*/
public URL valueFile() throws InvalidParameterTypeException {
throw new InvalidParameterTypeException(getClassTypeError(),
Parameter.getName(descriptor));
}
/** |
*/ public void setValue(double value, final Unit unit) throws InvalidParameterValueException { ensureNonNull("unit", unit); final Unit thisUnit = ((OperationParameter) descriptor).getUnit(); if (thisUnit == null) { throw new IllegalStateException(Resources.format( ResourceKeys.ERROR_UNITLESS_PARAMETER_$1, ParameterValue.getName(descriptor))); } final int expectedID = ParameterValue.getUnitMessageID(thisUnit); if (ParameterValue.getUnitMessageID(unit) != expectedID) { throw new IllegalArgumentException(Resources.format(expectedID, unit)); } value = unit.getConverterTo(thisUnit).convert(value); ParameterValue.ensureValidValue((OperationParameter) descriptor, new Double(value)); this.value = value; } |
*/ public void setValue(double value, final Unit unit) throws InvalidParameterValueException { ensureNonNull("unit", unit); final Unit thisUnit = ((ParameterDescriptor) descriptor).getUnit(); if (thisUnit == null) { throw new IllegalStateException(Resources.format( ResourceKeys.ERROR_UNITLESS_PARAMETER_$1, Parameter.getName(descriptor))); } final int expectedID = Parameter.getUnitMessageID(thisUnit); if (Parameter.getUnitMessageID(unit) != expectedID) { throw new IllegalArgumentException(Resources.format(expectedID, unit)); } value = unit.getConverterTo(thisUnit).convert(value); Parameter.ensureValidValue((ParameterDescriptor) descriptor, new Double(value)); this.value = value; } |
* (for example a value out of range).
*/
public void setValue(final double value) throws InvalidParameterValueException {
ParameterValue.ensureValidValue((OperationParameter) descriptor, new Double(value));
this.value = value;
} |
* (for example a value out of range).
*/
public void setValue(final double value) throws InvalidParameterValueException {
Parameter.ensureValidValue((ParameterDescriptor) descriptor, new Double(value));
this.value = value;
} |
* the value is numeric and out of range).
*/
public void setValue(final Object value) throws InvalidParameterValueException {
ParameterValue.ensureValidValue((OperationParameter) descriptor, value);
this.value = ((Number) value).doubleValue();
} |
* the value is numeric and out of range).
*/
public void setValue(final Object value) throws InvalidParameterValueException {
Parameter.ensureValidValue((ParameterDescriptor) descriptor, value);
this.value = ((Number) value).doubleValue();
} |
*/
public void setValue(double[] values, final Unit unit) throws InvalidParameterValueException {
throw new InvalidParameterTypeException(getClassTypeError(),
ParameterValue.getName(descriptor));
}
/** |
*/
public void setValue(double[] values, final Unit unit) throws InvalidParameterValueException {
throw new InvalidParameterTypeException(getClassTypeError(),
Parameter.getName(descriptor));
}
/** |
*/
public boolean equals(final Object object) {
if (super.equals(object)) {
final ParameterRealValue that = (ParameterRealValue) object;
return Double.doubleToLongBits(this.value) ==
Double.doubleToLongBits(that.value);
} |
*/
public boolean equals(final Object object) {
if (super.equals(object)) {
final ParameterReal that = (ParameterReal) object;
return Double.doubleToLongBits(this.value) ==
Double.doubleToLongBits(that.value);
} |
final long code = Double.doubleToLongBits(value); return (int)code ^ (int)(code >>> 32) + super.hashCode()*37; } } |
final long code = Double.doubleToLongBits(value); return (int)code ^ (int)(code >>> 32) + super.hashCode()*37; } public String toString() { String name = descriptor.getName().toString( null ); Object value = getValue(); StringBuffer buf = new StringBuffer(); buf.append( "[<" ); buf.append( descriptor.getName().toString( null ) ); buf.append( "> " ); if( value == null ){ buf.append( "null" ); } else { buf.append( value ); } buf.append("]"); return buf.toString(); } } |