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 extends AbstractPersistence {
15 
16   @Override
17   public void extractDataFromSource(Object sourcethrows PersistenceException {
18     if((source instanceof AnalyserRunningStrategy))
19       throw new UnsupportedOperationException(
20                 getClass().getName() " can only be used for " +
21                 AnalyserRunningStrategy.class.getName() +
22                 " objects!\n" + source.getClass().getName() +
23                 " is not a " + AnalyserRunningStrategy.class.getName());
24     AnalyserRunningStrategy strategy = (AnalyserRunningStrategy)source;
25     this.pr = PersistenceManager.getPersistentRepresentation(strategy.getPR());
26     this.runMode = strategy.getRunMode();
27     this.featureName = strategy.getFeatureName();
28     this.featureValue = strategy.getFeatureValue();
29   }
30 
31 
32   @Override
33   public Object createObject() throws PersistenceException,
34                                       ResourceInstantiationException {
35     return new AnalyserRunningStrategy(
36             (LanguageAnalyser)PersistenceManager.getTransientRepresentation(
37               pr,containingControllerName,initParamOverrides),
38                                        runMode, featureName, featureValue);
39   }
40 
41   protected int runMode;
42 
43   protected String featureName;
44 
45   protected String featureValue;
46 
47   protected Serializable pr;
48   /**
49    * Serialisation ID
50    */
51   static final long serialVersionUID = -8288186597177634360L;
52 }