01: /*
02: * Copyright Aduna (http://www.aduna-software.com/) (c) 1997-2006.
03: *
04: * Licensed under the Aduna BSD-style license.
05: */
06: package org.openrdf.query.algebra;
07:
08: import java.util.LinkedHashSet;
09: import java.util.Set;
10:
11: /**
12: * The INTERSECT set operator, which returns the intersection of the result sets
13: * of two tuple expressions.
14: */
15: public class Intersection extends BinaryTupleOperator {
16:
17: /*--------------*
18: * Constructors *
19: *--------------*/
20:
21: public Intersection() {
22: }
23:
24: /**
25: * Creates a new intersection operator that operates on the two specified
26: * arguments.
27: *
28: * @param leftArg
29: * The left argument of the intersection operator.
30: * @param rightArg
31: * The right argument of the intersection operator.
32: */
33: public Intersection(TupleExpr leftArg, TupleExpr rightArg) {
34: super (leftArg, rightArg);
35: }
36:
37: /*---------*
38: * Methods *
39: *---------*/
40:
41: public Set<String> getBindingNames() {
42: Set<String> bindingNames = new LinkedHashSet<String>(16);
43: bindingNames.addAll(getLeftArg().getBindingNames());
44: bindingNames.retainAll(getRightArg().getBindingNames());
45: return bindingNames;
46: }
47:
48: public <X extends Exception> void visit(QueryModelVisitor<X> visitor)
49: throws X {
50: visitor.meet(this );
51: }
52:
53: @Override
54: public Intersection clone() {
55: return (Intersection) super.clone();
56: }
57: }
|