root / trunk / libraries / libGDBMS / src / main / java / com / hardcode / gdbms / engine / instruction / AbstractExpression.java @ 10627
History | View | Annotate | Download (982 Bytes)
1 |
package com.hardcode.gdbms.engine.instruction; |
---|---|
2 |
|
3 |
import com.hardcode.gdbms.engine.values.Value; |
4 |
|
5 |
|
6 |
/**
|
7 |
* Adaptador
|
8 |
*
|
9 |
* @author Fernando Gonz?lez Cort?s
|
10 |
*/
|
11 |
public abstract class AbstractExpression extends Adapter implements Expression { |
12 |
private boolean literal; |
13 |
private boolean literalCalculated = false; |
14 |
private Value value;
|
15 |
|
16 |
/**
|
17 |
* @see com.hardcode.gdbms.engine.instruction.Expression#evaluateExpression(long)
|
18 |
*/
|
19 |
public Value evaluateExpression(long row) |
20 |
throws EvaluationException {
|
21 |
if (!getLiteralCondition()) {
|
22 |
return evaluate(row);
|
23 |
} else {
|
24 |
if (value == null) { |
25 |
return (value = evaluate(row));
|
26 |
} else {
|
27 |
return value;
|
28 |
} |
29 |
} |
30 |
} |
31 |
|
32 |
|
33 |
public boolean getLiteralCondition() { |
34 |
if (!literalCalculated){
|
35 |
literal = isLiteral(); |
36 |
} |
37 |
|
38 |
return literal;
|
39 |
} |
40 |
|
41 |
/**
|
42 |
* @see com.hardcode.gdbms.engine.instruction.Expression#isAggregated()
|
43 |
*/
|
44 |
public boolean isAggregated() { |
45 |
return false; |
46 |
} |
47 |
|
48 |
} |