public method O2GClosedTradesTable.getNextGenericRowByColumnValue

Brief

Gets the next row from O2GTable based on the column value.

Declaration
Java
O2GRow  getNextGenericRowByColumnValue (String columnId, Object columnValue, O2GTableIterator iterator)

Parameters
columnId

The unique identifier of a column.

columnValue

The value of the column specified by the columnId parameter.

iterator

The table iterator.

Details

If the row is not found, the method returns null.
If you develop a GUI application based on ForexConnect API, the method is useful for filtering rows of a table by particular parameter. For example, if you want to display open positions and orders for a particular account only, use AccountID as the columnId parameter.
Note: The returned row contains the current column values. The values are not automatically updated. To monitor changes, use IO2GTableListener.onChanged. The row interface is thread-safe. The returned row can be used in different threads without synchronization.

Example

Filtering orders and trades by a particular account [hide]

    // Get tables, create iterator, call printTable method
    String mColumnID = "AccountID";
    String mValue = "******";
    if (tableManager.getStatus() == O2GTableManagerStatus.TABLES_LOADED) {
        O2GOrdersTable ordersTable = (O2GOrdersTable)tableManager.getTable(O2GTableType.ORDERS);
        O2GTradesTable tradesTable = (O2GTradesTable)tableManager.getTable(O2GTableType.TRADES);
        O2GTableIterator iterator = new O2GTableIterator();
        printTable(ordersTable, iterator, mColumnID, mValue);
        printTable(tradesTable, iterator, mColumnID, mValue);
    }
 
    // Print table using getNextGenericRowByColumnValue
    public static void printTable(O2GTable table, O2GTableIterator iterator, String columnID, Object value) {
        O2GTableType tableType = table.getType();
        O2GRow row = table.getNextGenericRowByColumnValue(columnID, value, iterator);
        if (row == null) {
            System.out.println("Table " + tableType + " does not have value " + value + " for the column " + columnID + ".");
        }
        while (row != null) {
            System.out.println("\nPrinting a row from the " + tableType + " table.\n");
            O2GTableColumnCollection collection = row.getColumns();
            for (int i = 0; i < collection.size(); i++) {
                O2GTableColumn column = collection.get(i);
                System.out.print(column.getId() + "=" + row.getCell(i) + ";");
            }
            System.out.println();
            row = table.getNextGenericRowByColumnValue(columnID, value, iterator);
        }
    }

Declared in O2GTable

back