-
Notifications
You must be signed in to change notification settings - Fork 103
Save and Recovery one AST
An AST (iDSL object) can be saved and recovery using the methods saveSerializable
and recoverySerializable
from class SerializableController. All iDSL's objects are serializable and allow Java to serialize and save the solutions easily.
line 1. String path = System.getProperty("user.dir").concat("/logs2/");
line 2. iDSL script1 = BuilderDSLTreeSingleton.getInstance().buildS1Grammar();
line 3. SerializableController.saveSerializable(script1, "dsl_test_id_.ser", path);
line 1. BuilderDSLTreeSingleton builder = BuilderDSLTreeSingleton.getInstance();
line 2. final JFileChooser fc = new JFileChooser();
line 3. fc.setCurrentDirectory(new File(System.getProperty("user.home")));
line 4. int result = fc.showOpenDialog(new JDialog());
line 5. if (result == JFileChooser.APPROVE_OPTION) {
line 6. ...File selectedFile = fc.getSelectedFile();
line 7. ...System.out.println("Selected file: " + selectedFile.getAbsolutePath());
line 8. ...iDSL ast = SerializableController.recoverySerializable(selectedFile.getName(),
line 8. ...............selectedFile.getAbsolutePath().replace(selectedFile.getName(),
line 8. ...............""));
line 9. };