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

COVERAGE SUMMARY FOR SOURCE FILE [SequenceValue.java]

nameclass, %method, %block, %line, %
SequenceValue.java100% (1/1)85%  (11/13)70%  (54/77)75%  (18/24)

COVERAGE BREAKDOWN BY CLASS AND METHOD

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

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