1 |
/* Graph.java -- Representation of a RDF graph. |
/* Graph.java -- Representation of a RDF graph. |
2 |
Copyright (C) 2005 The University of Sheffield. |
Copyright (C) 2005 The University of Sheffield. |
3 |
|
|
4 |
This file is part of the CASheW-s editor. |
This file is part of the CASheW-s editor. |
5 |
|
|
6 |
The CASheW-s editor is free software; you can redistribute it and/or modify |
The CASheW-s editor is free software; you can redistribute it and/or modify |
7 |
it under the terms of the GNU General Public License as published by |
it under the terms of the GNU General Public License as published by |
8 |
the Free Software Foundation; either version 2, or (at your option) |
the Free Software Foundation; either version 2, or (at your option) |
9 |
any later version. |
any later version. |
10 |
|
|
11 |
The CASheW-s editor is distributed in the hope that it will be useful, but |
The CASheW-s editor is distributed in the hope that it will be useful, but |
12 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 |
General Public License for more details. |
General Public License for more details. |
15 |
|
|
16 |
You should have received a copy of the GNU General Public License |
You should have received a copy of the GNU General Public License |
17 |
along with The CASheW-s editor; see the file COPYING. If not, write to the |
along with The CASheW-s editor; see the file COPYING. If not, write to the |
18 |
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
19 |
02111-1307 USA. |
02111-1307 USA. |
20 |
*/ |
*/ |
21 |
|
|
22 |
package nongnu.cashews.rdf; |
package nongnu.cashews.rdf; |
25 |
import java.util.Set; |
import java.util.Set; |
26 |
|
|
27 |
/** |
/** |
28 |
* This class represents an RDF graph, |
* This class represents an RDF graph, formally described as a set of RDF |
29 |
* formally described as a set of RDF triples. |
* triples. The graph is made up of nodes (the subjects and objects of the |
30 |
* The graph is made up of nodes (the subjects |
* triples) and the links between these nodes (the predicates of the triples). |
31 |
* and objects of the triples) and the links between |
* |
|
* these nodes (the predicates of the triples). |
|
|
* |
|
32 |
* @author Andrew John Hughes (gnu_andrew@member.fsf.org) |
* @author Andrew John Hughes (gnu_andrew@member.fsf.org) |
33 |
* @see Triple |
* @see Triple |
34 |
* @see Node |
* @see Node |
36 |
* @see RDFObject |
* @see RDFObject |
37 |
* @see Predicate |
* @see Predicate |
38 |
*/ |
*/ |
39 |
public class Graph |
public class Graph |
40 |
implements Serializable |
implements Serializable |
41 |
{ |
{ |
42 |
|
|
43 |
/** |
/** |
44 |
* The set of RDF triples which make up |
* Serialization UID for compatability. |
45 |
* this particular RDF <code>Graph</code> |
*/ |
46 |
* instance. |
private static final long serialVersionUID = -4009151165788339408L; |
47 |
* |
|
48 |
|
/** |
49 |
|
* The set of RDF triples which make up this particular RDF |
50 |
|
* <code>Graph</code> instance. |
51 |
|
* |
52 |
* @see Triple |
* @see Triple |
53 |
* @serial the graph of RDF triples. |
* @serial the graph of RDF triples. |
54 |
*/ |
*/ |
55 |
private Set graph; |
private Set<Triple> graph; |
56 |
|
|
57 |
/** |
/** |
58 |
* Returns true if the specified object is either of type <code>Graph</code>, |
* Returns true if the specified object is either of type <code>Graph</code>, |
59 |
* or a sub-type, and contains an equivalent set of triples. If the |
* or a sub-type, and contains an equivalent set of triples. If the specified |
60 |
* specified object is null, false is returned. |
* object is null, false is returned. |
61 |
* |
* |
62 |
* @param obj the object to compare this object with. |
* @param obj |
63 |
|
* the object to compare this object with. |
64 |
* @return true if the two objects are equivalent. |
* @return true if the two objects are equivalent. |
65 |
*/ |
*/ |
66 |
public boolean equals(Object obj) |
public boolean equals(Object obj) |
69 |
return false; |
return false; |
70 |
if (getClass() == obj.getClass()) |
if (getClass() == obj.getClass()) |
71 |
{ |
{ |
72 |
Graph g = (Graph) obj; |
Graph g = (Graph) obj; |
73 |
return graph.equals(g.getGraph()); |
return graph.equals(g.getGraph()); |
74 |
} |
} |
75 |
else |
else |
76 |
return false; |
return false; |
77 |
} |
} |
78 |
|
|
79 |
/** |
/** |
80 |
|
* Returns the hashcode of this RDF graph. This is the code for the |
81 |
|
* underlying collection of <code>Triple</code>s. |
82 |
|
* |
83 |
|
* @return the hashcode for the RDF graph. |
84 |
|
*/ |
85 |
|
public int hashCode() |
86 |
|
{ |
87 |
|
return graph.hashCode(); |
88 |
|
} |
89 |
|
|
90 |
|
/** |
91 |
* Returns the graph of RDF triples. |
* Returns the graph of RDF triples. |
92 |
* |
* |
93 |
* @return a graph of RDF triples. |
* @return a graph of RDF triples. |
94 |
*/ |
*/ |
95 |
public Set getGraph() |
public Set<Triple> getGraph() |
96 |
{ |
{ |
97 |
return graph; |
return graph; |
98 |
} |
} |