com.edsdev.jconvert.persistence
Class DataLoader

java.lang.Object
  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

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

    Constructor Summary
    DataLoader()
               
     
    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

    DataLoader

    public DataLoader()
    Method Detail

    main

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

    loadData

    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.

    Returns:
    List of ConversionTypes

    loadData

    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.

    Parameters:
    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.
    Returns:
    List of ConversionTypes.

    unloadData

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

    Parameters:
    domainData - List of ConversionTypes


    JConvert - opensource project by Ed Sarrazin