View Javadoc

1   /*
2    *  $Id: Attribute.java,v 1.1 2004/07/24 18:10:30 roku Exp $ 
3    *
4    *  Copyright 2004 University of Hannover
5    *
6    *  Licensed under the Apache License, Version 2.0 (the "License");
7    *  you may not use this file except in compliance with the License.
8    *  You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   *  Unless required by applicable law or agreed to in writing, software
13   *  distributed under the License is distributed on an "AS IS" BASIS,
14   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   *  See the License for the specific language governing permissions and
16   *  limitations under the License.
17   */
18  
19  package olr.rdf;
20  
21  
22  
23  public class Attribute
24  {
25  
26      public Attribute(String predicate, String object)
27      {
28          this.predicate = Tools.correctURI(predicate);
29          this.object = Tools.correctURI(object);
30          ID = hashCode();
31      }
32  
33      public Attribute(String predicate, String object, int ID)
34      {
35          this.predicate = Tools.correctURI(predicate);
36          this.object = Tools.correctURI(object);
37          this.ID = ID;
38      }
39  
40      public Attribute(Attribute attribute)
41      {
42          predicate = attribute.getPredicate();
43          object = attribute.getObject();
44          ID = attribute.getID();
45      }
46  
47      public String getPredicate()
48      {
49          return predicate;
50      }
51  
52      public String getObject()
53      {
54          return object;
55      }
56  
57      public void setObject(String object)
58      {
59          this.object = Tools.correctURI(object);
60      }
61  
62      public boolean hasObject()
63      {
64          return object.length() > 0;
65      }
66  
67      public int getID()
68      {
69          return ID;
70      }
71  
72      public String toString()
73      {
74          return String.valueOf(String.valueOf((new StringBuffer(String.valueOf(String.valueOf(predicate.toString())))).append('=').append(object.toString())));
75      }
76  
77      protected String predicate;
78      protected String object;
79      private int ID;
80  }