/** * 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))); }
LOGGER.fine(e1.getLocalizedMessage());
final Unit unit = format.parse(definition, this); if (unit == null) { throw new NoSuchUnitException(definition);
/** * Adds an alias for a unit already in the database. * * @param alias * The alias to be added to the database. * @param name * The name of the unit to have an alias added to the database. * @throws NoSuchUnitException * The unit is not in the database. * @throws UnitExistsException * Another unit with the same alias is already in the database. */ public final void addAlias(final UnitID alias, final String name) throws NoSuchUnitException, UnitExistsException { final Unit unit = getByName(name); if (unit == null) { throw new NoSuchUnitException(name); } addByName(alias.getName(), unit); addByName(alias.getPlural(), unit); addBySymbol(alias.getSymbol(), unit); }
/** * Adds an alias for a unit already in the database. * * @param alias * The alias to be added to the database. * @param name * The name of the unit to have an alias added to the database. * @throws NoSuchUnitException * The unit is not in the database. * @throws UnitExistsException * Another unit with the same alias is already in the database. */ public final void addAlias(final UnitID alias, final String name) throws NoSuchUnitException, UnitExistsException { final Unit unit = getByName(name); if (unit == null) { throw new NoSuchUnitException(name); } addByName(alias.getName(), unit); addByName(alias.getPlural(), unit); addBySymbol(alias.getSymbol(), unit); }