EMMA Coverage Report (generated Sun Mar 01 22:06:14 CET 2015)
[all classes][org.h2.index]

COVERAGE SUMMARY FOR SOURCE FILE [FunctionCursorResultSet.java]

nameclass, %method, %block, %line, %
FunctionCursorResultSet.java100% (1/1)80%  (4/5)88%  (91/103)79%  (22/28)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class FunctionCursorResultSet100% (1/1)80%  (4/5)88%  (91/103)79%  (22/28)
previous (): boolean 0%   (0/1)0%   (0/2)0%   (0/1)
FunctionCursorResultSet (Session, ResultSet): void 100% (1/1)78%  (14/18)75%  (6/8)
get (): Row 100% (1/1)89%  (17/19)80%  (4/5)
next (): boolean 100% (1/1)93%  (57/61)85%  (11/13)
getSearchRow (): SearchRow 100% (1/1)100% (3/3)100% (1/1)

1/*
2 * Copyright 2004-2014 H2 Group. Multiple-Licensed under the MPL 2.0,
3 * and the EPL 1.0 (http://h2database.com/html/license.html).
4 * Initial Developer: H2 Group
5 */
6package org.h2.index;
7 
8import java.sql.ResultSet;
9import java.sql.ResultSetMetaData;
10import java.sql.SQLException;
11import org.h2.engine.Session;
12import org.h2.message.DbException;
13import org.h2.result.Row;
14import org.h2.result.SearchRow;
15import org.h2.value.DataType;
16import org.h2.value.Value;
17 
18/**
19 * A cursor for a function that returns a JDBC result set.
20 */
21public class FunctionCursorResultSet implements Cursor {
22 
23    private final Session session;
24    private final ResultSet result;
25    private final ResultSetMetaData meta;
26    private Value[] values;
27    private Row row;
28 
29    FunctionCursorResultSet(Session session, ResultSet result) {
30        this.session = session;
31        this.result = result;
32        try {
33            this.meta = result.getMetaData();
34        } catch (SQLException e) {
35            throw DbException.convert(e);
36        }
37    }
38 
39    @Override
40    public Row get() {
41        if (values == null) {
42            return null;
43        }
44        if (row == null) {
45            row = new Row(values, 1);
46        }
47        return row;
48    }
49 
50    @Override
51    public SearchRow getSearchRow() {
52        return get();
53    }
54 
55    @Override
56    public boolean next() {
57        row = null;
58        try {
59            if (result != null && result.next()) {
60                int columnCount = meta.getColumnCount();
61                values = new Value[columnCount];
62                for (int i = 0; i < columnCount; i++) {
63                    int type = DataType.getValueTypeFromResultSet(meta, i + 1);
64                    values[i] = DataType.readValue(session, result, i + 1, type);
65                }
66            } else {
67                values = null;
68            }
69        } catch (SQLException e) {
70            throw DbException.convert(e);
71        }
72        return values != null;
73    }
74 
75    @Override
76    public boolean previous() {
77        throw DbException.throwInternalError();
78    }
79 
80}

[all classes][org.h2.index]
EMMA 2.0.5312 (C) Vladimir Roubtsov