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

COVERAGE SUMMARY FOR SOURCE FILE [Rownum.java]

nameclass, %method, %block, %line, %
Rownum.java100% (1/1)92%  (12/13)74%  (34/46)89%  (16/18)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Rownum100% (1/1)92%  (12/13)74%  (34/46)89%  (16/18)
updateAggregate (Session): void 0%   (0/1)0%   (0/1)0%   (0/1)
isEverything (ExpressionVisitor): boolean 100% (1/1)39%  (7/18)75%  (3/4)
Rownum (Prepared): void 100% (1/1)100% (6/6)100% (3/3)
getCost (): int 100% (1/1)100% (2/2)100% (1/1)
getDisplaySize (): int 100% (1/1)100% (2/2)100% (1/1)
getPrecision (): long 100% (1/1)100% (2/2)100% (1/1)
getSQL (): String 100% (1/1)100% (2/2)100% (1/1)
getScale (): int 100% (1/1)100% (2/2)100% (1/1)
getType (): int 100% (1/1)100% (2/2)100% (1/1)
getValue (Session): Value 100% (1/1)100% (5/5)100% (1/1)
mapColumns (ColumnResolver, int): void 100% (1/1)100% (1/1)100% (1/1)
optimize (Session): Expression 100% (1/1)100% (2/2)100% (1/1)
setEvaluatable (TableFilter, boolean): void 100% (1/1)100% (1/1)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.expression;
7 
8import org.h2.command.Prepared;
9import org.h2.engine.Session;
10import org.h2.message.DbException;
11import org.h2.table.ColumnResolver;
12import org.h2.table.TableFilter;
13import org.h2.value.Value;
14import org.h2.value.ValueInt;
15 
16/**
17 * Represents the ROWNUM function.
18 */
19public class Rownum extends Expression {
20 
21    private final Prepared prepared;
22 
23    public Rownum(Prepared prepared) {
24        this.prepared = prepared;
25    }
26 
27    @Override
28    public Value getValue(Session session) {
29        return ValueInt.get(prepared.getCurrentRowNumber());
30    }
31 
32    @Override
33    public int getType() {
34        return Value.INT;
35    }
36 
37    @Override
38    public void mapColumns(ColumnResolver resolver, int level) {
39        // nothing to do
40    }
41 
42    @Override
43    public Expression optimize(Session session) {
44        return this;
45    }
46 
47    @Override
48    public void setEvaluatable(TableFilter tableFilter, boolean b) {
49        // nothing to do
50    }
51 
52    @Override
53    public int getScale() {
54        return 0;
55    }
56 
57    @Override
58    public long getPrecision() {
59        return ValueInt.PRECISION;
60    }
61 
62    @Override
63    public int getDisplaySize() {
64        return ValueInt.DISPLAY_SIZE;
65    }
66 
67    @Override
68    public String getSQL() {
69        return "ROWNUM()";
70    }
71 
72    @Override
73    public void updateAggregate(Session session) {
74        // nothing to do
75    }
76 
77    @Override
78    public boolean isEverything(ExpressionVisitor visitor) {
79        switch(visitor.getType()) {
80        case ExpressionVisitor.QUERY_COMPARABLE:
81        case ExpressionVisitor.OPTIMIZABLE_MIN_MAX_COUNT_ALL:
82        case ExpressionVisitor.DETERMINISTIC:
83        case ExpressionVisitor.INDEPENDENT:
84            return false;
85        case ExpressionVisitor.EVALUATABLE:
86        case ExpressionVisitor.READONLY:
87        case ExpressionVisitor.NOT_FROM_RESOLVER:
88        case ExpressionVisitor.GET_DEPENDENCIES:
89        case ExpressionVisitor.SET_MAX_DATA_MODIFICATION_ID:
90        case ExpressionVisitor.GET_COLUMNS:
91            // if everything else is the same, the rownum is the same
92            return true;
93        default:
94            throw DbException.throwInternalError("type="+visitor.getType());
95        }
96    }
97 
98    @Override
99    public int getCost() {
100        return 0;
101    }
102 
103}

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