public ResultList(Result result) { add(new FieldPathIteratorHandler.VariableMap(), result); }
/** * Converts the given object value into a result list, so it can be compared by logical operators. * * @param value The object to convert. * @return The corresponding result value. */ public static ResultList toResultList(Object value) { if (value instanceof ResultList) { return (ResultList)value; } else if (value instanceof AttributeNode.VariableValueList) { ResultList retVal = new ResultList(); for (VariableValue vv : (AttributeNode.VariableValueList)value) { retVal.add(vv.getVariables(), Result.TRUE); } return retVal; } else if (value == null || value == Result.FALSE || value == Boolean.FALSE || (Number.class.isInstance(value) && ((Number)value).doubleValue() == 0)) { return new ResultList(Result.FALSE); } else if (value == Result.INVALID) { return new ResultList(Result.INVALID); } else { return new ResultList(Result.TRUE); } }
public ResultList combineOR(ResultList other) { ResultList result = new ResultList(); // TODO: optimize for (ResultPair pair : results) { for (ResultPair otherPair : other.results) { FieldPathIteratorHandler.VariableMap varMap = (FieldPathIteratorHandler.VariableMap)pair.variables.clone(); if (combineVariables(varMap, otherPair.variables)) { result.add(varMap, combineOR(pair.result, otherPair.result)); } } } return result; }
public ResultList combineAND(ResultList other) { ResultList result = new ResultList(); // TODO: optimize for (ResultPair pair : results) { for (ResultPair otherPair : other.results) { FieldPathIteratorHandler.VariableMap varMap = (FieldPathIteratorHandler.VariableMap)pair.variables.clone(); if (combineVariables(varMap, otherPair.variables)) { result.add(varMap, combineAND(pair.result, otherPair.result)); } } } return result; }
public ResultList evaluateListAndSingle(AttributeNode.VariableValueList lhs, Object rhs) { if (rhs == null && lhs == null) { return new ResultList(Result.TRUE); } if (rhs == null || lhs == null) { return new ResultList(Result.FALSE); } ResultList retVal = new ResultList(); for (int i = 0; i < lhs.size(); i++) { Result result = evaluateBool(lhs.get(i).getValue(), rhs); retVal.add((FieldPathIteratorHandler.VariableMap)lhs.get(i).getVariables().clone(), result); } return retVal; }