View Javadoc

1   // Save.java, created Jul 3, 2004 12:54:37 PM by joewhaley
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.Collections;
7   import java.util.List;
8   import net.sf.bddbddb.Relation;
9   import net.sf.bddbddb.ir.Operation;
10  
11  /***
12   * Save
13   * 
14   * @author John Whaley
15   * @version $Id: Save.java 328 2004-10-16 02:45:30Z joewhaley $
16   */
17  public class Save extends HighLevelOperation {
18      Relation r;
19      String fileName;
20      boolean tuples;
21  
22      /***
23       * @param r
24       */
25      public Save(Relation r, String fileName, boolean tuples) {
26          super();
27          this.r = r;
28          this.fileName = fileName;
29          this.tuples = tuples;
30      }
31  
32      /*
33       * (non-Javadoc)
34       * 
35       * @see net.sf.bddbddb.ir.Operation#visit(net.sf.bddbddb.ir.HighLevelOperationVisitor)
36       */
37      public Object visit(HighLevelOperationVisitor i) {
38          return i.visit(this);
39      }
40  
41      /*
42       * (non-Javadoc)
43       * 
44       * @see java.lang.Object#toString()
45       */
46      public String toString() {
47          return "save(" + r.toString() + ")";
48      }
49  
50      /*
51       * (non-Javadoc)
52       * 
53       * @see net.sf.bddbddb.ir.Operation#getExpressionString()
54       */
55      public String getExpressionString() {
56          return toString();
57      }
58  
59      /*
60       * (non-Javadoc)
61       * 
62       * @see net.sf.bddbddb.ir.Operation#getDest()
63       */
64      public Relation getRelationDest() {
65          return null;
66      }
67  
68      /*
69       * (non-Javadoc)
70       * 
71       * @see net.sf.bddbddb.ir.Operation#getSrcs()
72       */
73      public List getSrcs() {
74          return Collections.singletonList(r);
75      }
76  
77      /***
78       * @return Returns the source relation.
79       */
80      public Relation getSrc() {
81          return r;
82      }
83  
84      public Operation copy() {
85          return new Save(r, fileName, tuples);
86      }
87  
88      /*
89       * (non-Javadoc)
90       * 
91       * @see net.sf.bddbddb.ir.Operation#replaceSrc(net.sf.bddbddb.Relation,
92       *      net.sf.bddbddb.Relation)
93       */
94      public void replaceSrc(Relation r_old, Relation r_new) {
95          if (r == r_old) r = r_new;
96      }
97  
98      /*
99       * (non-Javadoc)
100      * 
101      * @see net.sf.bddbddb.ir.Operation#setRelationDest(net.sf.bddbddb.Relation)
102      */
103     public void setRelationDest(Relation r0) {
104     }
105 
106     /***
107      * @return  the file name being saved
108      */
109     public String getFileName() {
110         return fileName;
111     }
112 
113     /***
114      * @return  whether we are saving tuples
115      */
116     public boolean isTuples() {
117         return tuples;
118     }
119 }