TwoDimensionalValueObject (2DVO) is a object that can hold a two dimensional array of ValueObjects. This makes it convenient to store values from a database table. The data is stored in column format with each column being represented by a vector. There are n of these where n is the number of rows. All these are stored in a single vector “values”.

That is, the size of the Vector is the number of rows of the data. The organization is: Vector 'Values' (size()== number of columns) VectorColumn0 [Row0Value, Row1Value, …] (size() = number of rows) VectorColumn1 [Row0Value, Row1Value, …] VectorColumn2 [Row0Value, Row1Value, …] ..

getColumnCount() returns values.size(); getRowCount() returns values.elementAt(0)).size(). The data is square, that is, no column values are missing, no rows are short.

Overall, The core idea of 2DVO is to represent each column as a vector and then store these vectors in a main vector. This structure allows for efficient access to rows and columns.

The following code snippet demonstrates how to extract data from a TwoDimensionalValueObject and populate a java.util.ArrayList with the objects in an object called “dataObject”:

//1. Create a variable to store the 2DVO object values in a java.util.ArrayList

var dataArrayList = new java.util.ArrayList();

//2. Get all data from the database by using Database Raw Table Lookup, the output is in a 2D value object with rows and columns. Asssigne the output to a variable "dataResult:

 var dataResult = 2DVO table output; 

// Count the rows of the table using vector.getRowCount() method

rowCount = dataResult.getRowCount();

for (var i = 0; i < rowCount; i++) {
    // If want to get all the objects, each row is one object
    var rowData = dataResult.getRow(i);

    // below codes use vector.getValueAt(i, column_index) method to retrieve the values of a specific column and assign it to the corresponding property in the SomeDataObject instance

    // Create a new object (replace with your actual object type)
    var dataObject = new SomeDataObject();

    
    // To access properties and populate dataObject

	        dataObject.property1 =dataResult.getValueAt (i, 0);
		dataObject.property2=dataResult.getValueAt(i, 1);
		dataObject.property3 =dataResult.getValueAt(i, 2);
		...
		dataObject.property6 = dataResult.getValueAt(i, 5);
		dataObject.property7 = dataResult.getValueAt(i, 6);
		....


    // Add each data object to the dataArrayList
    dataArrayList.add(dataObject);
}