Documentation of 'javanpst.data.structures.dataTable.DataTable' Java class
DataTable
javanpst.data.structures.dataTable

Class DataTable



  • public class DataTable
    extends java.lang.Object
    A general purpose data table. Support null values treatment.
    • Constructor Summary

      Constructors 
      Constructor and Description
      DataTable()
      Default builder
      DataTable(double[][] data)
      Builder.
      DataTable(double[][] data, boolean[][] nullV)
      Builder.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void clear()
      Clear method.
      double get(int row, int col)
      Get a value.
      double[][] getBody()
      Get the data matrix
      double[] getColumn(int col)
      Get a column (no null values are considered)
      int getColumnNulls(int col)
      Get the number of null values in the selected column
      int getColumns()
      Get the number of columns
      boolean[][] getNulls()
      Get the matrix of nulls
      double[] getRow(int row)
      Get a row (no null values are considered)
      int getRowNulls(int row)
      Get the number of null values in the selected row
      int getRows()
      Get the number of rows
      boolean isNull(int row, int col)
      Returns if the selected value is null of not
      static DataTable newInstance(DataTable aTable)
      Copy constructor
      void readCSV(java.lang.String file)
      Loads a table from a CSV file
      void readTXT(java.lang.String file)
      Loads a table from a TXT file
      void readXML(java.lang.String file)
      Loads a table from a XML file
      void setColumn(int col, double[] array)
      Sets a entire column
      void setColumns(int col)
      Set new number of columns
      void setDimensions(int row, int col)
      Set new dimensions.
      void setNull(int row, int col)
      Sets a null value
      void setRow(int row, double[] array)
      Sets a entire row
      void setRows(int row)
      Set new number of rows
      void setValue(int row, int col, double value)
      Sets a new value
      java.lang.String toString()
      To String method
      void writeCSV(java.lang.String file, boolean useComma)
      Writes a table to a CSV file
      void writeTXT(java.lang.String file)
      Writes a table to a TXT file
      void writeXML(java.lang.String file)
      Writes a table to a XML file
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • 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
      • toString

        public java.lang.String toString()
        To String method
        Overrides:
        toString in class java.lang.Object
      • readXML

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

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

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

        public void writeCSV(java.lang.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(java.lang.String file)
        Loads a table from a TXT file
        Parameters:
        file - path of the file
      • writeTXT

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

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.