src/core/net/sf/basedb/util/units/UnitConverter.java

Code
Comments
Other
Rev Date Author Line
4544 25 Sep 08 nicklas 1 /**
4544 25 Sep 08 nicklas 2   $Id$
4544 25 Sep 08 nicklas 3
4544 25 Sep 08 nicklas 4   Copyright (C) 2008 Nicklas Nordborg
4544 25 Sep 08 nicklas 5
4544 25 Sep 08 nicklas 6   This file is part of BASE - BioArray Software Environment.
4544 25 Sep 08 nicklas 7   Available at http://base.thep.lu.se/
4544 25 Sep 08 nicklas 8
4544 25 Sep 08 nicklas 9   BASE is free software; you can redistribute it and/or
4544 25 Sep 08 nicklas 10   modify it under the terms of the GNU General Public License
4544 25 Sep 08 nicklas 11   as published by the Free Software Foundation; either version 3
4544 25 Sep 08 nicklas 12   of the License, or (at your option) any later version.
4544 25 Sep 08 nicklas 13
4544 25 Sep 08 nicklas 14   BASE is distributed in the hope that it will be useful,
4544 25 Sep 08 nicklas 15   but WITHOUT ANY WARRANTY; without even the implied warranty of
4544 25 Sep 08 nicklas 16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4544 25 Sep 08 nicklas 17   GNU General Public License for more details.
4544 25 Sep 08 nicklas 18
4544 25 Sep 08 nicklas 19   You should have received a copy of the GNU General Public License
4544 25 Sep 08 nicklas 20   along with BASE. If not, see <http://www.gnu.org/licenses/>.
4544 25 Sep 08 nicklas 21 */
4544 25 Sep 08 nicklas 22 package net.sf.basedb.util.units;
4544 25 Sep 08 nicklas 23
4544 25 Sep 08 nicklas 24 /**
4544 25 Sep 08 nicklas 25   Interface for converting values between two units. A unit converter
4544 25 Sep 08 nicklas 26   implemenation usually has a notion of a <i>specific unit</i> and
4544 25 Sep 08 nicklas 27   a <i>reference unit</i>, which are the two units the converter can
4544 25 Sep 08 nicklas 28   convert values from.
4544 25 Sep 08 nicklas 29   <p>
4544 25 Sep 08 nicklas 30   If rounding errors and truncation is ignored the following should
4544 25 Sep 08 nicklas 31   hold for any implementation:
4544 25 Sep 08 nicklas 32   <code>value == converter.convertFrom(converter.convertTo(value))</code>
4544 25 Sep 08 nicklas 33
4544 25 Sep 08 nicklas 34   @author Nicklas
4544 25 Sep 08 nicklas 35   @version 2.9
4544 25 Sep 08 nicklas 36   @base.modified $Date$
4544 25 Sep 08 nicklas 37 */
4544 25 Sep 08 nicklas 38 public interface UnitConverter
4544 25 Sep 08 nicklas 39 {
4544 25 Sep 08 nicklas 40   /**
4544 25 Sep 08 nicklas 41     Convert a value from the specific unit to the reference unit.
4544 25 Sep 08 nicklas 42     @param specificValue The value to convert
4544 25 Sep 08 nicklas 43     @return The converted value
4544 25 Sep 08 nicklas 44   */
4544 25 Sep 08 nicklas 45   public double convertToReferenceUnit(double specificValue);
4544 25 Sep 08 nicklas 46   
4544 25 Sep 08 nicklas 47   /**
4544 25 Sep 08 nicklas 48     Convert a value from the reference unit to the specific unit.
4544 25 Sep 08 nicklas 49     @param referenceValue The reference value
4544 25 Sep 08 nicklas 50     @return The converted value
4544 25 Sep 08 nicklas 51   */
4544 25 Sep 08 nicklas 52   public double convertToSpecificUnit(double referenceValue);
4544 25 Sep 08 nicklas 53
4544 25 Sep 08 nicklas 54
4544 25 Sep 08 nicklas 55 }