File: ResultWrapper.java

package info (click to toggle)
libpgjava 8.4-701-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 3,532 kB
  • ctags: 4,162
  • sloc: java: 33,948; xml: 3,158; makefile: 14; sh: 10
file content (63 lines) | stat: -rw-r--r-- 1,583 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*-------------------------------------------------------------------------
*
* Copyright (c) 2004-2008, PostgreSQL Global Development Group
* Copyright (c) 2004, Open Cloud Limited.
*
* IDENTIFICATION
*   $PostgreSQL: pgjdbc/org/postgresql/jdbc2/ResultWrapper.java,v 1.5 2008/01/08 06:56:29 jurka Exp $
*
*-------------------------------------------------------------------------
*/
package org.postgresql.jdbc2;

import java.sql.*;

/**
 * Helper class that storing result info. This handles both the
 * ResultSet and no-ResultSet result cases with a single interface for
 * inspecting and stepping through them.
 *
 * @author Oliver Jowett (oliver@opencloud.com)
 */
public class ResultWrapper {
    public ResultWrapper(ResultSet rs) {
        this.rs = rs;
        this.updateCount = -1;
        this.insertOID = -1;
    }

    public ResultWrapper(int updateCount, long insertOID) {
        this.rs = null;
        this.updateCount = updateCount;
        this.insertOID = insertOID;
    }

    public ResultSet getResultSet() {
        return rs;
    }

    public int getUpdateCount() {
        return updateCount;
    }

    public long getInsertOID() {
        return insertOID;
    }

    public ResultWrapper getNext() {
        return next;
    }

    public void append(ResultWrapper newResult) {
        ResultWrapper tail = this;
        while (tail.next != null)
            tail = tail.next;

        tail.next = newResult;
    }

    private final ResultSet rs;
    private final int updateCount;
    private final long insertOID;
    private ResultWrapper next;
}