| FeatureReader.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 17/05/2002
10 *
11 * $Id: FeatureReader.java,v 1.2 2004/07/21 17:10:04 akshay Exp $
12 *
13 */
14 package gate.creole.ir;
15
16 import gate.Document;
17
18 /**
19 * A property reader for a document feature
20 */
21 public class FeatureReader implements PropertyReader {
22
23 public FeatureReader(String featureName){
24 this.featureName = featureName;
25 }
26
27 public String getPropertyValue(Document doc) {
28 if(doc.getFeatures() != null){
29 Object value = doc.getFeatures().get(featureName);
30 if(value != null) return value.toString();
31 }
32 return "";
33 }
34
35 String featureName;
36 static final long serialVersionUID = -2831603184521440396L;
37 }