Ejemplo n.º 1
0
 /**
  * The Method delegates the unit convertes to the unitConverter Class
  *
  * @param value metric value, which is to be converted
  * @return The converted value as String
  */
 public String getConvertedLocaleUnit(double value) {
   return converter.getValue(value);
 }
Ejemplo n.º 2
0
 /**
  * Here you can set a new unitConverter. The converter must implemets the LocaleUnits interface.
  *
  * @param unitConverter a class which can calculate a
  * @return
  */
 public String setUnitConverter(LocaleUnits unitConverter) {
   converter = unitConverter;
   return converter.getDisplayName();
 }
Ejemplo n.º 3
0
 /**
  * This method converts a given metric value in the new system value. E.g. meters in foots
  *
  * @param unitInMeters Input value in meters
  * @param toUnit a string that indicates what unit to convert to. For the available Strings you
  *     must see in the docs of the concrete converter
  * @return A String the includes the converted value, and the unit
  * @throws NoConverterExeption Will raised, when you have forgotten to set the concrete unit
  *     converter
  * @throws NotSupportedUnitException Will raised when the unit is not supported by the converter.
  *     There is a list with all options on the most Exceptions saved, in the field supportedUnits
  */
 public String convertFromMeters(double unitInMeters, String toUnit)
     throws NoConverterExeption, NotSupportedUnitException {
   if (!checkIsSetTheConverter()) throw new NoConverterExeption("It isn't set a converter");
   return converter.convertFromMeters(unitInMeters, toUnit);
 }