DataRowCollection

Inheritance: java.lang.Object

All Implemented Interfaces: java.lang.Iterable

public class DataRowCollection implements Iterable

Represents a collection of rows for a DataTable.

Methods

MethodDescription
add(System.Data.DataRow row)Adds the specified DataRow to the DataRowCollection object.
add(Object[] values)Creates a row using specified values and adds it to the DataRowCollection.
clear()Clears the collection of all rows.
find(Object[] keys)Gets the row that contains the specified primary key values.
find(String primaryKeyValue)Gets the row specified by the primary key value.
get(int index)Gets the row at the specified index.
get(Object[] values)Gets the row that contains the specified values.
getCount()Gets the total number of DataRow objects in this collection.
insertAt(System.Data.DataRow row, int pos)Inserts a new row into the collection at the specified location.
iterator()Gets an java.util.Iterator for this collection.
removeAt(int index)Removes the row at the specified index from the collection.

add(System.Data.DataRow row)

public void add(System.Data.DataRow row)

Adds the specified DataRow to the DataRowCollection object.

Parameters:

ParameterTypeDescription
rowDataRowThe DataRow to add.

add(Object[] values)

public void add(Object[] values)

Creates a row using specified values and adds it to the DataRowCollection.

Parameters:

ParameterTypeDescription
valuesjava.lang.Object[]The array of values that are used to create the new row.

clear()

public void clear()

Clears the collection of all rows.

find(Object[] keys)

public System.Data.DataRow find(Object[] keys)

Gets the row that contains the specified primary key values.

Parameters:

ParameterTypeDescription
keysjava.lang.Object[]An array of primary key values to find. The type of the array is Object.

Returns: DataRow - A DataRow object that contains the primary key values specified; otherwise a null value if the primary key value does not exist in the DataRowCollection.

find(String primaryKeyValue)

public System.Data.DataRow find(String primaryKeyValue)

Gets the row specified by the primary key value.

Parameters:

ParameterTypeDescription
primaryKeyValuejava.lang.StringThe primary key value of the DataRow to find.

Returns: DataRow - A DataRow that contains the primary key value specified; otherwise a null value if the primary key value does not exist in the DataRowCollection.

get(int index)

public System.Data.DataRow get(int index)

Gets the row at the specified index.

Parameters:

ParameterTypeDescription
indexintThe zero-based index of the row to return.

Returns: DataRow - The specified DataRow.

get(Object[] values)

public System.Data.DataRow get(Object[] values)

Gets the row that contains the specified values. If there is primary key’s column(s) present then the index will be used. If there is no index then simple linear scan is used. Be carefully with that because it could take a significant amount of time.

Parameters:

ParameterTypeDescription
valuesjava.lang.Object[]row’s data

Returns: DataRow - found row or null

getCount()

public int getCount()

Gets the total number of DataRow objects in this collection.

Returns: int - The total number of DataRow objects in this collection.

insertAt(System.Data.DataRow row, int pos)

public void insertAt(System.Data.DataRow row, int pos)

Inserts a new row into the collection at the specified location.

Parameters:

ParameterTypeDescription
rowDataRowThe DataRow to add.
posintThe (zero-based) location in the collection where you want to add the DataRow.

iterator()

public Iterator iterator()

Gets an java.util.Iterator for this collection.

Returns: java.util.Iterator - An java.util.Iterator for this collection.

removeAt(int index)

public void removeAt(int index)

Removes the row at the specified index from the collection.

Parameters:

ParameterTypeDescription
indexintThe index of the row to remove.