Package javax.measure.converter

Examples of javax.measure.converter.ConversionException


                    // between source[i] and target[j].
                    continue;
                }
                final UnitConverter converter = sourceUnit.getConverterToAny(targetUnit);
                if (!(converter instanceof LinearConverter)) {
                    throw new ConversionException(Errors.format(
                              Errors.Keys.NonLinearUnitConversion_2, sourceUnit, targetUnit));
                }
                final double offset = converter.convert(0);
                final double scale  = Units.derivative(converter, 0);
                matrix.setElement(j, i, element*scale);
 
View Full Code Here


          this.bandMnemonic);
    final StringBuilder buffer = new StringBuilder();
    buffer.append("Unable to perform requested conversion");
    buffer.append("\nsource UoM:").append("  ").append(Unit.ONE.toString());
    buffer.append("\ntarget UoM:").append("  ").append(target.toString());
    throw new ConversionException(buffer.toString());

  }
View Full Code Here

     * Workaround for RFE #4093999 ("Relax constraint on placement of this()/super()
     * call in constructors").
     */
    private static UnitConverter getConverter(final Unit<?> source) throws ConversionException {
        if (source == null) {
            throw new ConversionException(Errors.format(ErrorKeys.NO_UNIT));
        }
        return source.getConverterTo(MILLISECOND);
    }
View Full Code Here

                    // between source[i] and target[j].
                    continue;
                }
                final UnitConverter converter = sourceUnit.getConverterTo(targetUnit);
                if (!converter.isLinear()) {
                    throw new ConversionException(Errors.format(
                              ErrorKeys.NON_LINEAR_UNIT_CONVERSION_$2, sourceUnit, targetUnit));
                }
                final double offset = converter.convert(0);
// JSR-275      final double scale  = converter.derivative(0);
                final double scale  = converter.convert(1) - offset;
View Full Code Here

                    if (unit != null) {
                        final UnitConverter converter = candidate.getConverterTo(unit);
                        if (!converter.isLinear()) {
                            // TODO: use the localization provided in 'swapAxis'. We could also
                            //       do a more intelligent work by checking the unit scale type.
                            throw new ConversionException("Unit conversion is non-linear");
                        }
// JSR-275              final double scale = converter.derivative(0);
                        final double scale = converter.convert(1) - converter.convert(0);
                        if (Math.abs(scale) <= 1) {
                            // The candidate is a "smaller" unit than the current one
View Full Code Here

TOP

Related Classes of javax.measure.converter.ConversionException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.