1 11 package org.eclipse.core.expressions; 12 13 import org.eclipse.core.runtime.Assert; 14 15 132 public class EvaluationResult { 133 134 private int fValue; 135 136 private static final int FALSE_VALUE= 0; 137 private static final int TRUE_VALUE= 1; 138 private static final int NOT_LOADED_VALUE= 2; 139 140 141 public static final EvaluationResult FALSE= new EvaluationResult(FALSE_VALUE); 142 143 public static final EvaluationResult TRUE= new EvaluationResult(TRUE_VALUE); 144 145 public static final EvaluationResult NOT_LOADED= new EvaluationResult(NOT_LOADED_VALUE); 146 147 private static final EvaluationResult[][] AND= new EvaluationResult[][] { 148 { FALSE, FALSE, FALSE }, 150 { FALSE, TRUE, NOT_LOADED }, 151 { FALSE, NOT_LOADED, NOT_LOADED }, 152 }; 153 154 private static final EvaluationResult[][] OR= new EvaluationResult[][] { 155 { FALSE, TRUE, NOT_LOADED }, 157 { TRUE, TRUE, TRUE }, 158 { NOT_LOADED, TRUE, NOT_LOADED }, 159 }; 160 161 private static final EvaluationResult[] NOT= new EvaluationResult[] { 162 TRUE, FALSE, NOT_LOADED 164 }; 165 166 169 private EvaluationResult(int value) { 170 fValue= value; 171 } 172 173 180 public EvaluationResult and(EvaluationResult other) { 181 return AND[fValue][other.fValue]; 182 } 183 184 191 public EvaluationResult or(EvaluationResult other) { 192 return OR[fValue][other.fValue]; 193 } 194 195 200 public EvaluationResult not() { 201 return NOT[fValue]; 202 } 203 204 216 public static EvaluationResult valueOf(boolean b) { 217 return b ? TRUE : FALSE; 218 } 219 220 232 public static EvaluationResult valueOf(Boolean b) { 233 return b.booleanValue() ? TRUE : FALSE; 234 } 235 236 242 public String toString() { 243 switch (fValue) { 244 case 0: 245 return "false"; case 1: 247 return "true"; case 2: 249 return "not_loaded"; } 251 Assert.isTrue(false); 252 return null; 253 } 254 } 255 | Popular Tags |