PropertyValue.java
01 /*
02  *  PropertyValue.java
03  *
04  *  Niraj Aswani, 09/March/07
05  *
06  *  $Id: PropertyValue.html,v 1.0 2007/03/09 16:13:01 niraj Exp $
07  */
08 package gate.gui.ontology;
09 
10 import gate.creole.ontology.Literal;
11 import gate.creole.ontology.RDFProperty;
12 
13 /**
14  * There are various types of properties (e.g.
15  * RDF/Object/Datatype/Annotation etc). Resources with different
16  * properties have different types of property values (e.g. Instances
17  * for Object properties, string values for annotation/datatype and so
18  * on). This class represents a property value and its type.
19  
20  @author niraj
21  
22  */
23 public class PropertyValue {
24 
25   /**
26    * The instance of property for which the value is of type.
27    */
28   protected RDFProperty property;
29 
30   /**
31    * The actual value (it can be string or an instance of OResource)
32    */
33   protected Object value;
34 
35   /**
36    * Constructor
37    
38    @param property
39    @param value
40    */
41   public PropertyValue(RDFProperty property, Object value) {
42     this.property = property;
43     this.value = value;
44   }
45 
46   /**
47    * Gets the associated property
48    
49    @return
50    */
51   public RDFProperty getProperty() {
52     return property;
53   }
54 
55   /**
56    * Gets the set value
57    
58    @return
59    */
60   public Object getValue() {
61     return value;
62   }
63 
64   /**
65    * Returns the string representation (i.e. propertyURI("value")) which
66    * is used to show in the right hand side panel of the Ontology
67    * Editor.
68    */
69   public String toString() {
70     StringBuffer sb = new StringBuffer(property.toString());
71     sb.append("(");
72     if(value instanceof Literal) {
73       sb.append(((Literal)value).getValue());
74     }
75     else {
76       sb.append(value.toString());
77     }
78     sb.append(")");
79     return sb.toString();
80   }
81 }