001 /*
002 * Cumulus4j - Securing your data in the cloud - http://cumulus4j.org
003 * Copyright (C) 2011 NightLabs Consulting GmbH
004 *
005 * This program is free software: you can redistribute it and/or modify
006 * it under the terms of the GNU Affero General Public License as
007 * published by the Free Software Foundation, either version 3 of the
008 * License, or (at your option) any later version.
009 *
010 * This program is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
013 * GNU Affero General Public License for more details.
014 *
015 * You should have received a copy of the GNU Affero General Public License
016 * along with this program. If not, see <http://www.gnu.org/licenses/>.
017 */
018 package org.cumulus4j.store.query.method;
019
020 import java.util.Set;
021
022 import org.cumulus4j.store.model.DataEntry;
023 import org.cumulus4j.store.query.QueryEvaluator;
024 import org.cumulus4j.store.query.eval.InvokeExpressionEvaluator;
025 import org.cumulus4j.store.query.eval.ResultDescriptor;
026 import org.datanucleus.query.expression.Expression;
027
028 /**
029 * Interface for the evaluator for a method.
030 */
031 public interface MethodEvaluator
032 {
033 /**
034 * Method to evaluate the provided method invocation invoking on a PrimaryExpression.
035 * @param queryEval Query evaluator
036 * @param invokeExprEval Evaluator for the InvokeExpression that this is processing
037 * @param invokedExpr Expression on which we are invoking the method
038 * @param resultDesc Result descriptor
039 * @return those {@link DataEntry#getDataEntryID() dataEntryID}s that match the query
040 * criteria for the specified <code>resultSymbol</code> or <code>null</code>, if the symbol is not supported
041 */
042 Set<Long> evaluate(QueryEvaluator queryEval, InvokeExpressionEvaluator invokeExprEval, Expression invokedExpr,
043 ResultDescriptor resultDesc);
044
045 /**
046 * Whether this evaluator requires a comparison argument to perform its evaluation.
047 * @return True if needing the comparison argument
048 */
049 boolean requiresComparisonArgument();
050
051 /**
052 * Method to set any argument to be compared with (when evaluating method invocation and comparison).
053 * Should be set prior to call of evaluate(...).
054 * @param obj The compared argument
055 */
056 void setCompareToArgument(Object obj);
057 }