org.decisiondeck.jmcda.persist.utils
Class ExportUtils

java.lang.Object
  extended by org.decisiondeck.jmcda.persist.utils.ExportUtils

public class ExportUtils
extends Object


Constructor Summary
ExportUtils()
           
 
Method Summary
static void copySettings(ExportSettings source, ExportSettings target)
          Copies the settings found in the given source to the given target, overriding the target to make it equivalent to the source.
static FunctionWithInputCheck<Category,String> getCategoryRankFct(ISortingData sortingData)
          Retrieves a function that associates to a category its rank (1 is the best one) as an English formatted string.
static
<I> Function<I,String>
getInputToIntToStringFct(Map<I,Integer> ints)
          Retrieves a function that associates to an object an integer as an English formatted string.
static
<I> FunctionWithInputCheck<I,String>
getInputToIntToStringFctWithInputCheck(Map<I,Integer> ints)
          Retrieves a function that associates to an object an integer as an English formatted string.
static ExportSettings newExportByIndexSettings(IGroupSortingData source)
          Note that the returned settings contain copy of the given source data, thus writing to the source data is not reflected in the settings, thus after a write the previously returned settings object should not be used anymore as it will be outdated.
static ExportSettings newExportByIndexSettings(ISortingData source, int countFrom)
          Note that the returned settings contain copy of the given source data, thus writing to the source data is not reflected in the settings, thus after a write the previously returned settings object should not be used anymore as it will be outdated.
static ExportSettings newExportSettings(ISortingData source)
          Note that the returned settings contain copy of the given source data, thus writing to the source data is not reflected in the settings, thus after a write the previously returned settings object should not be used anymore as it will be outdated.
static void setOrder(ISortingData source, ExportSettings target)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExportUtils

public ExportUtils()
Method Detail

copySettings

public static void copySettings(ExportSettings source,
                                ExportSettings target)
Copies the settings found in the given source to the given target, overriding the target to make it equivalent to the source. If some orders are not defined in the source, they end up being not defined either in the target.

Parameters:
source - not null.
target - not null.

getInputToIntToStringFctWithInputCheck

public static <I> FunctionWithInputCheck<I,String> getInputToIntToStringFctWithInputCheck(Map<I,Integer> ints)
Retrieves a function that associates to an object an integer as an English formatted string. The returned function knows the mapping at the time this method is called, it is not a view to the given map (which means that if the data is changed, this is not reflected in the returned function). The returned function will throw an InvalidInputException iff it is asked about an input object that did not exist in the given data at the time this method was called.

Type Parameters:
I - the input object type.
Parameters:
ints - not null.
Returns:
not null.

getCategoryRankFct

public static FunctionWithInputCheck<Category,String> getCategoryRankFct(ISortingData sortingData)
Retrieves a function that associates to a category its rank (1 is the best one) as an English formatted string. The returned function knows the categories at the time this method is called, it is not a view to the given data (which means that if the data is changed, this is not reflected in the returned function). If the categories are incomplete, the rank is still computed according to the order from best to worst, even though it will not necessarily be compatible with the profiles ranks. The returned function will throw an InvalidInputException iff it is asked for a rank of a category that did not exist in the given data at the time this method was called, otherwize it returns a string corresponding to a number between one and the number of categories.

Parameters:
sortingData - not null.
Returns:
not null.

getInputToIntToStringFct

public static <I> Function<I,String> getInputToIntToStringFct(Map<I,Integer> ints)
Retrieves a function that associates to an object an integer as an English formatted string. The returned function knows the mapping at the time this method is called, it is not a view to the given map (which means that if the data is changed, this is not reflected in the returned function). The returned function will throw an InvalidInputException iff it is asked about an input object that did not exist in the given data at the time this method was called.

Type Parameters:
I - the input object type.
Parameters:
ints - not null.
Returns:
not null.

newExportByIndexSettings

public static ExportSettings newExportByIndexSettings(ISortingData source,
                                                      int countFrom)
Note that the returned settings contain copy of the given source data, thus writing to the source data is not reflected in the settings, thus after a write the previously returned settings object should not be used anymore as it will be outdated.

Parameters:
source - not null. The profiles must all be ordered through the categories and profiles object.
countFrom - the index to start counting from (typically zero or one). Applies to alternatives, profiles, criteria, categories.
Returns:
a settings object configured to export indexes of the objects (i.e. alternatives, profiles, criteria, categories), ordered by their natural ordering, thus alphabetical order of their id, except categories and profiles which are ordered from worst to best.

newExportSettings

public static ExportSettings newExportSettings(ISortingData source)
Note that the returned settings contain copy of the given source data, thus writing to the source data is not reflected in the settings, thus after a write the previously returned settings object should not be used anymore as it will be outdated. The returned settings order on the decision makers is unspecified.

Parameters:
source - not null. The profiles must all be ordered through the categories and profiles object.
Returns:
a settings object configured to export ids of the objects (i.e. alternatives, profiles, criteria, categories), ordered by their natural ordering, thus alphabetical order of their id, except categories and profiles which are ordered from worst (index 0) to best.

setOrder

public static void setOrder(ISortingData source,
                            ExportSettings target)

newExportByIndexSettings

public static ExportSettings newExportByIndexSettings(IGroupSortingData source)
Note that the returned settings contain copy of the given source data, thus writing to the source data is not reflected in the settings, thus after a write the previously returned settings object should not be used anymore as it will be outdated.

Parameters:
source - not null. The profiles must all be ordered through the categories and profiles object.
Returns:
a settings object configured to export indexes of the objects (i.e. alternatives, profiles, criteria, decision makers, categories), counting from zero, ordered by their natural ordering, thus alphabetical order of their id, except categories and profiles which are ordered from worst (index 0) to best.


Copyright © 2011. All Rights Reserved.