svn-gvsig-desktop / trunk / libraries / libGDBMS / src / com / hardcode / gdbms / engine / instruction / OrExprAdapter.java @ 466
History | View | Annotate | Download (2.27 KB)
1 |
/* Generated by Together */
|
---|---|
2 |
package com.hardcode.gdbms.engine.instruction; |
3 |
|
4 |
import com.hardcode.gdbms.engine.data.DriverException; |
5 |
import com.hardcode.gdbms.engine.values.Value; |
6 |
|
7 |
|
8 |
/**
|
9 |
* Adaptador sobre las expresiones or del arbol sint?ctico
|
10 |
*
|
11 |
* @author Fernando Gonz?lez Cort?s
|
12 |
*/
|
13 |
public class OrExprAdapter extends AbstractExpression implements Expression { |
14 |
/**
|
15 |
* Evalua expresi?n invocando el m?todo adecuado en funci?n del tipo de
|
16 |
* expresion (suma, producto, ...) de los objetos Value de la expresion,
|
17 |
* de las subexpresiones y de los objetos Field
|
18 |
*
|
19 |
* @param row Fila en la que se eval?a la expresi?n, en este caso no es
|
20 |
* necesario, pero las subexpresiones sobre las que se opera pueden
|
21 |
* ser campos de una tabla, en cuyo caso si es necesario
|
22 |
*
|
23 |
* @return Objeto Value resultado de la operaci?n propia de la expresi?n
|
24 |
* representada por el nodo sobre el cual ?ste objeto es adaptador
|
25 |
*
|
26 |
* @throws SemanticException Si se produce un error sem?ntico
|
27 |
* @throws DriverException Si se produce un error de I/O
|
28 |
*/
|
29 |
public Value evaluate(long row) throws SemanticException, DriverException { |
30 |
Value ret = null;
|
31 |
|
32 |
Adapter[] expr = (Adapter[]) getChilds(); |
33 |
|
34 |
if (expr.length > 0) { |
35 |
ret = ((Expression) expr[0]).evaluateExpression(row); |
36 |
|
37 |
for (int i = 1; i < expr.length; i++) { |
38 |
ret = ret.or(((Expression) expr[i]).evaluateExpression(row));
|
39 |
} |
40 |
} |
41 |
|
42 |
return ret;
|
43 |
} |
44 |
|
45 |
/**
|
46 |
* @see com.hardcode.gdbms.engine.instruction.Expression#getFieldName()
|
47 |
*/
|
48 |
public String getFieldName() { |
49 |
return null; |
50 |
} |
51 |
|
52 |
/**
|
53 |
* @see com.hardcode.gdbms.engine.instruction.Expression#isLiteral()
|
54 |
*/
|
55 |
public boolean isLiteral() { |
56 |
return literal;
|
57 |
} |
58 |
|
59 |
/**
|
60 |
* @see com.hardcode.gdbms.engine.instruction.Expression#simplify()
|
61 |
*/
|
62 |
public void simplify() { |
63 |
Adapter[] childs = getChilds();
|
64 |
|
65 |
if (childs.length == 1) { |
66 |
getParent().replaceChild(this, childs[0]); |
67 |
} |
68 |
} |
69 |
|
70 |
/**
|
71 |
* @see com.hardcode.gdbms.engine.instruction.Expression#calculateLiteralCondition()
|
72 |
*/
|
73 |
public void calculateLiteralCondition() { |
74 |
literal = Utilities.checkExpressions(getChilds());
|
75 |
} |
76 |
} |