Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/bdgp/apps/dagedit/dataadapter/GOSerialAdapter.java


1   package org.bdgp.apps.dagedit.dataadapter;
2   
3   import java.util.*;
4   import org.bdgp.apps.dagedit.datamodel.*;
5   import org.bdgp.apps.dagedit.gui.*;
6   import org.bdgp.io.*;
7   import java.io.*;
8   import org.bdgp.util.*;
9   
10  public class GOSerialAdapter extends AbstractDataAdapter implements DEDataAdapterI, SingleFileAdapterI {
11  
12      protected File path;
13  
14      public void init() {
15      }
16  
17      public DataAdapterUI getUI(IOOperation op) {
18    SingleFileGUI gui = new SingleFileGUI(op);
19    final Controller controller = Controller.getController();
20    gui.setDefaultBrowsePath(controller.getAutosavePath().toString());
21    gui.setFont(controller.getDefaultFont());
22    return gui;
23      }
24      
25      public void init(Object params) throws DataAdapterException {
26      }
27  
28      public String getName() {
29    return "GO Serial File Adapter";
30      }
31  
32      public String getType() {
33    return "GO Serial File";
34      }
35  
36      public IOOperation [] getSupportedOperations() {
37    IOOperation [] supported = {
38        DEDataAdapterI.READ_TERMS,
39        DEDataAdapterI.WRITE_TERMS
40    };
41    return supported;
42      }
43  
44      public void setPath(File path) {
45    this.path = path;
46      }
47  
48      public Properties getStateInformation() {
49    Properties out = new Properties();
50    out.setProperty("filename", path.toString());
51    return out;
52      }
53  
54      public void setStateInformation(Properties props) {
55    path = new File(props.getProperty("filename"));
56      }
57  
58      public DEEditHistory getRoot() throws DataAdapterException {
59    try {
60        ProgressableFileInputStream pfis = new ProgressableFileInputStream(path);
61        pfis.addProgressListener(new ProgressListener() {
62          public void progressMade(ProgressEvent e) {
63        GOSerialAdapter.this.fireProgressEvent(e);
64          }
65      });
66        ObjectInputStream stream = new ObjectInputStream(new BufferedInputStream(pfis));
67        DEEditHistory history = (DEEditHistory) stream.readObject();
68        return history;
69    } catch (Exception e) {
70        throw new DataAdapterException(e, "Load error");
71    }  
72      }
73  
74      public DEEditHistory write(DEEditHistory history) throws DataAdapterException {
75    try {
76        ObjectOutputStream stream = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(path)));
77        stream.writeObject(history);
78        stream.close();
79        return history;
80    } catch (Exception e) {
81        throw new DataAdapterException(e, "Write error");
82    }
83      }
84  
85      public String [] getIDs(Term root, Term term, String prefix, int length, int count) throws DataAdapterException {
86    throw new DataAdapterException("Not supported");
87      }
88  
89      public String [] getIDs(Term root, Term term, String prefix, int min, int max, int length, int count) throws DataAdapterException {
90    throw new DataAdapterException("Not supported");
91      }
92  
93      public Vector getHistories() throws DataAdapterException {
94    throw new DataAdapterException("Not supported");
95      }
96  
97      public Vector getRelationshipTypes() throws DataAdapterException {
98    return new Vector();
99      }
100 
101     public Vector getTermCategories() throws DataAdapterException {
102   return new Vector();
103     }
104 
105     public void delegateToIDAdapter(DEDataAdapterI adapter) {
106     }
107 }
108