1 /*
2 * Copyright (c) 2007, James Leigh All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * - Redistributions of source code must retain the above copyright notice, this
8 * list of conditions and the following disclaimer.
9 * - Redistributions in binary form must reproduce the above copyright notice,
10 * this list of conditions and the following disclaimer in the documentation
11 * and/or other materials provided with the distribution.
12 * - Neither the name of the openrdf.org nor the names of its contributors may
13 * be used to endorse or promote products derived from this software without
14 * specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 *
28 */
29 package org.openrdf.elmo;
30
31 import java.util.Collection;
32
33 /**
34 * Maps between roles and rdf:type.
35 *
36 * @author James Leigh
37 *
38 * @param <URI>
39 * Class used to represent a rdf:type.
40 */
41 public interface RoleMapper<URI> {
42 public abstract void setRdfTypeFactory(RdfTypeFactory<URI> vf);
43
44 public abstract void recordFactory(Class<?> javaClass);
45
46 public abstract void recordFactory(Class<?> javaClass, String type);
47
48 public abstract void recordRole(Class<?> role);
49
50 public abstract void recordRole(Class<?> role, String type);
51
52 /**
53 * Roles that shoulde be included by any bean. Used when the resource has no
54 * rdf:type.
55 *
56 * @return roles implemented by all Beans.
57 */
58 public abstract Class<?>[] findBaseRoles();
59
60 /**
61 * Determines if a registered role hase this value as a {link
62 * org.openrdf.annotations.oneOf} value.
63 *
64 * @param instance
65 * @return <code>true</code> if {link
66 * {@link #findIndividualRoles(Object, Collection)} will modify the
67 * collection.
68 */
69 public boolean isIndividualRolesPresent(URI instance);
70
71 /**
72 * Adds roles to the collection that are specific to this instance. Defined
73 * with the {link org.openrdf.annotations.oneOf} annotation.
74 *
75 * @param instance
76 * @param classes
77 * @return <code>classes</code>
78 */
79 public Collection<Class<?>> findIndividualRoles(URI instance,
80 Collection<Class<?>> classes);
81
82 /**
83 * Finds the Java Class for this rdf:Class. Searches for register classes.
84 *
85 * @param type
86 */
87 public abstract Class<?>[] findRoles(URI type);
88
89 /**
90 * Finds all the roles that should be implemented by these types.
91 *
92 * @param types
93 * rdf:types
94 * @param roles
95 * collection should be used to add the classes.
96 * @return <code>roles</code>
97 */
98 public abstract Collection<Class<?>> findRoles(Collection<URI> types,
99 Collection<Class<?>> roles);
100
101 /**
102 * Finds if there exists a Java Class for this rdf:Class. Searches for
103 * register classes.
104 *
105 * @param type
106 */
107 public abstract boolean isTypeRecorded(URI type);
108
109 /**
110 * Finds the rdf:Class for this Java Class.
111 *
112 * @param concept
113 * @return URI of the rdf:Class for this Java Class or null.
114 */
115 public URI findType(Class<?> concept);
116
117 /**
118 * Finds the rdf:types that this interface or class represents.
119 *
120 * @param concept
121 * @param rdfTypes
122 * @return <code>rdfTypes</code>
123 */
124 public abstract Collection<URI> findTypes(Class<?> role,
125 Collection<URI> rdfTypes);
126
127 /**
128 * Finds the rdf:types for concept and any sub-concept(s).
129 *
130 * @param concept
131 * @param rdfTypes
132 * @return <code>rdfTypes</code>
133 */
134 public abstract Collection<URI> findSubTypes(Class<?> role,
135 Collection<URI> rdfTypes);
136
137 }