mondrian.rolap.agg
Class LiteralStarPredicate

java.lang.Object
  extended by mondrian.rolap.agg.AbstractColumnPredicate
      extended by mondrian.rolap.agg.LiteralStarPredicate
All Implemented Interfaces:
StarColumnPredicate, StarPredicate

public class LiteralStarPredicate
extends AbstractColumnPredicate

A constraint which always returns true or false.

Since:
Nov 2, 2006
Author:
jhyde
 

Nested Class Summary
 
Nested classes/interfaces inherited from class mondrian.rolap.agg.AbstractColumnPredicate
AbstractColumnPredicate.Factory
 
Nested classes/interfaces inherited from interface mondrian.rolap.StarColumnPredicate
StarColumnPredicate.Overlap
 
Field Summary
static LiteralStarPredicate FALSE
           
static LiteralStarPredicate TRUE
           
 
Fields inherited from class mondrian.rolap.agg.AbstractColumnPredicate
constrainedColumn
 
Fields inherited from interface mondrian.rolap.StarPredicate
WILDCARD
 
Constructor Summary
LiteralStarPredicate(RolapStar.Column column, boolean value)
          Creates a LiteralStarPredicate.
 
Method Summary
 StarColumnPredicate cloneWithColumn(RolapStar.Column column)
          This method is required because unfortunately some ColumnPredicate objects are created without a column.
 void describe(StringBuilder buf)
          Appends a description of this predicate to a StringBuilder.
 boolean equalConstraint(StarPredicate that)
          Returns whether this Predicate has the same constraining effect as the other constraint.
 boolean equals(Object obj)
           
 boolean evaluate(List<Object> valueList)
          Evaluates a constraint against a list of values.
 boolean evaluate(Object value)
          Returns whether this constraint would return true for a given value.
 boolean getValue()
           
 int hashCode()
           
 StarColumnPredicate.Overlap intersect(StarColumnPredicate predicate)
          Applies this predicate to a predicate from the axis of a segment, and tests for overlap.
 boolean mightIntersect(StarPredicate other)
          Returns whether this predicate might intersect another predicate.
 StarColumnPredicate minus(StarPredicate predicate)
          Returns the logical inverse of this Predicate.
 void toSql(SqlQuery sqlQuery, StringBuilder buf)
           
 String toString()
           
 void values(Collection<Object> collection)
          Adds the values in this constraint to a collection.
 
Methods inherited from class mondrian.rolap.agg.AbstractColumnPredicate
and, cloneListWithColumn, getConstrainedColumn, getConstrainedColumnBitKey, getConstrainedColumnList, or, orColumn
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

TRUE

public static final LiteralStarPredicate TRUE

FALSE

public static final LiteralStarPredicate FALSE
Constructor Detail

LiteralStarPredicate

public LiteralStarPredicate(RolapStar.Column column,
                            boolean value)
Creates a LiteralStarPredicate.

Parameters:
column - Constrained column
value - Truth value
Method Detail

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

evaluate

public boolean evaluate(List<Object> valueList)
Description copied from interface: StarPredicate
Evaluates a constraint against a list of values.

If one of the values is StarPredicate.WILDCARD, returns true if constraint is true for all possible values of that column.

Specified by:
evaluate in interface StarPredicate
Overrides:
evaluate in class AbstractColumnPredicate
Parameters:
valueList - List of values, one for each constrained column
Returns:
Whether constraint holds for given set of values

equalConstraint

public boolean equalConstraint(StarPredicate that)
Description copied from interface: StarPredicate
Returns whether this Predicate has the same constraining effect as the other constraint. This is weaker than Object.equals(Object): it is possible for two different members to constrain the same column in the same way.

Specified by:
equalConstraint in interface StarPredicate
Overrides:
equalConstraint in class AbstractColumnPredicate
Parameters:
that - Other predicate
Returns:
whether the other predicate is equivalent

toString

public String toString()
Overrides:
toString in class AbstractColumnPredicate

values

public void values(Collection<Object> collection)
Description copied from interface: StarColumnPredicate
Adds the values in this constraint to a collection.

Parameters:
collection - Collection to add values to

evaluate

public boolean evaluate(Object value)
Description copied from interface: StarColumnPredicate
Returns whether this constraint would return true for a given value.

Parameters:
value - Value
Returns:
Whether predicate is true

describe

public void describe(StringBuilder buf)
Description copied from interface: StarPredicate
Appends a description of this predicate to a StringBuilder. For example:

Parameters:
buf - Builder to append to

intersect

public StarColumnPredicate.Overlap intersect(StarColumnPredicate predicate)
Description copied from interface: StarColumnPredicate
Applies this predicate to a predicate from the axis of a segment, and tests for overlap. The result might be that there is no overlap, full overlap (so the constraint can be removed), or partial overlap (so the constraint will need to be replaced with a stronger constraint, say 'x > 10' is replaced with 'x > 20').

Parameters:
predicate - Predicate
Returns:
description of overlap between predicates, if any

mightIntersect

public boolean mightIntersect(StarPredicate other)
Description copied from interface: StarColumnPredicate
Returns whether this predicate might intersect another predicate. That is, whether there might be a value which holds true for both constraints.

Parameters:
other - Other constraint
Returns:
Whether constraints intersect

minus

public StarColumnPredicate minus(StarPredicate predicate)
Description copied from interface: StarPredicate
Returns the logical inverse of this Predicate. The result is a Predicate which holds whenever this predicate holds but the other does not.

Parameters:
predicate - Predicate
Returns:
Combined predicate

cloneWithColumn

public StarColumnPredicate cloneWithColumn(RolapStar.Column column)
Description copied from interface: StarColumnPredicate
This method is required because unfortunately some ColumnPredicate objects are created without a column.

We call this method to provide a fake column, then call StarPredicate.toSql(mondrian.rolap.sql.SqlQuery, StringBuilder).

todo: remove this method when bug 1767776 and bug 1767779 are fixed.


getValue

public boolean getValue()

toSql

public void toSql(SqlQuery sqlQuery,
                  StringBuilder buf)
Specified by:
toSql in interface StarPredicate
Overrides:
toSql in class AbstractColumnPredicate

SourceForge.net_Logo