Class CalcTemplate

  • All Implemented Interfaces:
    Calculable

    public final class CalcTemplate
    extends java.lang.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.
    Author:
    Petr Hamernik
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static CalcTemplate create​(java.lang.String msgFormatPattern, DFField[] params)
      Creates a CalcTemplate instance for the message format and parameters
      static CalcTemplate create​(java.lang.String msgFormatPattern, java.lang.String[] fieldIDs, DFEntity entity)
      Creates a CalcTemplate instance for the message format and fields given by IDs.
      java.lang.String getFormatPattern()  
      DFField[] getParams()  
      java.lang.String getValue​(java.util.Map<java.lang.String,​java.lang.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​(java.lang.String msgFormatPattern,
                                          java.lang.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​(java.lang.String msgFormatPattern,
                                          DFField[] params)
        Creates a CalcTemplate instance for the message format and parameters
      • getFormatPattern

        public java.lang.String getFormatPattern()
      • isValid

        public boolean isValid()
      • getValue

        public java.lang.String getValue​(java.util.Map<java.lang.String,​java.lang.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:
        java.lang.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.)