1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package olr.relations;
18
19 import java.util.ArrayList;
20 import java.util.Collection;
21 import java.util.Iterator;
22 import java.util.List;
23
24 import olr.rdf.Model;
25 import olr.rdf.Resource;
26 import olr.rdf.StatementPool;
27
28 /***
29 * @version $Id: RelationViewer.java,v 1.9 2004/08/02 18:36:53 roku Exp $
30 */
31 public final class RelationViewer {
32 /***
33 * Initializes an instance of this class.
34 *
35 * @param model
36 */
37 public RelationViewer(Model model) {
38 this.model = model;
39 }
40
41 public List getRelationTypes() {
42 ArrayList properties = new ArrayList();
43 Collection resources = model.getSubjects();
44 Iterator it = resources.iterator();
45 do {
46 if (!it.hasNext())
47 break;
48 Resource property = getStatementPool().getResource(it.next().toString());
49 if (getStatementPool().isProperty(property)
50 && property.getNS().equals(model.getNamespace()))
51 properties.add(property);
52 } while (true);
53 return properties;
54 }
55
56 public List getSpecificRelations(String aboutURI, String predicate) {
57 List relations = new ArrayList();
58 Resource resource = getStatementPool().getResource(aboutURI);
59 if (resource != null) {
60 Iterator it = resource.getObjects(predicate).iterator();
61 do {
62 if (!it.hasNext())
63 break;
64 Resource object = getStatementPool().getResource(it.next().toString());
65 if (object != null)
66 relations.add(object);
67 } while (true);
68 }
69 return relations;
70 }
71
72 private StatementPool getStatementPool() {
73 return model.getStatementPool();
74 }
75
76 Model model;
77 }