|
14 | 14 | * #L%
|
15 | 15 | */
|
16 | 16 |
|
17 |
| -import org.apache.jena.rdf.model.ResourceFactory; |
18 | 17 | import org.apache.jena.rdf.model.Property;
|
| 18 | +import org.apache.jena.rdf.model.ResourceFactory; |
19 | 19 | import thewebsemantic.Namespace;
|
20 | 20 | import thewebsemantic.RdfType;
|
21 | 21 |
|
|
24 | 24 | *
|
25 | 25 | * @author scholze
|
26 | 26 | * @version $LastChangedRevision: 417 $
|
27 |
| - * |
28 | 27 | */
|
29 | 28 | public class SPARQLHelper {
|
30 |
| - private SPARQLHelper() {} |
| 29 | + private SPARQLHelper() { |
| 30 | + } |
31 | 31 |
|
32 |
| - public static String appendDefaultPrefixes(final String sparqlQuery) { |
| 32 | + public static String appendDefaultPrefixes(final String sparqlQuery) { |
33 | 33 | return SPARQLPrefixMappings.getAllAsPrefixString() + sparqlQuery;
|
34 |
| - } |
| 34 | + } |
35 | 35 |
|
36 |
| - public static synchronized <T> String getRdfNamespace( |
37 |
| - final Class<T> clazz) { |
38 |
| - final Namespace namespaceAnnotation = clazz |
39 |
| - .getAnnotation(Namespace.class); |
40 |
| - if (namespaceAnnotation == null) { |
41 |
| - throw new IllegalArgumentException( |
42 |
| - "Clazz must be annotated with thewebsemantic.Namespace annotation."); |
43 |
| - } |
44 |
| - return namespaceAnnotation.value().endsWith("/") ? namespaceAnnotation |
45 |
| - .value() : namespaceAnnotation.value() + "/"; |
46 |
| - } |
| 36 | + public static synchronized <T> String getRdfNamespace(final Class<T> clazz) { |
| 37 | + final Namespace namespaceAnnotation = clazz.getAnnotation(Namespace.class); |
| 38 | + if (namespaceAnnotation == null) { |
| 39 | + throw new IllegalArgumentException("Clazz must be annotated with thewebsemantic.Namespace annotation."); |
| 40 | + } |
| 41 | + return namespaceAnnotation.value().endsWith("/") |
| 42 | + ? namespaceAnnotation.value() |
| 43 | + : namespaceAnnotation.value() + "/"; |
| 44 | + } |
47 | 45 |
|
48 |
| - public static synchronized <T> String getRdfType(final Class<T> clazz) { |
49 |
| - final RdfType typeAnnotation = clazz.getAnnotation(RdfType.class); |
50 |
| - if (typeAnnotation == null) { |
51 |
| - throw new IllegalArgumentException( |
52 |
| - "Clazz must be annotated with thewebsemantic.RdfType annotation."); |
53 |
| - } |
54 |
| - return typeAnnotation.value(); |
55 |
| - } |
| 46 | + public static synchronized <T> String getRdfType(final Class<T> clazz) { |
| 47 | + final RdfType typeAnnotation = clazz.getAnnotation(RdfType.class); |
| 48 | + if (typeAnnotation == null) { |
| 49 | + throw new IllegalArgumentException("Clazz must be annotated with thewebsemantic.RdfType annotation."); |
| 50 | + } |
| 51 | + return typeAnnotation.value(); |
| 52 | + } |
56 | 53 |
|
57 |
| - public static synchronized <T> String getRdfPropertyQualifier( |
58 |
| - final Class<T> clazz, final String propertyName) { |
59 |
| - return String.format("<%s%s>", SPARQLHelper.getRdfNamespace(clazz), |
60 |
| - propertyName); |
61 |
| - } |
| 54 | + public static synchronized <T> String getRdfPropertyQualifier(final Class<T> clazz, final String propertyName) { |
| 55 | + return String.format("<%s%s>", SPARQLHelper.getRdfNamespace(clazz), propertyName); |
| 56 | + } |
62 | 57 |
|
63 |
| - public static synchronized <T> Property createProperty( |
64 |
| - final Class<T> clazz, final String propertyName) { |
65 |
| - return ResourceFactory.createProperty(String.format("%s%s", |
66 |
| - SPARQLHelper.getRdfNamespace(clazz), propertyName)); |
67 |
| - } |
| 58 | + public static synchronized <T> Property createProperty(final Class<T> clazz, final String propertyName) { |
| 59 | + return ResourceFactory.createProperty(String.format("%s%s", SPARQLHelper.getRdfNamespace(clazz), propertyName)); |
| 60 | + } |
68 | 61 |
|
69 |
| - public static synchronized <T> String getRdfClassQualifier( |
70 |
| - final Class<T> clazz) { |
71 |
| - return String.format("<%s%s>", SPARQLHelper.getRdfNamespace(clazz), |
72 |
| - SPARQLHelper.getRdfType(clazz)); |
73 |
| - } |
| 62 | + public static synchronized <T> String getRdfClassQualifier(final Class<T> clazz) { |
| 63 | + return String.format("<%s%s>", SPARQLHelper.getRdfNamespace(clazz), SPARQLHelper.getRdfType(clazz)); |
| 64 | + } |
74 | 65 |
|
75 |
| - public static synchronized <T> String getRdfClassQualifierWithoutBraces( |
76 |
| - final Class<T> clazz) { |
77 |
| - return String.format("%s%s", SPARQLHelper.getRdfNamespace(clazz), |
78 |
| - SPARQLHelper.getRdfType(clazz)); |
79 |
| - } |
| 66 | + public static synchronized <T> String getRdfClassQualifierWithoutBraces(final Class<T> clazz) { |
| 67 | + return String.format("%s%s", SPARQLHelper.getRdfNamespace(clazz), SPARQLHelper.getRdfType(clazz)); |
| 68 | + } |
80 | 69 | }
|
0 commit comments