class O2GTableIterator

Brief

The class traverses a trading table.

Details

The O2GTableIterator class is available only when your application uses the O2GTableManager class. An instance of the O2GTableManager class must have the O2GTableManagerStatus.TABLES_LOADED status. For complete instructions on the table manager usage, see the How to use table manager in ForexConnect API section.

An instance of the O2GTableIterator class references the current row in the trading table being traversed.
To create an instance of the class, use regular Java syntax. For example,

O2GTableIterator iterator = new O2GTableIterator();

An instance of the class initially references the first row of the table being traversed and is used as an argument in the methods that are responsible for getting the next row of the table. These methods are:

The rows of the trading tables are not sorted in any particular way. The iterator traverses a table consecutively. During the traversing process some rows may be added to the table, changed or deleted from the table. Depending on the order of a row, these changes may not be caught by the iterator. If you want to create a data snapshot at any moment, use the O2GTableManager.lockUpdates method. After the traversing process is completed, use the O2GTableManager.unlockUpdates method.

Example

Traverse the Trades table [hide]

    // Get open positions information
    O2GTradesTable tradesTable = (O2GTradesTable)tableManager.getTable(O2GTableType.TRADES);
    tableManager.lockUpdates();
    O2GTableIterator iterator = new O2GTableIterator();
    O2GTradeTableRow trade = tradesTable.getNextRow(iterator);
    while (trade != null) {
        System.out.println( "TradeID: " + trade.getTradeID() +
                            " Close = " +  trade.getClose()  +
                            " GrossPL= " + trade.getGrossPL());
        trade = tradesTable.getNextRow(iterator);
    }
    tableManager.unlockUpdates();

The namespace is com.fxcore2.

Public Constructors

O2GTableIterator

Initializes an object of the table iterator class.

Public Methods

reset

Places an instance of the table iterator at the beginning of the table being traversed.

back