1
14 package gate.util.persistence;
15
16 import gate.DataStore;
17 import gate.Factory;
18 import gate.creole.ResourceInstantiationException;
19 import gate.persist.PersistenceException;
20
21 public class DSPersistence implements Persistence{
22
23
24
28 public void extractDataFromSource(Object source)throws PersistenceException{
29 if(! (source instanceof DataStore)){
31 throw new UnsupportedOperationException(
32 getClass().getName() + " can only be used for " +
33 DataStore.class.getName() +
34 " objects!\n" + source.getClass().getName() +
35 " is not a " + DataStore.class.getName());
36 }
37
38 DataStore ds = (DataStore)source;
39 className = ds.getClass().getName();
40 storageUrlString = ds.getStorageUrl();
41 }
42
43
47 public Object createObject()throws PersistenceException,
48 ResourceInstantiationException{
49 return Factory.openDataStore(className, storageUrlString);
50 }
51
52 protected String className;
53 protected String storageUrlString;
54 static final long serialVersionUID = 5952924943977701708L;
55 }
56