/** * Converts numeric values from this unit to another unit. * * @param amounts * The numeric values. * @param outputUnit * The unit to which to convert the numeric values. * @return The numeric values in the output unit in allocated space. * @throws ConversionException * The units aren't convertible. */ public float[] convertTo(final float[] amounts, final Unit outputUnit) throws ConversionException { return convertTo(amounts, outputUnit, new float[amounts.length]); }
/** * Divides this unit by another. * * @param that * The other unit. * @return The quotient of this unit divided by the other unit. * @throws OperationException * Can't divide these units. */ public final Unit divideBy(final Unit that) throws OperationException { return myDivideBy(that); }
/** * Returns the string representation of this unit. * * @return The string representation of this unit. */ @Override public String toString() { final String string = super.toString(); // get symbol or name return string != null ? string : getCanonicalString(); }
/** * Converts a numeric value from this unit to another unit. * * @param amount * The numeric value. * @param outputUnit * The unit to which to convert the numeric value. * @return The numeric value in the output unit. * @throws ConversionException * The units aren't convertible. */ public double convertTo(final double amount, final Unit outputUnit) throws ConversionException { return getConverterTo(outputUnit).convert(amount); }
/** * Divides this unit into another. * * @param that * The other unit. * @return The quotient of this unit divided into the other unit. * @throws OperationException * Can't divide these units. */ public final Unit divideInto(final Unit that) throws OperationException { return myDivideInto(that); }
/** * Multiplies this unit by another. * * @param that * The other unit. * @return The product of this unit multiplied by the other unit. * @throws MultiplyException * Can't multiply these units. */ public final Unit multiplyBy(final Unit that) throws MultiplyException { return myMultiplyBy(that); }
/** * Raises this unit to a power. * * @param power * The power. * @return The result of raising this unit to the power. * @throws RaiseException * Can't raise this unit to a power. */ public final Unit raiseTo(final int power) throws RaiseException { return myRaiseTo(power); }
/** * Indicates if numeric values in this unit are convertible with another * unit. * * @param that * The other unit. * @return <code>true</code> if and only if numeric values in this unit are * convertible the other unit. */ public boolean isCompatible(final Unit that) { // jeffm: for some reason just calling getDerivedUnit().equals(...) // with jikes 1.1.7 as the compiler causes the jvm to crash. // The Unit u1=... does not crash. final Unit u1 = getDerivedUnit(); return u1.equals(that.getDerivedUnit()); // return getDerivedUnit().equals(that.getDerivedUnit()); }
/** * Returns the string representation of this unit. * * @return The string representation of this unit. */ @Override public String toString() { final String string = super.toString(); // get symbol or name return string != null ? string : getCanonicalString(); }
/** * Converts a numeric value from this unit to another unit. * * @param amount * The numeric value. * @param outputUnit * The unit to which to convert the numeric value. * @return The numeric value in the output unit. * @throws ConversionException * The units aren't convertible. */ public double convertTo(final double amount, final Unit outputUnit) throws ConversionException { return getConverterTo(outputUnit).convert(amount); }
/** * Divides this unit into another. * * @param that * The other unit. * @return The quotient of this unit divided into the other unit. * @throws OperationException * Can't divide these units. */ public final Unit divideInto(final Unit that) throws OperationException { return myDivideInto(that); }
/** * Multiplies this unit by another. * * @param that * The other unit. * @return The product of this unit multiplied by the other unit. * @throws MultiplyException * Can't multiply these units. */ public final Unit multiplyBy(final Unit that) throws MultiplyException { return myMultiplyBy(that); }
/** * Raises this unit to a power. * * @param power * The power. * @return The result of raising this unit to the power. * @throws RaiseException * Can't raise this unit to a power. */ public final Unit raiseTo(final int power) throws RaiseException { return myRaiseTo(power); }
/** * Indicates if numeric values in this unit are convertible with another * unit. * * @param that * The other unit. * @return <code>true</code> if and only if numeric values in this unit are * convertible the other unit. */ public boolean isCompatible(final Unit that) { // jeffm: for some reason just calling getDerivedUnit().equals(...) // with jikes 1.1.7 as the compiler causes the jvm to crash. // The Unit u1=... does not crash. final Unit u1 = getDerivedUnit(); return u1.equals(that.getDerivedUnit()); // return getDerivedUnit().equals(that.getDerivedUnit()); }
/** * Returns the string representation of this unit. * * @return The string representation of this unit. */ @Override public String toString() { final String string = super.toString(); // get symbol or name return string != null ? string : getCanonicalString(); }
/** * Converts numeric values from this unit to another unit. * * @param amounts * The numeric values. * @param outputUnit * The unit to which to convert the numeric values. * @return The numeric values in the output unit in allocated space. * @throws ConversionException * The units aren't convertible. */ public double[] convertTo(final double[] amounts, final Unit outputUnit) throws ConversionException { return convertTo(amounts, outputUnit, new double[amounts.length]); }
/** * Converts numeric values from this unit to another unit. * * @param input * The input numeric values. * @param outputUnit * The unit to which to convert the numeric values. * @param output * The output numeric values. May be the same array as the input * values. * @return The numeric values in the output unit. * @throws ConversionException * The units aren't convertible. */ public float[] convertTo(final float[] input, final Unit outputUnit, final float[] output) throws ConversionException { return getConverterTo(outputUnit).convert(input, output); }
/** * Divides this unit by another. * * @param that * The other unit. * @return The quotient of this unit divided by the other unit. * @throws OperationException * Can't divide these units. */ public final Unit divideBy(final Unit that) throws OperationException { return myDivideBy(that); }