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