/** * Factory method for constructing a derived unit. * * @param name The name of the unit. * @param symbol The symbol for the unit. * @param definition The definition of the unit. * @return The derived unit corresponding to the arguments. */ private static Unit du(final String name, final String symbol, final Unit definition) throws NameException { return definition.clone(UnitName.newUnitName(name, null, symbol)); }
/** * Factory method for constructing a derived unit. * * @param name * The name of the unit. * @param symbol * The symbol for the unit. * @param quantity * The definition of the unit. * @return The derived unit corresponding to the arguments. */ private static Unit du(final String name, final String symbol, final Unit definition) throws NameException { return definition.clone(UnitName.newUnitName(name, null, symbol)); }
/** * Adds a derived unit to the database. * * @param name The name of the unit. * @param definition The definition for the unit. * @param symbol The symbol for the unit. * @param plural The plural form of the name of the unit. * @throws UnitExistsException Attempt to redefine an existing unit. * @throws NameException Bad unit name. * @throws UnitParseException A string specification couldn't be parsed. * @throws SpecificationException Bad string specification. * @throws UnitDBException Problem with the unit database. * @throws PrefixDBException Problem with the prefix database. * @throws NameException Bad unit name. * @throws OperationException Improper unit operation. * @throws UnitSystemException Problem with UnitSystem. */ private void au(final String name, final String definition, final String symbol, final String plural) throws UnitExistsException, NoSuchUnitException, UnitParseException, SpecificationException, UnitDBException, PrefixDBException, OperationException, NameException, UnitSystemException { final Unit unit = format.parse(definition, this); if (unit == null) { throw new NoSuchUnitException(definition); } addUnit(unit.clone(UnitName.newUnitName(name, plural, symbol))); }
throw new NoSuchUnitException(definition); addUnit(unit.clone(UnitName.newUnitName(name, plural, symbol)));
myAssert(kelvin.hashCode() != celsius.hashCode()); Unit fahrenheit = format.parse("fahrenheit"); fahrenheit = fahrenheit.clone(UnitName.newUnitName("fahrenheit")); kelvin = kelvin.clone(UnitName.newUnitName("kelvin")); myAssert(kelvin.isCompatible(fahrenheit)); myAssert(fahrenheit.isCompatible(kelvin)); final Unit kelvinUnit = format.parse("kelvin").clone( UnitName.newUnitName("kelvin")); final Unit fahrenUnit = format.parse("fahrenheit").clone( UnitName.newUnitName("fahrenheit")); myAssert(kelvinUnit.isCompatible(fahrenUnit)); System.out.println("minute.getConverterTo(second).convert(1) = \"" + minute.getConverterTo(second).convert(1) + '"'); final Unit mixingRatio = format.parse("g/kg").clone( UnitName.newUnitName("mixing ratio")); System.out.println("mixingRatio.toString() = \""
myAssert(kelvin.hashCode() != celsius.hashCode()); Unit fahrenheit = format.parse("fahrenheit"); fahrenheit = fahrenheit.clone(UnitName.newUnitName("fahrenheit")); kelvin = kelvin.clone(UnitName.newUnitName("kelvin")); myAssert(kelvin.isCompatible(fahrenheit)); myAssert(fahrenheit.isCompatible(kelvin)); final Unit kelvinUnit = format.parse("kelvin").clone( UnitName.newUnitName("kelvin")); final Unit fahrenUnit = format.parse("fahrenheit").clone( UnitName.newUnitName("fahrenheit")); myAssert(kelvinUnit.isCompatible(fahrenUnit)); System.out.println("minute.getConverterTo(second).convert(1) = \"" + minute.getConverterTo(second).convert(1) + '"'); final Unit mixingRatio = format.parse("g/kg").clone( UnitName.newUnitName("mixing ratio")); System.out.println("mixingRatio.toString() = \""