Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. /* $Id: Manager.java,v 1.1 2016/11/21 02:49:40 ist182457 Exp $ */
  2. package pex;
  3.  
  4. import java.io.Serializable;
  5. import pex.Interpreter;
  6. import java.io.*;
  7. import java.lang.*;
  8.  
  9. import pex.operators.Program;
  10.  
  11. /**
  12. * Manager can be considered a Interpreter handler.
  13. */
  14. public class Manager implements Serializable {
  15.  
  16. /** Serial number for serialization. */
  17. private static final long serialVersionUID = 201608281332L;
  18.  
  19. private Interpreter _i;
  20.  
  21. private Parser _p;
  22.  
  23.  
  24. public Manager(){
  25. _i = new Interpreter();
  26. _p = new Parser();
  27.  
  28. }
  29.  
  30. public Interpreter getCurrentInterpreter(){
  31. return _i;
  32. }
  33.  
  34. public Parser getParser(){
  35. return _p;
  36. }
  37.  
  38. public void setCurrentInterpreter( Interpreter i){
  39. _i = i;
  40. }
  41.  
  42. public Interpreter createInterpreter(){
  43. Interpreter j = new Interpreter();
  44. return j;
  45. }
  46.  
  47. public Program createProgram( String programName){
  48. Program p = new Program( programName);
  49. return p;
  50. }
  51.  
  52. public void saveInterpreter(){
  53. try {
  54. ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream( _i.getFileName() )));
  55.  
  56. out.writeObject(_i);
  57. out.close();
  58.  
  59. }catch(IOException j) {
  60. }
  61. }
  62.  
  63. public File createFile( String file){
  64. File a = new File(file);
  65. return a;
  66. }
  67.  
  68. public void openInterpreter( String filename ) {
  69. try{
  70. ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(new FileInputStream( filename )));
  71.  
  72. _i = (Interpreter) in.readObject();
  73.  
  74.  
  75. in.close();
  76.  
  77. }catch( IOException j) {
  78. j.printStackTrace();
  79. return;
  80. }catch( ClassNotFoundException c) {
  81. c.printStackTrace();
  82. return;
  83. }
  84.  
  85.  
  86. }
  87.  
  88.  
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement