| DSPersistence |

    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 26/10/2001
    10   *
    11   *  $Id: DSPersistence.java,v 1.3 2001/11/05 18:16:27 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  public class DSPersistence implements Persistence{
    24
    25
    26    /**
    27     * Populates this Persistence with the data that needs to be stored from the
    28     * original source object.
    29     */
    30    public void extractDataFromSource(Object source)throws PersistenceException{
    31      //check input
    32      if(! (source instanceof DataStore)){
    33        throw new UnsupportedOperationException(
    34                  getClass().getName() + " can only be used for " +
    35                  DataStore.class.getName() +
    36                  " objects!\n" + source.getClass().getName() +
    37                  " is not a " + DataStore.class.getName());
    38      }
    39
    40      DataStore ds = (DataStore)source;
    41      className = ds.getClass().getName();
    42      storageUrlString = ds.getStorageUrl();
    43    }
    44
    45    /**
    46     * Creates a new object from the data contained. This new object is supposed
    47     * to be a copy for the original object used as source for data extraction.
    48     */
    49    public Object createObject()throws PersistenceException,
    50                                       ResourceInstantiationException{
    51      return Factory.openDataStore(className, storageUrlString);
    52    }
    53
    54    protected String className;
    55    protected String storageUrlString;
    56    static final long serialVersionUID = 5952924943977701708L;
    57  }
    58

| DSPersistence |