UpdateJSON.displayTable()

UpdateJSON.displayTable()メソッドは、単に表全体をコマンドラインに書き込みます。

このメソッドでは、表の内容が特別な方法でフォーマットされることはありません。このメソッドは、データがストアで変更されたことをユーザーが簡単に確認できるように、用意されています。

    // Dumps the entire table to the command line.
    // Output is unformatted.
    private void displayTable(KVStore kvstore) {
        TableAPI tableH = kvstore.getTableAPI();
        Table myTable = tableH.getTable("personContacts");

        PrimaryKey pkey = myTable.createPrimaryKey();
        TableIterator<Row> iter = tableH.tableIterator(pkey, null,
                null);
        try {
            while (iter.hasNext()) {
                Row row = iter.next();
                System.out.println("\nAccount: " +
                        row.get("account").asInteger());
                if (row.get("person").isNull()) {
                    System.out.println("No person field");
                } else {
                    System.out.println(row.get("person").asMap());
                }
            }
        } finally {
            if (iter != null) {
                iter.close();
            }
        }
    }