-
Notifications
You must be signed in to change notification settings - Fork 14
/
JenaUtils.java
38 lines (33 loc) · 1.03 KB
/
JenaUtils.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package cz.cvut.kbss.ontodriver.jena.util;
import cz.cvut.kbss.ontodriver.model.NamedResource;
import java.net.URL;
/**
* Utility methods for working with Jena API.
*/
public class JenaUtils {
private JenaUtils() {
throw new AssertionError();
}
/**
* Resolves whether the specified value is a resource identifier.
* <p>
* Only absolute IRIs are supported (i.e. no blank node identifiers).
*
* @param value The value to check
* @return {@code true} if the value is either an URI or an URL
*/
public static boolean isResourceIdentifier(Object value) {
if (value instanceof NamedResource || value instanceof java.net.URI || value instanceof URL) {
return true;
}
if (!(value instanceof String)) {
return false;
}
try {
final java.net.URI uri = java.net.URI.create(value.toString());
return uri.isAbsolute();
} catch (IllegalArgumentException e) {
return false;
}
}
}