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