/**
* @see nexj.core.persistence.Query.OperatorFactory#create(nexj.core.scripting.Pair, nexj.core.persistence.Query, Object, byte)
*/
public Operator create(Pair args, Query query, Object key, byte nOutput)
{
ComparisonOperator op = create(query);
if (args == null || args.getTail() == null)
{
throw new InvalidQueryException("err.persistence.comparisonOperatorArgCount",
new Object[]{op.getSymbol()});
}
if (!op.setLeft(query.createOperator(key, args.getHead(), nOutput)))
{
return null;
}
args = args.getNext();
MultiArgOperator logical = null;
for (;;)
{
if (!op.setRight(query.createOperator(key, args.getHead(), nOutput)))
{
return null;
}
op.initialize();
if (args.getTail() == null)
{
break;
}
if (logical == null)
{
logical = createLogical(query);
logical.addOperand(op);
}
ComparisonOperator right = create(query);
if (!right.setLeft(query.createOperator(key, args.getHead(), nOutput)))
{
return null;
}
logical.addOperand(right);