com.im.df.api 5.9

com.im.df.api.support
Class CalcTemplate

java.lang.Object
  extended by com.im.df.api.support.CalcTemplate
All Implemented Interfaces:
Calculable

public final class CalcTemplate
extends Object
implements Calculable

The template used in DFFieldCalcCapability. This is typically used as template for URL field with generated link. For example message format can be "http://www.mycompany.com/detail_for_structure?id={0}" where {0} will be replaced with value of field provided as params for each row.


Method Summary
static CalcTemplate create(String msgFormatPattern, DFField[] params)
          Creates a CalcTemplate instance for the message format and parameters
static CalcTemplate create(String msgFormatPattern, String[] fieldIDs, DFEntity entity)
          Creates a CalcTemplate instance for the message format and fields given by IDs.
 String getFormatPattern()
           
 DFField[] getParams()
           
 String getValue(Map<String,Object> values)
          Resolve the URL (as String) for given row.
 boolean isValid()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static CalcTemplate create(String msgFormatPattern,
                                  String[] fieldIDs,
                                  DFEntity entity)
Creates a CalcTemplate instance for the message format and fields given by IDs. Fields initialization is postponed as we need to create this in an early stage, when not all fields might be already initialized


create

public static CalcTemplate create(String msgFormatPattern,
                                  DFField[] params)
Creates a CalcTemplate instance for the message format and parameters


getFormatPattern

public String getFormatPattern()

getParams

public DFField[] getParams()
Specified by:
getParams in interface Calculable

isValid

public boolean isValid()

getValue

public String getValue(Map<String,Object> values)
Resolve the URL (as String) for given row.

Specified by:
getValue in interface Calculable
Parameters:
values - Values represents map of data in a single row. You can use the same Map you get from DFEntityDataProvider.getData(java.util.List, com.im.commons.progress.DFEnvironmentRO) method - obviously only Map for single row. It's expected that keys in this Map are Field.getId() and values are actual data for each field. These values are used for resolution of URL.
Returns:
The result URL if everything is correct
Throws:
IllegalStateException - if there is something incorrect (any used field is invalid, or if values doesn't contain the appropriate data for each used field, etc.)

com.im.df.api 5.9