| SerialAnalyserControllerPersistence |

    1   /*
    2    *  Copyright (c) 1998-2001, 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.2 2001/10/29 17:11:26 valyt Exp $
    12   *
    13   */
    14  package gate.util.persistence;
    15
    16  import gate.*;
    17  import gate.creole.*;
    18  import gate.util.*;
    19  import gate.persist.PersistenceException;
    20
    21  import java.util.*;
    22  /**
    23   * Persistence handler for {@link SerialAnalyserController}.
    24   * Adds handling of the corpus memeber to the {@link ControllerPersistence}
    25   * class
    26   */
    27
    28  public class SerialAnalyserControllerPersistence extends ControllerPersistence {
    29    /**
    30     * Populates this Persistence with the data that needs to be stored from the
    31     * original source object.
    32     */
    33    public void extractDataFromSource(Object source)throws PersistenceException{
    34      if(! (source instanceof SerialAnalyserController)){
    35        throw new UnsupportedOperationException(
    36                  getClass().getName() + " can only be used for " +
    37                  SerialAnalyserController.class.getName() +
    38                  " objects!\n" + source.getClass().getName() +
    39                  " is not a " + SerialAnalyserController.class.getName());
    40      }
    41
    42      super.extractDataFromSource(source);
    43
    44      SerialAnalyserController sac = (SerialAnalyserController)source;
    45      corpus = PersistenceManager.getPersistentRepresentation(sac.getCorpus());
    46    }
    47
    48    /**
    49     * Creates a new object from the data contained. This new object is supposed
    50     * to be a copy for the original object used as source for data extraction.
    51     */
    52    public Object createObject()throws PersistenceException,
    53                                       ResourceInstantiationException{
    54      SerialAnalyserController sac = (SerialAnalyserController)
    55                                    super.createObject();
    56      sac.setCorpus((Corpus)PersistenceManager.getTransientRepresentation(corpus));
    57      return sac;
    58    }
    59    protected Object corpus;
    60    static final long serialVersionUID = -4116973147963269225L;
    61  }

| SerialAnalyserControllerPersistence |