1   package gate.util.persistence;
2   
3   import java.io.Serializable;
4   
5   import gate.*;
6   import gate.creole.*;
7   import gate.persist.PersistenceException;
8   
9   /**
10   * Persistent holder for {@link gate.creole.AnalyserRunningStrategy}.
11   */
12  
13  public class AnalyserRunningStrategyPersistence implements Persistence {
14  
15    public void extractDataFromSource(Object source) throws PersistenceException {
16      if(! (source instanceof AnalyserRunningStrategy))
17        throw new UnsupportedOperationException(
18                  getClass().getName() + " can only be used for " +
19                  AnalyserRunningStrategy.class.getName() +
20                  " objects!\n" + source.getClass().getName() +
21                  " is not a " + AnalyserRunningStrategy.class.getName());
22      AnalyserRunningStrategy strategy = (AnalyserRunningStrategy)source;
23      this.pr = PersistenceManager.getPersistentRepresentation(strategy.getPR());
24      this.runMode = strategy.getRunMode();
25      this.featureName = strategy.getFeatureName();
26      this.featureValue = strategy.getFeatureValue();
27    }
28  
29  
30    public Object createObject() throws PersistenceException,
31                                        ResourceInstantiationException {
32      return new AnalyserRunningStrategy((LanguageAnalyser)
33                                         PersistenceManager.
34                                         getTransientRepresentation(pr),
35                                         runMode, featureName, featureValue);
36    }
37  
38    protected int runMode;
39  
40    protected String featureName;
41  
42    protected String featureValue;
43  
44    protected Serializable pr;
45    /**
46     * Serialisation ID
47     */
48    static final long serialVersionUID = -8288186597177634360L;
49  }