Class MalcolmTable

java.lang.Object
org.eclipse.scanning.api.malcolm.MalcolmTable
All Implemented Interfaces:
Iterable<Map<String,Object>>

public class MalcolmTable extends Object implements Iterable<Map<String,Object>>
Class representing a table in Malcolm Format (List of columns with data). Instances of this class are NOT thread safe.
  • Constructor Details

    • MalcolmTable

      public MalcolmTable()
    • MalcolmTable

      public MalcolmTable(LinkedHashMap<String,List<?>> tableAsMap, LinkedHashMap<String,Class<?>> dataTypes)
      Create a new Malcolm table with the given columns data and data types. The size of each column must be equal, and the keys of both maps must be the same, these are the column headings.

      The passed maps are required to be LinkedHashMaps as the order of the columns must be maintained when the table is serialized

      Parameters:
      tableAsMap - a list of values for each column, of equal lengths
      dataTypes - a map of the data types for each column, this map must have the same keys as the tableAsMap
    • MalcolmTable

      public MalcolmTable(LinkedHashMap<String,Class<?>> dataTypes)
      Creates a new empty table with columns of the given types.
      Parameters:
      dataTypes - map from column name to data type for that column
  • Method Details

    • getColumn

      public <T> List<T> getColumn(String columnName)
    • getColumnClass

      public Class<?> getColumnClass(String columnName)
    • getRow

      public Map<String,Object> getRow(int rowIndex)
    • getCellValue

      public Object getCellValue(String columnName, int rowIndex)
    • getHeadings

      public List<String> getHeadings()
    • addRow

      public <T> void addRow(Map<String,T> newRow)
    • iterator

      public Iterator<Map<String,Object>> iterator()
      Returns an iterator over the rows of the table, where each row is represented as a Map from a column name (a String) to a value.
      Specified by:
      iterator in interface Iterable<Map<String,Object>>
      Returns:
      iterator over table rows
    • stream

      public Stream<Map<String,Object>> stream()
      Returns a stream of the rows of the table, where each row is represented as a Map from a column name (a String) to a value.
      Returns:
      stream of table rows
    • getTableData

      public Map<String,List<?>> getTableData()
    • setTableData

      public void setTableData(LinkedHashMap<String,List<?>> tableData)
    • getTableDataTypes

      public LinkedHashMap<String,Class<?>> getTableDataTypes()
    • setTableDataTypes

      public void setTableDataTypes(LinkedHashMap<String,Class<?>> tableDataTypes)
    • getNumRows

      public int getNumRows()
    • setNumRows

      public void setNumRows(int numRows)
    • isEmpty

      public boolean isEmpty()
    • setHeadings

      public void setHeadings(List<String> headings)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object