| LanguageAnalyserPersistence |

    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: LanguageAnalyserPersistence.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   * Provides a persistent equivalent for {@link LanguageAnalyser}s.
    24   * Adds handling of corpus and document members for PRPersistence.
    25   */
    26  public class LanguageAnalyserPersistence extends PRPersistence {
    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 LanguageAnalyser)){
    33        throw new UnsupportedOperationException(
    34                  getClass().getName() + " can only be used for " +
    35                  LanguageAnalyser.class.getName() +
    36                  " objects!\n" + source.getClass().getName() +
    37                  " is not a " + LanguageAnalyser.class.getName());
    38      }
    39
    40      super.extractDataFromSource(source);
    41
    42      LanguageAnalyser la = (LanguageAnalyser)source;
    43      document = PersistenceManager.getPersistentRepresentation(la.getDocument());
    44      corpus = PersistenceManager.getPersistentRepresentation(la.getCorpus());
    45    }
    46
    47    /**
    48     * Creates a new object from the data contained. This new object is supposed
    49     * to be a copy for the original object used as source for data extraction.
    50     */
    51    public Object createObject()throws PersistenceException,
    52                                       ResourceInstantiationException{
    53      LanguageAnalyser la = (LanguageAnalyser)super.createObject();
    54      la.setCorpus((Corpus)PersistenceManager.getTransientRepresentation(corpus));
    55      la.setDocument((Document)PersistenceManager.
    56                               getTransientRepresentation(document));
    57      return la;
    58    }
    59
    60
    61    protected Object corpus;
    62    protected Object document;
    63    static final long serialVersionUID = -4632241679877556163L;
    64  }

| LanguageAnalyserPersistence |