Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* $Id: Manager.java,v 1.1 2016/11/21 02:49:40 ist182457 Exp $ */
- package pex;
- import java.io.Serializable;
- import pex.Interpreter;
- import java.io.*;
- import java.lang.*;
- import pex.operators.Program;
- /**
- * Manager can be considered a Interpreter handler.
- */
- public class Manager implements Serializable {
- /** Serial number for serialization. */
- private static final long serialVersionUID = 201608281332L;
- private Interpreter _i;
- private Parser _p;
- public Manager(){
- _i = new Interpreter();
- _p = new Parser();
- }
- public Interpreter getCurrentInterpreter(){
- return _i;
- }
- public Parser getParser(){
- return _p;
- }
- public void setCurrentInterpreter( Interpreter i){
- _i = i;
- }
- public Interpreter createInterpreter(){
- Interpreter j = new Interpreter();
- return j;
- }
- public Program createProgram( String programName){
- Program p = new Program( programName);
- return p;
- }
- public void saveInterpreter(){
- try {
- ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream( _i.getFileName() )));
- out.writeObject(_i);
- out.close();
- }catch(IOException j) {
- }
- }
- public File createFile( String file){
- File a = new File(file);
- return a;
- }
- public void openInterpreter( String filename ) {
- try{
- ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(new FileInputStream( filename )));
- _i = (Interpreter) in.readObject();
- in.close();
- }catch( IOException j) {
- j.printStackTrace();
- return;
- }catch( ClassNotFoundException c) {
- c.printStackTrace();
- return;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement