01: package org.ontoware.rdfreactor.runtime.example;
02:
03: import org.ontoware.rdf2go.model.Model;
04: import org.ontoware.rdf2go.model.node.URI;
05: import org.ontoware.rdf2go.model.node.impl.URIImpl;
06: import org.ontoware.rdfreactor.runtime.RDFDataException;
07: import org.ontoware.rdfreactor.runtime.ReactorBaseImpl;
08:
09: public class Person extends ReactorBaseImpl {
10:
11: /**
12: * class uri
13: */
14: public static final URI PERSON = new URIImpl("schema://person");
15:
16: // property uris
17:
18: public static final URI AGE = new URIImpl("schema://age");
19:
20: public static final URI NAME = new URIImpl("schema://name");
21:
22: public static final URI HAS_FRIEND = new URIImpl(
23: "schema://hasFriend");
24:
25: /**
26: * @param model -
27: * rdf2go model
28: * @param uri -
29: * instance URI
30: */
31: public Person(Model model, URI uri, boolean write) {
32: super (model, PERSON, uri, write);
33: }
34:
35: public Integer getAge() throws RDFDataException {
36: return (Integer) get(AGE, Integer.class);
37: }
38:
39: public void setAge(Integer age) {
40: set(AGE, age);
41: }
42:
43: public String getName() throws RDFDataException {
44: return (String) get(NAME, String.class);
45: }
46:
47: public void setName(String name) {
48: set(NAME, name);
49: }
50:
51: public void addFriend(Person p) {
52: add(HAS_FRIEND, p);
53: }
54:
55: public boolean removeFriend(Person p) {
56: return remove(HAS_FRIEND, p);
57: }
58:
59: public Person[] getAllFriend() {
60: return (Person[]) getAll(HAS_FRIEND, Person.class);
61: }
62:
63: public Person[] getAllInstances() {
64: return (Person[]) getAllInstances(super .model, Person.class);
65: }
66:
67: }
|