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

COVERAGE SUMMARY FOR SOURCE FILE [IndexColumn.java]

nameclass, %method, %block, %line, %
IndexColumn.java100% (1/1)100% (4/4)100% (94/94)100% (18/18)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class IndexColumn100% (1/1)100% (4/4)100% (94/94)100% (18/18)
IndexColumn (): void 100% (1/1)100% (6/6)100% (2/2)
getSQL (): String 100% (1/1)100% (38/38)100% (8/8)
mapColumns (IndexColumn [], Table): void 100% (1/1)100% (23/23)100% (3/3)
wrap (Column []): IndexColumn [] 100% (1/1)100% (27/27)100% (5/5)

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.table;
7 
8import org.h2.result.SortOrder;
9 
10/**
11 * This represents a column item of an index. This is required because some
12 * indexes support descending sorted columns.
13 */
14public class IndexColumn {
15 
16    /**
17     * The column name.
18     */
19    public String columnName;
20 
21    /**
22     * The column, or null if not set.
23     */
24    public Column column;
25 
26    /**
27     * The sort type. Ascending (the default) and descending are supported;
28     * nulls can be sorted first or last.
29     */
30    public int sortType = SortOrder.ASCENDING;
31 
32    /**
33     * Get the SQL snippet for this index column.
34     *
35     * @return the SQL snippet
36     */
37    public String getSQL() {
38        StringBuilder buff = new StringBuilder(column.getSQL());
39        if ((sortType & SortOrder.DESCENDING) != 0) {
40            buff.append(" DESC");
41        }
42        if ((sortType & SortOrder.NULLS_FIRST) != 0) {
43            buff.append(" NULLS FIRST");
44        } else if ((sortType & SortOrder.NULLS_LAST) != 0) {
45            buff.append(" NULLS LAST");
46        }
47        return buff.toString();
48    }
49 
50    /**
51     * Create an array of index columns from a list of columns. The default sort
52     * type is used.
53     *
54     * @param columns the column list
55     * @return the index column array
56     */
57    public static IndexColumn[] wrap(Column[] columns) {
58        IndexColumn[] list = new IndexColumn[columns.length];
59        for (int i = 0; i < list.length; i++) {
60            list[i] = new IndexColumn();
61            list[i].column = columns[i];
62        }
63        return list;
64    }
65 
66    /**
67     * Map the columns using the column names and the specified table.
68     *
69     * @param indexColumns the column list with column names set
70     * @param table the table from where to map the column names to columns
71     */
72    public static void mapColumns(IndexColumn[] indexColumns, Table table) {
73        for (IndexColumn col : indexColumns) {
74            col.column = table.getColumn(col.columnName);
75        }
76    }
77}

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