KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > shark > api > common > ExpressionBuilder


1 package org.enhydra.shark.api.common;
2
3 /**
4  * ExpressionBuilder interface helps building expressions for any
5  * BaseIterator implementation.
6  *
7  * Expirience has learned us that it's not that easy to build any
8  * usefull expression to be used in xxIterators. Since Shark supports
9  * BeanShell and JavaScript, making expressions starts to be even more
10  * complicated once you start to use string literals. Also, reading
11  * and debugging of such expression might turn into very tedious task.
12  * On the other side OMG (or at least the way we read it) explicitely
13  * says set_expression method takes String as parameter, and there's
14  * no escape.
15  * ExpressionBuilder and it's extending interfaces/classes serves the
16  * intention to ease this task, although there is another benefit -
17  * it allows us to prepare such expressions xxIterator can execute
18  * directly against database, thus improving the performance.
19  *
20  * @author Vladimir Puskas
21  * @version 0.2
22  */

23 public interface ExpressionBuilder {
24    
25    public static final boolean ORDER_ASCENDING = true;
26    public static final boolean ORDER_DESCENDING = false;
27    
28    /**
29     * Comment for <code>AND_OPERATOR</code>
30     */

31    public static final int AND_OPERATOR = 1;
32
33    /**
34     * Comment for <code>OR_OPERATOR</code>
35     */

36    public static final int OR_OPERATOR = 2;
37
38    /**
39     * Comment for <code>NOT_OPERATOR</code>
40     */

41    public static final int NOT_OPERATOR = 4;
42
43    /**
44     * @return true if expression can be performed on DB entirely
45     */

46    public boolean isComplete();
47
48    /**
49     * @return sql interpretation of expression prepared to fit into
50     * WHERE clause
51     */

52    public String JavaDoc toSQL();
53
54    /**
55     * @return expression in target script language
56     */

57    public String JavaDoc toScript();
58    
59    /**
60     * @return expression that should be set to appropriate iterator.
61     */

62    public String JavaDoc toExpression();
63    
64 }
65
Popular Tags