KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mondrian > rolap > StarPredicate


1 /*
2 // $Id: //open/mondrian/src/main/mondrian/rolap/StarPredicate.java#1 $
3 // This software is subject to the terms of the Common Public License
4 // Agreement, available at the following URL:
5 // http://www.opensource.org/licenses/cpl.html.
6 // Copyright (C) 2007-2007 Julian Hyde
7 // All Rights Reserved.
8 // You must accept the terms of that agreement to use this software.
9 */

10 package mondrian.rolap;
11
12 import java.util.List JavaDoc;
13
14 /**
15  * Condition which constrains a set of values of a single
16  * {@link mondrian.rolap.RolapStar.Column} or a set of columns.
17  *
18  * <p>For example, the predicate
19  * <code>Range([Time].[1997].[Q3], [Time].[1998].[Q2])</code>
20  * constrains the <code>year</code> and <code>quarter</code> columns:
21  *
22  * <blockquote><code>
23  * &nbsp;&nbsp;((year = 1997 and quarter >= 'Q3')<br/>
24  * &nbsp;&nbsp;&nbsp;&nbsp;or (year > 1997))<br/>
25  * and ((year = 1998 and quarter <= 'Q2')<br/>
26  * &nbsp;&nbsp;&nbsp;&nbsp;or (year < 1998))</code></blockquote>
27  *
28  * @author jhyde
29  * @version $Id: //open/mondrian/src/main/mondrian/rolap/StarPredicate.java#1 $
30  * @since Jan 15, 2007
31  */

32 public interface StarPredicate {
33     /**
34      * Returns a list of constrained columns.
35      *
36      * @return List of constrained columns
37      */

38     public List JavaDoc<RolapStar.Column> getConstrainedColumnList();
39
40     /**
41      * Appends a description of this predicate to a <code>StringBuilder</code>.
42      * For example:<ul>
43      * <li>=any</li>
44      * <li>=5</li>
45      * <li>in (2, 4, 6)</li>
46      * </ul>
47      *
48      * @param buf Builder to append to
49      */

50     public abstract void describe(StringBuilder JavaDoc buf);
51
52     /**
53      * Evaluates a constraint against a list of values.
54      *
55      * <p>If one of the values is {@link #WILDCARD}, returns true if constraint is
56      * true for all possible values of that column.
57      *
58      * @param valueList List of values, one for each constrained column
59      * @return Whether constraint holds for given set of values
60      */

61     public boolean evaluate(List JavaDoc<Object JavaDoc> valueList);
62
63     /**
64      * Returns whether this Predicate has the same constraining effect as the
65      * other constraint. This is weaker than {@link #equals(Object)} -- it is
66      * possible for two different members to constrain the same column in the
67      * same way.
68      */

69     boolean equalConstraint(StarPredicate that);
70
71     /**
72      * Returns the logical inverse of this Predicate. The result is a Predicate
73      * which holds whenever this predicate holds but the other does not.
74      *
75      * @pre predicate != null
76      */

77     StarPredicate minus(StarPredicate predicate);
78
79     /**
80      * Wildcard value for {@link #evaluate(java.util.List)}.
81      */

82     Object JavaDoc WILDCARD = new Object JavaDoc();
83 }
84
85 // End StarPredicate.java
86
Popular Tags