Class DataLoader

  extended bycom.edsdev.jconvert.persistence.DataLoader

public class DataLoader
extends java.lang.Object

This class is responsible for creating ConversionTypes by loading data from the data files that contain the specifiactions.

Here is an example of the datafile format:

  • #Conversion Type Name, FromUnit, From Unit Abbr, To Unit, To Unit Abbr, factor, offset
  • Temperature,Celsius,C,Celsius,C,1,0
  • Temperature,Celsius,C,Fahrenheit,F,9/5,32
  • Time,century,,day,dy,36500,0
  • Time,century,,decade,,10,0
  • Time,century,,fortnight,,18250/7,0
  • Time,century,,hour,hr,876000,0
  • Time,century,,leap-year,,36500/366,0
  • Time,century,,millennium,,0.10,0

    Ed Sarrazin Created on Jul 17, 2007 6:59:31 PM

    Constructor Summary
    Method Summary
     java.util.List loadData()
              This method will load data from convert.dat and convert_custom.dat.
     java.util.List loadData(java.lang.String resourceName, boolean generateGaps, java.util.List existingConversionTypes)
              This method is responsible for loading data from a resource into a list.
    static void main(java.lang.String[] args)
     void unloadData(java.util.List domainData, java.lang.String outputFileName)
              Writes the List of ConversionTypes to output.dat.
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Constructor Detail


    public DataLoader()
    Method Detail


    public static void main(java.lang.String[] args)


    public java.util.List loadData()
    This method will load data from convert.dat and convert_custom.dat. It will look in the classpath for these files.

    List of ConversionTypes


    public java.util.List loadData(java.lang.String resourceName,
                                   boolean generateGaps,
                                   java.util.List existingConversionTypes)
    This method is responsible for loading data from a resource into a list. Existing conversion types are passed into this method to provide support for generating gaps. For example if you create a conversion of decades to doubledecades and that is it. We will look at the existing conversions to also generate gaps such as doubledecades to year, months, days, etc.

    resourceName - String name of the resource that has the data to be loaded
    generateGaps - boolean that indicates whether or not to spend time generating missing conversions. This is needed because generating these gaps takes significant time and the default conversions that are supplied will have all combinatorics created before hand
    existingConversionTypes - List of existing conversion types that will be used in aiding generation of missing conversion types.
    List of ConversionTypes.


    public void unloadData(java.util.List domainData,
                           java.lang.String outputFileName)
    Writes the List of ConversionTypes to output.dat.

    domainData - List of ConversionTypes

    JConvert - opensource project by Ed Sarrazin