ucar.units
Class ConverterImpl

java.lang.Object
  extended by ucar.units.ConverterImpl
All Implemented Interfaces:
Converter
Direct Known Subclasses:
TimeScaleUnit.MyConverter, UnitImpl.MyConverter

public abstract class ConverterImpl
extends Object
implements Converter

Provides support for implementations of unit converters. A unit converter class may be created by subclassing this class and implementing the methods convert(double), convert(float[] input, float[] output) , and convert(double[] input, double[] output) of interface Converter.

Version:
$Id: ConverterImpl.java 64 2006-07-12 22:30:50Z edavis $
Author:
Steven R. Emmerson

Constructor Summary
protected ConverterImpl(Unit fromUnit, Unit toUnit)
          Constructs from a "from" unit and a "to" unit.
 
Method Summary
 double[] convert(double[] amounts)
          Converts an array of numeric values.
 float convert(float amount)
          Converts a numeric value.
 float[] convert(float[] amounts)
          Converts an array of numeric values.
static Converter create(Unit fromUnit, Unit toUnit)
          Factory method for creating a unit converter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ucar.units.Converter
convert, convert, convert
 

Constructor Detail

ConverterImpl

protected ConverterImpl(Unit fromUnit,
                        Unit toUnit)
                 throws ConversionException
Constructs from a "from" unit and a "to" unit.

Parameters:
fromUnit - The unit from which to convert.
toUnit - The unit to which to convert.
Throws:
ConversionException - The units are not convertible.
Method Detail

create

public static Converter create(Unit fromUnit,
                               Unit toUnit)
                        throws ConversionException
Factory method for creating a unit converter.

Parameters:
fromUnit - The unit from which to convert.
toUnit - The unit to which to convert.
Throws:
ConversionException - The units are not convertible.

convert

public final float convert(float amount)
Converts a numeric value.

Specified by:
convert in interface Converter
Parameters:
amount - The numeric value to convert.
Returns:
The converted numeric value.

convert

public final float[] convert(float[] amounts)
Converts an array of numeric values.

Specified by:
convert in interface Converter
Parameters:
amounts - The numeric values to convert.
Returns:
The converted numeric values in allocated space.

convert

public final double[] convert(double[] amounts)
Converts an array of numeric values.

Specified by:
convert in interface Converter
Parameters:
amounts - The numeric values to convert.
Returns:
The converted numeric values in allocated space.


Copyright © 1999-2011 UCAR/Unidata. All Rights Reserved.