1 10 package mondrian.rolap.agg; 11 12 import mondrian.rolap.StarPredicate; 13 import mondrian.rolap.RolapStar; 14 import mondrian.rolap.StarColumnPredicate; 15 16 import java.util.Collection ; 17 import java.util.List ; 18 19 26 public class LiteralStarPredicate extends AbstractColumnPredicate { 27 private final boolean value; 28 29 public static final LiteralStarPredicate TRUE = 30 new LiteralStarPredicate(null, true); 31 public static final LiteralStarPredicate FALSE = 32 new LiteralStarPredicate(null, false); 33 34 40 public LiteralStarPredicate(RolapStar.Column column, boolean value) { 41 super(column); 42 this.value = value; 43 } 44 45 46 public int hashCode() { 47 return value ? 2 : 1; 48 } 49 50 public boolean equals(Object obj) { 51 if (obj instanceof LiteralStarPredicate) { 52 LiteralStarPredicate that = 53 (LiteralStarPredicate) obj; 54 return this.value == that.value; 55 } else { 56 return false; 57 } 58 } 59 60 public boolean evaluate(List <Object > valueList) { 61 assert valueList.isEmpty(); 62 return value; 63 } 64 65 public boolean equalConstraint(StarPredicate that) { 66 throw new UnsupportedOperationException (); 67 } 68 69 public String toString() { 70 return Boolean.toString(value); 71 } 72 73 public void values(Collection collection) { 74 } 75 76 public boolean evaluate(Object value) { 77 return this.value; 78 } 79 80 public void describe(StringBuilder buf) { 81 buf.append("=any"); 82 } 83 84 public Overlap intersect( 85 StarColumnPredicate predicate) { 86 return new Overlap(value, null, 0f); 87 } 88 89 public boolean mightIntersect(StarPredicate other) { 90 if (!value) { 93 return false; 94 } else if (other instanceof LiteralStarPredicate) { 95 return ((LiteralStarPredicate) other).value; 96 } else { 97 return true; 98 } 99 } 100 101 public StarColumnPredicate minus(StarPredicate predicate) { 102 assert predicate != null; 103 if (value) { 104 return new MinusStarPredicate(this, (StarColumnPredicate) predicate); 107 } else { 108 return this; 110 } 111 } 112 113 public boolean getValue() { 114 return value; 115 } 116 } 117 118 | Popular Tags |