| SerialAnalyserControllerPersistence.java |
1 /*
2 * Copyright (c) 1998-2004, The University of Sheffield.
3 *
4 * This file is part of GATE (see http://gate.ac.uk/), and is free
5 * software, licenced under the GNU Library General Public License,
6 * Version 2, June 1991 (in the distribution as file licence.html,
7 * and also available at http://gate.ac.uk/gate/licence.html).
8 *
9 * Valentin Tablan 29/10/2001
10 *
11 * $Id: SerialAnalyserControllerPersistence.java,v 1.4 2004/07/21 17:10:09 akshay Exp $
12 *
13 */
14 package gate.util.persistence;
15
16 import gate.Corpus;
17 import gate.creole.ResourceInstantiationException;
18 import gate.creole.SerialAnalyserController;
19 import gate.persist.PersistenceException;
20 /**
21 * Persistence handler for {@link SerialAnalyserController}.
22 * Adds handling of the corpus memeber to the {@link ControllerPersistence}
23 * class
24 */
25
26 public class SerialAnalyserControllerPersistence extends ControllerPersistence {
27 /**
28 * Populates this Persistence with the data that needs to be stored from the
29 * original source object.
30 */
31 public void extractDataFromSource(Object source)throws PersistenceException{
32 if(! (source instanceof SerialAnalyserController)){
33 throw new UnsupportedOperationException(
34 getClass().getName() + " can only be used for " +
35 SerialAnalyserController.class.getName() +
36 " objects!\n" + source.getClass().getName() +
37 " is not a " + SerialAnalyserController.class.getName());
38 }
39
40 super.extractDataFromSource(source);
41
42 SerialAnalyserController sac = (SerialAnalyserController)source;
43 corpus = PersistenceManager.getPersistentRepresentation(sac.getCorpus());
44 }
45
46 /**
47 * Creates a new object from the data contained. This new object is supposed
48 * to be a copy for the original object used as source for data extraction.
49 */
50 public Object createObject()throws PersistenceException,
51 ResourceInstantiationException{
52 SerialAnalyserController sac = (SerialAnalyserController)
53 super.createObject();
54 sac.setCorpus((Corpus)PersistenceManager.getTransientRepresentation(corpus));
55 return sac;
56 }
57 protected Object corpus;
58 static final long serialVersionUID = -4116973147963269225L;
59 }