01 /*
02 * Copyright (c) 1995-2010, The University of Sheffield. See the file
03 * COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
04 *
05 * This file is part of GATE (see http://gate.ac.uk/), and is free
06 * software, licenced under the GNU Library General Public License,
07 * Version 2, June 1991 (in the distribution as file licence.html,
08 * and also available at http://gate.ac.uk/gate/licence.html).
09 *
10 * Valentin Tablan 17/05/2002
11 *
12 * $Id: FeatureReader.java 12006 2009-12-01 17:24:28Z thomas_heitz $
13 *
14 */
15 package gate.creole.ir;
16
17 import gate.Document;
18
19 /**
20 * A property reader for a document feature
21 */
22 public class FeatureReader implements PropertyReader {
23
24 public FeatureReader(String featureName){
25 this.featureName = featureName;
26 }
27
28 public String getPropertyValue(Document doc) {
29 if(doc.getFeatures() != null){
30 Object value = doc.getFeatures().get(featureName);
31 if(value != null) return value.toString();
32 }
33 return "";
34 }
35
36 String featureName;
37 static final long serialVersionUID = -2831603184521440396L;
38 }
|