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

COVERAGE SUMMARY FOR SOURCE FILE [DbTableOrView.java]

nameclass, %method, %block, %line, %
DbTableOrView.java100% (1/1)86%  (6/7)96%  (78/81)95%  (21/22)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class DbTableOrView100% (1/1)86%  (6/7)96%  (78/81)95%  (21/22)
getSchema (): DbSchema 0%   (0/1)0%   (0/3)0%   (0/1)
DbTableOrView (DbSchema, ResultSet): void 100% (1/1)100% (27/27)100% (7/7)
getColumns (): DbColumn [] 100% (1/1)100% (3/3)100% (1/1)
getName (): String 100% (1/1)100% (3/3)100% (1/1)
getQuotedName (): String 100% (1/1)100% (3/3)100% (1/1)
isView (): boolean 100% (1/1)100% (3/3)100% (1/1)
readColumns (DatabaseMetaData): void 100% (1/1)100% (39/39)100% (10/10)

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 java.sql.DatabaseMetaData;
9import java.sql.ResultSet;
10import java.sql.SQLException;
11import java.util.ArrayList;
12import org.h2.util.New;
13 
14/**
15 * Contains meta data information about a table or a view.
16 * This class is used by the H2 Console.
17 */
18public class DbTableOrView {
19 
20    /**
21     * The schema this table belongs to.
22     */
23    private final DbSchema schema;
24 
25    /**
26     * The table name.
27     */
28    private final String name;
29 
30    /**
31     * The quoted table name.
32     */
33    private final String quotedName;
34 
35    /**
36     * True if this represents a view.
37     */
38    private final boolean isView;
39 
40    /**
41     * The column list.
42     */
43    private DbColumn[] columns;
44 
45    public DbTableOrView(DbSchema schema, ResultSet rs) throws SQLException {
46        this.schema = schema;
47        name = rs.getString("TABLE_NAME");
48        String type = rs.getString("TABLE_TYPE");
49        isView = "VIEW".equals(type);
50        quotedName = schema.getContents().quoteIdentifier(name);
51    }
52 
53    /**
54     * @return The schema this table belongs to.
55     */
56    public DbSchema getSchema() {
57        return schema;
58    }
59 
60    /**
61     * @return The column list.
62     */
63    public DbColumn[] getColumns() {
64        return columns;
65    }
66 
67    /**
68     * @return The table name.
69     */
70    public String getName() {
71        return name;
72    }
73 
74    /**
75     * @return True if this represents a view.
76     */
77    public boolean isView() {
78        return isView;
79    }
80 
81    /**
82     * @return The quoted table name.
83     */
84    public String getQuotedName() {
85        return quotedName;
86    }
87 
88    /**
89     * Read the column for this table from the database meta data.
90     *
91     * @param meta the database meta data
92     */
93    public void readColumns(DatabaseMetaData meta) throws SQLException {
94        ResultSet rs = meta.getColumns(null, schema.name, name, null);
95        ArrayList<DbColumn> list = New.arrayList();
96        while (rs.next()) {
97            DbColumn column = DbColumn.getColumn(schema.getContents(), rs);
98            list.add(column);
99        }
100        rs.close();
101        columns = new DbColumn[list.size()];
102        list.toArray(columns);
103    }
104 
105}

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