DataTable
javanpst.data.structures.dataTable

Class DataTable



  • public class DataTableextends Object
    A general purpose data table. Support null values treatment.
    • Constructor Detail

      • DataTable

        public DataTable()
        Default builder
      • DataTable

        public DataTable(double[][] data)
        Builder. Built a new table from a data matrix Both matrixes must have the same dimensions, else a void table is created
        Parameters:
        data - contents of the table
      • DataTable

        public DataTable(double[][] data,         boolean[][] nullV)
        Builder. Allows to specify which values are null. Both matrixes must have the same dimensions, else a void table is created
        Parameters:
        data - contents of the table
        nullV - null values matrix
    • Method Detail

      • newInstance

        public static DataTable newInstance(DataTable aTable)
        Copy constructor
        Parameters:
        aTable - old table
        Returns:
        a copy of aTable
      • getBody

        public double[][] getBody()
        Get the data matrix
        Returns:
        values of the table
      • getNulls

        public boolean[][] getNulls()
        Get the matrix of nulls
        Returns:
        null values of the table
      • isNull

        public boolean isNull(int row,             int col)
        Returns if the selected value is null of not
        Returns:
        true if it is null, false otherwise
      • getRows

        public int getRows()
        Get the number of rows
        Returns:
        number of rows of the table
      • getColumns

        public int getColumns()
        Get the number of columns
        Returns:
        number of columns of the table
      • clear

        public void clear()
        Clear method. Set all values of the table to null
      • setDimensions

        public void setDimensions(int row,                 int col)
        Set new dimensions. Table is cleared after resizing
        Parameters:
        row - new number of rows
        col - new number of columns
      • setRows

        public void setRows(int row)
        Set new number of rows
        Parameters:
        row - new number of rows
      • setColumns

        public void setColumns(int col)
        Set new number of columns
        Parameters:
        col - new number of columns
      • setValue

        public void setValue(int row,            int col,            double value)
        Sets a new value
        Parameters:
        row - row index
        col - col index
        value - value to set
      • setNull

        public void setNull(int row,           int col)
        Sets a null value
        Parameters:
        row - row index
        col - col index
      • setRow

        public void setRow(int row,          double[] array)
        Sets a entire row
        Parameters:
        row - row to set
        array - array of values
      • setColumn

        public void setColumn(int col,             double[] array)
        Sets a entire column
        Parameters:
        col - column to set
        array - array of values
      • getRowNulls

        public int getRowNulls(int row)
        Get the number of null values in the selected row
        Parameters:
        row - row selected
        Returns:
        number of null values
      • getColumnNulls

        public int getColumnNulls(int col)
        Get the number of null values in the selected column
        Parameters:
        col - column selected
        Returns:
        number of null values
      • get

        public double get(int row,         int col)
        Get a value. Returns NULL_VALUE if null.
        Parameters:
        row - row index
        col - col index
        Returns:
        value stored
      • getRow

        public double[] getRow(int row)
        Get a row (no null values are considered)
        Parameters:
        row - row index
        Returns:
        array with values stored
      • getColumn

        public double[] getColumn(int col)
        Get a column (no null values are considered)
        Parameters:
        col - column index
        Returns:
        array with values stored
      • readXML

        public void readXML(String file)
        Loads a table from a XML file
        Parameters:
        file - path of the file
      • writeXML

        public void writeXML(String file)
        Writes a table to a XML file
        Parameters:
        file - path of the file
      • readCSV

        public void readCSV(String file)
        Loads a table from a CSV file
        Parameters:
        file - path of the file
      • writeCSV

        public void writeCSV(String file,            boolean useComma)
        Writes a table to a CSV file
        Parameters:
        file - path of the file
        useComma - true true if "," is used as separator, false if ";" is used instead
      • readTXT

        public void readTXT(String file)
        Loads a table from a TXT file
        Parameters:
        file - path of the file
      • writeTXT

        public void writeTXT(String file)
        Writes a table to a TXT file
        Parameters:
        file - path of the file

SCaVis 2.2 © jWork.ORG