/curie-util

Java utility library to translate CURIEs to IRIs and vice-versa.

Primary LanguageJavaBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

Build Status Maven Central Javadoc

curie-util

Java utility library to translate CURIEs to IRIs and vice-versa.

Usage

Add the dependency:

<dependency>
    <groupId>org.prefixcommons</groupId>
    <artifactId>curie-util</artifactId>
    <version>0.0.2</version>
</dependency

Create the CurieUtil object

From a java map object:

Map<String, String> map = new HashMap<>();
map.put("", "http://x.org/");
map.put("A", "http://x.org/a_");
map.put("B", "http://x.org/B_");
map.put("CC", "http://x.org/C_C");
map.put("C", "http://x.org/C_");
CurieUtil curieUtil = new CurieUtil(map);

From a json-ld file:

CurieUtil curieUtil = CurieUtil.fromJsonLdFile("path/to/file");

Translates CURIEs and IRIs

Both methods will return an Option:

curieUtil.getCurie("http://x.org/a_foo"); // Optional.of("A:foo")
curieUtil.getIri("A:foo"); // Optional.of("http://x.org/a_foo")
curieUtil.getCurie("none"); // Optional.absent();