1   package gate.creole;
2   
3   /*
4    *  Copyright (c) 1998-2001, The University of Sheffield.
5    *
6    *  This file is part of GATE (see http://gate.ac.uk/), and is free
7    *  software, licenced under the GNU Library General Public License,
8    *  Version 2, June 1991 (in the distribution as file licence.html,
9    *  and also available at http://gate.ac.uk/gate/licence.html).
10   *
11   *  Valentin Tablan, 13 May 2002
12   *
13   *  $Id: OntologyAwareTransducer.java,v 1.1 2002/05/14 12:37:09 valyt Exp $
14   */
15  
16  import gate.creole.ontology.Ontology;
17  import gate.Resource;
18  
19  /**
20   * An ontology aware JAPE transducer. Adds the {@link #ontology} member to the
21   * {@link Transducer} class.
22   */
23  public class OntologyAwareTransducer extends Transducer {
24  
25    /**
26     * The ontology that will be available on the RHS of JAPE rules.
27     */
28    private gate.creole.ontology.Ontology ontology;
29  
30    /**
31     * Gets the ontology used by this transducer.
32     * @return an {@link gate.creole.ontology.Ontology} value.
33     */
34    public gate.creole.ontology.Ontology getOntology() {
35      return ontology;
36    }
37  
38    /**
39     * Sets the ontology used by this transducer.
40     * @param ontology an {@link gate.creole.ontology.Ontology} value.
41     */
42    public void setOntology(gate.creole.ontology.Ontology ontology) {
43      this.ontology = ontology;
44    }
45  
46    public Resource init() throws ResourceInstantiationException {
47      Resource res = super.init();
48      batch.setOntology(ontology);
49      return res;
50    }
51  }