View Javadoc

1   // Join.java, created Jun 29, 2004 12:25:51 PM 2004 by jwhaley
2   // Copyright (C) 2004 John Whaley <jwhaley@alum.mit.edu>
3   // Licensed under the terms of the GNU LGPL; see COPYING for details.
4   package net.sf.bddbddb.ir.highlevel;
5   
6   import java.util.LinkedList;
7   import java.util.List;
8   import net.sf.bddbddb.Relation;
9   import net.sf.bddbddb.ir.Operation;
10  import net.sf.javabdd.BDDFactory;
11  import net.sf.javabdd.BDDFactory.BDDOp;
12  
13  /***
14   * Join
15   * 
16   * @author jwhaley
17   * @version $Id: Join.java 328 2004-10-16 02:45:30Z joewhaley $
18   */
19  public class Join extends BooleanOperation {
20      List/*<Attribute>*/ attributes;
21  
22      /***
23       * @param r0
24       * @param r1
25       * @param r2
26       */
27      public Join(Relation r0, Relation r1, Relation r2) {
28          super(r0, r1, r2);
29          this.attributes = new LinkedList();
30          this.attributes.addAll(r1.getAttributes());
31          this.attributes.retainAll(r2.getAttributes());
32      }
33  
34      /*
35       * (non-Javadoc)
36       * 
37       * @see net.sf.bddbddb.ir.BooleanOperation#getName()
38       */
39      public String getName() {
40          return "join";
41      }
42  
43      /*
44       * (non-Javadoc)
45       * 
46       * @see net.sf.bddbddb.ir.Operation#visit(net.sf.bddbddb.ir.HighLevelOperationVisitor)
47       */
48      public Object visit(HighLevelOperationVisitor i) {
49          return i.visit(this);
50      }
51  
52      /*
53       * (non-Javadoc)
54       * 
55       * @see net.sf.bddbddb.ir.highlevel.BooleanOperation#getBDDOp()
56       */
57      public BDDOp getBDDOp() {
58          return BDDFactory.and;
59      }
60  
61      public Operation copy() {
62          return new Join(r0, r1, r2);
63      }
64      
65      
66      /***
67       * @return  the attributes that are being joined
68       */
69      public List getAttributes(){ return attributes; }
70  }