DataTable
Inheritance: java.lang.Object
All Implemented Interfaces: com.groupdocs.assembly.system.data.DataTableEventListener
public class DataTable implements DataTableEventListener
Represents one table of in-memory data.
Constructors
Constructor | Description |
---|---|
DataTable() | Initializes a new instance of the DataTable class with no arguments. |
DataTable(String tableName) | Initializes a new instance of the DataTable class with the specified table name. |
DataTable(ResultSet resultSet) | Creates an object by wrapping the specified ResultSet. |
DataTable(ResultSet resultSet, String tableName) | Creates an object by wrapping the specified ResultSet. |
Methods
Method | Description |
---|---|
close() | |
getTableName() | Gets the name of the DataTable. |
setTableName(String value) | Sets the name of the DataTable. |
containsColumn(String columnName) | Check whether the given column exists or not |
getColumnsCount() | |
getColumnName(int index) | Analog for .Net DataTable.Columns[i].ColumnName |
getResultSet() | Returns the underlying Java ResultSet object. |
getDataSet() | Gets the DataSet to which this table belongs. |
getChildRelations() | Gets the collection of child relations for this DataTable. |
getParentRelations() | Gets the collection of parent relations for this DataTable. |
getRows() | Gets the collection of rows that belong to this table. |
getColumns() | Gets the collection of columns that belong to this table. |
newRow() | Creates a new DataRow with the same schema as the table. |
getConstraints() | Gets the collection of constraints maintained by this table. |
getPrimaryKey() | Gets an array of columns that function as primary keys for the data table. |
setPrimaryKey(DataColumn[] value) | Sets an array of columns that function as primary keys for the data table. |
getNamespace() | Gets the namespace for the XML representation of the data stored in the DataTable. |
setNamespace(String value) | Sets the namespace for the XML representation of the data stored in the DataTable. |
getEnforceConstraints() | |
setEnforceConstraints(boolean enforceConstraints) | |
refresh() | Reloads all the data from ResultSet if it is present. |
acceptChanges() | Commits all the changes made to this table since the last time acceptChanges() was called. |
addEventListener(DataTableEventListener listener) | |
clearEventListneers() | |
onDataRowChanged(DataRow row) | |
onDataRowInserted(DataRow row) | |
onDataRowDeleted(DataRow row) | |
onDataColumnInserted(DataColumn column) | |
onDataColumnDeleted(DataColumn column) |
DataTable()
public DataTable()
Initializes a new instance of the DataTable class with no arguments.
DataTable(String tableName)
public DataTable(String tableName)
Initializes a new instance of the DataTable class with the specified table name.
Parameters:
Parameter | Type | Description |
---|---|---|
tableName | java.lang.String | The name to give the table. If tableName is null or an empty string, a default name is given when added to the DataTableCollection. |
DataTable(ResultSet resultSet)
public DataTable(ResultSet resultSet)
Creates an object by wrapping the specified ResultSet. Attempts to retrieve the table name from the metadata of the first column of the ResultSet.
Parameters:
Parameter | Type | Description |
---|---|---|
resultSet | java.sql.ResultSet | data set |
DataTable(ResultSet resultSet, String tableName)
public DataTable(ResultSet resultSet, String tableName)
Creates an object by wrapping the specified ResultSet.
Parameters:
Parameter | Type | Description |
---|---|---|
resultSet | java.sql.ResultSet | data set |
tableName | java.lang.String | name of the table |
close()
public void close()
getTableName()
public String getTableName()
Gets the name of the DataTable.
Returns: java.lang.String - The name of the DataTable.
setTableName(String value)
public void setTableName(String value)
Sets the name of the DataTable.
Parameters:
Parameter | Type | Description |
---|---|---|
value | java.lang.String | The name of the DataTable. |
containsColumn(String columnName)
public boolean containsColumn(String columnName)
Check whether the given column exists or not
Parameters:
Parameter | Type | Description |
---|---|---|
columnName | java.lang.String | name of the column |
Returns:
boolean - true
is column can be found by the given columnName
getColumnsCount()
public int getColumnsCount()
Returns: int - columns count
getColumnName(int index)
public String getColumnName(int index)
Analog for .Net DataTable.Columns[i].ColumnName
Parameters:
Parameter | Type | Description |
---|---|---|
index | int | - column’s index |
Returns: java.lang.String - column’s name by its index.
getResultSet()
public ResultSet getResultSet()
Returns the underlying Java ResultSet object. Ideally we would like to work with DataTable in .Net manner. But some users and even some ours sample code are using this property.
Returns: java.sql.ResultSet - the underlying java.sql.ResultSet
getDataSet()
public DataSet getDataSet()
Gets the DataSet to which this table belongs.
Returns: DataSet - The DataSet to which this table belongs.
getChildRelations()
public DataRelationCollection getChildRelations()
Gets the collection of child relations for this DataTable.
Returns: DataRelationCollection - A DataRelationCollection that contains the child relations for the table. An empty collection is returned if no DataRelation objects exist.
getParentRelations()
public DataRelationCollection getParentRelations()
Gets the collection of parent relations for this DataTable.
Returns: DataRelationCollection - A DataRelationCollection that contains the parent relations for the table. An empty collection is returned if no DataRelation objects exist.
getRows()
public DataRowCollection getRows()
Gets the collection of rows that belong to this table.
Returns: DataRowCollection - A DataRowCollection that contains DataRow objects; otherwise a null value if no DataRow objects exist.
getColumns()
public DataColumnCollection getColumns()
Gets the collection of columns that belong to this table.
Returns: DataColumnCollection - A DataColumnCollection that contains the collection of DataColumn objects for the table. An empty collection is returned if no DataColumn objects exist.
newRow()
public DataRow newRow()
Creates a new DataRow with the same schema as the table.
Returns: DataRow - A DataRow with the same schema as the DataTable.
getConstraints()
public ConstraintCollection getConstraints()
Gets the collection of constraints maintained by this table.
Returns: ConstraintCollection - A ConstraintCollection that contains the collection of Constraint objects for the table. An empty collection is returned if no Constraint objects exist.
getPrimaryKey()
public DataColumn[] getPrimaryKey()
Gets an array of columns that function as primary keys for the data table.
Returns: com.groupdocs.assembly.system.data.DataColumn[] - An array of DataColumn objects.
setPrimaryKey(DataColumn[] value)
public void setPrimaryKey(DataColumn[] value)
Sets an array of columns that function as primary keys for the data table.
Parameters:
Parameter | Type | Description |
---|---|---|
value | DataColumn[] | An array of DataColumn objects. |
getNamespace()
public String getNamespace()
Gets the namespace for the XML representation of the data stored in the DataTable.
Returns: java.lang.String - The namespace of the DataTable.
setNamespace(String value)
public void setNamespace(String value)
Sets the namespace for the XML representation of the data stored in the DataTable.
Parameters:
Parameter | Type | Description |
---|---|---|
value | java.lang.String | The namespace of the DataTable. |
getEnforceConstraints()
public boolean getEnforceConstraints()
Returns: boolean - flag which indicates whether check constraint violation or not
setEnforceConstraints(boolean enforceConstraints)
public void setEnforceConstraints(boolean enforceConstraints)
Parameters:
Parameter | Type | Description |
---|---|---|
enforceConstraints | boolean | is the flag which indicates whether check constraint violation or not |
refresh()
public void refresh()
Reloads all the data from ResultSet if it is present.
acceptChanges()
public void acceptChanges()
Commits all the changes made to this table since the last time acceptChanges() was called.
addEventListener(DataTableEventListener listener)
public synchronized void addEventListener(DataTableEventListener listener)
Parameters:
Parameter | Type | Description |
---|---|---|
listener | DataTableEventListener |
clearEventListneers()
public synchronized void clearEventListneers()
onDataRowChanged(DataRow row)
public void onDataRowChanged(DataRow row)
Parameters:
Parameter | Type | Description |
---|---|---|
row | DataRow |
onDataRowInserted(DataRow row)
public void onDataRowInserted(DataRow row)
Parameters:
Parameter | Type | Description |
---|---|---|
row | DataRow |
onDataRowDeleted(DataRow row)
public void onDataRowDeleted(DataRow row)
Parameters:
Parameter | Type | Description |
---|---|---|
row | DataRow |
onDataColumnInserted(DataColumn column)
public void onDataColumnInserted(DataColumn column)
Parameters:
Parameter | Type | Description |
---|---|---|
column | DataColumn |
onDataColumnDeleted(DataColumn column)
public void onDataColumnDeleted(DataColumn column)
Parameters:
Parameter | Type | Description |
---|---|---|
column | DataColumn |