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

COVERAGE SUMMARY FOR SOURCE FILE [DbProcedure.java]

nameclass, %method, %block, %line, %
DbProcedure.java100% (1/1)71%  (5/7)93%  (103/111)92%  (22.9/25)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class DbProcedure100% (1/1)71%  (5/7)93%  (103/111)92%  (22.9/25)
getQuotedName (): String 0%   (0/1)0%   (0/3)0%   (0/1)
isReturnsResult (): boolean 0%   (0/1)0%   (0/3)0%   (0/1)
DbProcedure (DbSchema, ResultSet): void 100% (1/1)93%  (26/28)99%  (5.9/6)
getName (): String 100% (1/1)100% (3/3)100% (1/1)
getParameters (): DbColumn [] 100% (1/1)100% (3/3)100% (1/1)
getSchema (): DbSchema 100% (1/1)100% (3/3)100% (1/1)
readParameters (DatabaseMetaData): void 100% (1/1)100% (68/68)100% (14/14)

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.bnf.context;
7 
8import org.h2.util.New;
9 
10import java.sql.DatabaseMetaData;
11import java.sql.ResultSet;
12import java.sql.SQLException;
13import java.util.ArrayList;
14 
15/**
16 * Contains meta data information about a procedure.
17 * This class is used by the H2 Console.
18 */
19public class DbProcedure {
20 
21    private final DbSchema schema;
22    private final String name;
23    private final String quotedName;
24    private boolean returnsResult;
25    private DbColumn[] parameters;
26 
27    public DbProcedure(DbSchema schema, ResultSet rs) throws SQLException {
28        this.schema = schema;
29        name = rs.getString("PROCEDURE_NAME");
30        returnsResult = rs.getShort("PROCEDURE_TYPE") ==
31                DatabaseMetaData.procedureReturnsResult;
32        quotedName = schema.getContents().quoteIdentifier(name);
33    }
34 
35    /**
36     * @return The schema this table belongs to.
37     */
38    public DbSchema getSchema() {
39        return schema;
40    }
41 
42    /**
43     * @return The column list.
44     */
45    public DbColumn[] getParameters() {
46        return parameters;
47    }
48 
49    /**
50     * @return The table name.
51     */
52    public String getName() {
53        return name;
54    }
55 
56    /**
57     * @return The quoted table name.
58     */
59    public String getQuotedName() {
60        return quotedName;
61    }
62 
63    /**
64     * @return True if this function return a value
65     */
66    public boolean isReturnsResult() {
67        return returnsResult;
68    }
69 
70    /**
71     * Read the column for this table from the database meta data.
72     *
73     * @param meta the database meta data
74     */
75    void readParameters(DatabaseMetaData meta) throws SQLException {
76        ResultSet rs = meta.getProcedureColumns(null, schema.name, name, null);
77        ArrayList<DbColumn> list = New.arrayList();
78        while (rs.next()) {
79            DbColumn column = DbColumn.getProcedureColumn(schema.getContents(), rs);
80            if (column.getPosition() > 0) {
81                // Not the return type
82                list.add(column);
83            }
84        }
85        rs.close();
86        parameters = new DbColumn[list.size()];
87        // Store the parameter in the good position [1-n]
88        for (int i = 0; i < parameters.length; i++) {
89            DbColumn column = list.get(i);
90            if (column.getPosition() > 0
91                    && column.getPosition() <= parameters.length) {
92                parameters[column.getPosition() - 1] = column;
93            }
94        }
95    }
96 
97}

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