1   /*
2    * DatatypePropertyImpl.java
3    *
4    * Copyright (c) 2002, 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, June1991.
9    *
10   * A copy of this licence is included in the distribution in the file
11   * licence.html, and is also available at http://gate.ac.uk/gate/licence.html.
12   *
13   * Kalina Bontcheva 11/2003
14   *
15   *
16   *  $Id: DatatypePropertyImpl.java,v 1.1 2004/07/23 17:48:08 kalina Exp $
17   */
18  
19  package gate.creole.ontology;
20  
21  public class DatatypePropertyImpl extends PropertyImpl
22                                      implements DatatypeProperty{
23    private Object range;
24  
25    public DatatypePropertyImpl(String aName, OClass aDomain, String aString, Ontology aKB) {
26      super(aName, aDomain, aKB);
27      range = aString;
28    }
29  
30    public DatatypePropertyImpl(String aName, OClass aDomain, Number number, Ontology aKB) {
31      super(aName, aDomain, aKB);
32      range = number;
33    }
34  
35    public boolean isValueCompatible(Object value) {
36      if (value instanceof String)
37        return true;
38      else if (value instanceof Number)
39        return true;
40      return false;
41    }
42  
43    public Object getRange() {
44      return range;
45    }
46  
47    public String toString() {
48      return this.getName() + "(" + this.getDomain() + "," + this.range + ")" +
49              "\n sub-propertyOf "
50              + this.getSubPropertyOf().toString() +
51              "\n samePropertyAs " +
52              this.getSamePropertyAs().toString();
53    }
54  
55  }