/*
* eXist Open Source Native XML Database
* Copyright (C) 2001-06 Wolfgang M. Meier
* wolfgang@exist-db.org
* http://exist.sourceforge.net
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id$
*/
package org.exist.xquery;
import org.exist.dom.DocumentSet;
import org.exist.xquery.value.Item;
import org.exist.xquery.value.Sequence;
import org.exist.xquery.value.Type;
/**
* Abstract base class for the XQuery/XPath combining operators "union", "intersect"
* and "except".
*
* @author Wolfgang Meier (wolfgang@exist-db.org)
*/
public abstract class CombiningExpression extends AbstractExpression {
final protected PathExpr left;
final protected PathExpr right;
/**
* @param context
*/
public CombiningExpression(XQueryContext context, PathExpr left, PathExpr right) {
super(context);
this.left = left;
this.right = right;
}
/* (non-Javadoc)
* @see org.exist.xquery.Expression#analyze(org.exist.xquery.Expression)
*/
public void analyze(AnalyzeContextInfo contextInfo) throws XPathException {
contextInfo.setParent(this);
left.analyze(contextInfo);
right.analyze(contextInfo);
}
/* (non-Javadoc)
* @see org.exist.xquery.Expression#eval(org.exist.dom.DocumentSet, org.exist.xquery.value.Sequence, org.exist.xquery.value.Item)
*/
public abstract Sequence eval(Sequence contextSequence, Item contextItem)
throws XPathException;
/* (non-Javadoc)
* @see org.exist.xquery.Expression#returnsType()
*/
public int returnsType() {
return Type.NODE;
}
public void setContextDocSet(DocumentSet contextSet) {
super.setContextDocSet(contextSet);
left.setContextDocSet(contextSet);
right.setContextDocSet(contextSet);
}
/* (non-Javadoc)
* @see org.exist.xquery.Expression#resetState()
*/
public void resetState(boolean postOptimization) {
super.resetState(postOptimization);
left.resetState(postOptimization);
right.resetState(postOptimization);
}
/* (non-Javadoc)
* @see org.exist.xquery.AbstractExpression#setPrimaryAxis(int)
*/
public void setPrimaryAxis(int axis) {
left.setPrimaryAxis(axis);
right.setPrimaryAxis(axis);
}
}