
/**
 * SaveVisitor.java
 *
 *
 * Created: Fri Oct 25 22:41:20 2002
 *
 * @author <a href="mailto:bina@cse.buffalo.edu "</a>
 * @version
 */
import java.io.*;
import javax.swing.JOptionPane;

public class SaveVisitor implements Visitor{
   public SaveVisitor (){
      
   }
   public Object operation(Object bt, Object inp) throws java.io.IOException
   {
      
   //get the database name
      String dbName =
         JOptionPane.showInputDialog 
	 ("Input database name to save into");
      try {
	 FileOutputStream fout = new FileOutputStream(dbName);
	 ObjectOutputStream out = new ObjectOutputStream(fout);
	 out.writeObject(bt);
	 out.close();
	 return bt;
      }
      catch(Exception exc){
	 System.out.println(exc);
	 return bt;
      }

   }
}// SaveVisitor

