UnconditionalRunningStrategyPersistence.java
01 package gate.util.persistence;
02 
03 import gate.ProcessingResource;
04 import gate.creole.ResourceInstantiationException;
05 import gate.creole.RunningStrategy.UnconditionalRunningStrategy;
06 import gate.persist.PersistenceException;
07 
08 import java.io.Serializable;
09 
10 /**
11  * Persistent holder for {@link gate.creole.RunningStrategy.UnconditionalRunningStrategy}.
12  */
13 
14 public class UnconditionalRunningStrategyPersistence extends AbstractPersistence {
15 
16   @Override
17   public void extractDataFromSource(Object sourcethrows PersistenceException {
18     if((source instanceof UnconditionalRunningStrategy))
19       throw new UnsupportedOperationException(
20                 getClass().getName() " can only be used for " +
21                 UnconditionalRunningStrategy.class.getName() +
22                 " objects!\n" + source.getClass().getName() +
23                 " is not a " + UnconditionalRunningStrategy.class.getName());
24     UnconditionalRunningStrategy strategy = (UnconditionalRunningStrategy)source;
25     this.pr = PersistenceManager.getPersistentRepresentation(strategy.getPR());
26     this.shouldRun = strategy.shouldRun();
27   }
28 
29 
30   @Override
31   public Object createObject() throws PersistenceException,
32                                       ResourceInstantiationException {
33     return new UnconditionalRunningStrategy(
34             (ProcessingResource)PersistenceManager.
35                getTransientRepresentation(pr,containingControllerName,initParamOverrides),
36             shouldRun);
37   }
38 
39   protected boolean shouldRun;
40 
41   protected Serializable pr;
42   
43   /**
44    * Serialisation ID
45    */
46   private static final long serialVersionUID = 5049829826299681555L;
47 }