Class DataContainer

java.lang.Object
net.simplace.sim.wrapper.DataContainer

public class DataContainer extends Object
Delivers data to wrapper clients (R, Python, ...) as simple types: parallel arrays of column names, units, data type names and values. Built either from a variable map (one value per variable, see SimplaceWrapper.step()) or from result caches of MEMORY outputs (one array of values per column, see SimplaceWrapper.getResult(String, String)). Dates of result caches are returned as ISO strings.
Author:
Andreas Enders
  • Constructor Details

    • DataContainer

      public DataContainer(FWSimVarMap aVarMap)
      Creates the container from all variables of a variable map.
      Parameters:
      aVarMap - the variable map
    • DataContainer

      public DataContainer(FWSimVarMap aVarMap, String[] aFieldNameFilter)
      Creates the container from the given variables of a variable map. An unknown name is logged and returned with type NULL.
      Parameters:
      aVarMap - the variable map
      aFieldNameFilter - names of the variables (not changed, the header is a copy)
    • DataContainer

      public DataContainer(Collection<FWSimResultCache> aResultCaches)
      Creates the container from several result caches with the same fields (e.g. of several simulations); their rows are concatenated.
      Parameters:
      aResultCaches - the result caches, must not be empty
    • DataContainer

      public DataContainer(FWSimResultCache aResultCache)
      Creates the container from a result cache.
      Parameters:
      aResultCache - the result cache
  • Method Details

    • fill

      public void fill(FWSimResultCache aResultCache, int aStartIndex, int aSize)
      Copies the rows of a result cache into the column arrays. With start index 0 header, units, types and the column arrays are created first.
      Parameters:
      aResultCache - the result cache
      aStartIndex - row index of the first row of this cache
      aSize - total number of rows (only used when creating the arrays)
    • getHeaderStrings

      public String[] getHeaderStrings()
      Returns:
      the column (variable) names
    • getHeaderUnits

      public String[] getHeaderUnits()
      Returns:
      the units of the columns
    • getTypeStrings

      public String[] getTypeStrings()
      Returns:
      the data type names of the columns
    • getDataObjects

      public Object[] getDataObjects()
      Returns:
      the values per column: single values (variable map) or arrays of values (result cache)
    • getDataObjects

      public Object[] getDataObjects(int from, int to)
      Returns a range of rows: each column array is copied with Arrays.copyOfRange(Object[], int, int), so the result is padded with null if to exceeds the number of rows. Only for containers created from result caches.
      Parameters:
      from - first row (inclusive)
      to - last row (exclusive)
      Returns:
      the column arrays of the range
      Throws:
      ArrayIndexOutOfBoundsException - if from < 0 or from is greater than the number of rows
      IllegalArgumentException - if from > to
    • isLast

      public boolean isLast()
      Returns:
      true if this is the last result of a simulation (the simulation has ended)
    • setLast

      public void setLast(boolean aLast)
      Parameters:
      aLast - true if this is the last result of a simulation