@Override public IRI resolveSilent(final String uriStr) { if (resolvedIRIs == null) return iriFactory.create(uriStr); Callable<IRI> filler = () -> iriFactory.create(uriStr); IRI iri = resolvedIRIs.getOrFill(uriStr, filler); return iri; }
/* * No exception thrown by this method. */ private static IRI resolveIRI(String relStr, String baseStr) { IRI i = iriFactory.create(relStr); if (i.isAbsolute()) // removes excess . segments return globalResolver.getBaseIRI().create(i); IRI base = iriFactory.create(baseStr); if ("file".equalsIgnoreCase(base.getScheme())) return globalResolver.getBaseIRI().create(i); return base.create(i); }
/** The current global resolver based on the working directory */ static { IRI cwd; try { cwd = iriFactory.construct(globalBase); } catch (IRIException e) { System.err.println("Unexpected IRIException in initializer: " + e.getMessage()); cwd = iriFactory.create("file:///"); e.printStackTrace(System.err); } globalResolver = new IRIResolverSync(IRIResolver.create(cwd)); }
@Override protected JsonObject execute(ValidationAction action) { JsonBuilder obj = new JsonBuilder(); obj.startObject(); String args[] = getArgs(action, paramIRI); if (args.length == 0) ServletOps.errorBadRequest("No IRIs supplied"); obj.key(jIRIs); obj.startArray(); for (String iriStr : args) { obj.startObject(); obj.key(jIRI).value(iriStr); IRI iri = iriFactory.create(iriStr); List<String> errors = new ArrayList<>(); List<String> warnings = new ArrayList<>(); if (iri.isRelative()) warnings.add("Relative IRI: " + iriStr); Iterator<Violation> vIter = iri.violations(true); for (; vIter.hasNext(); ) { Violation v = vIter.next(); String str = v.getShortMessage(); if (v.isError()) errors.add(str); else warnings.add(str); } obj.key(jErrors); obj.startArray(); for (String msg : errors) obj.value(msg); obj.finishArray(); obj.key(jWarnings); obj.startArray(); for (String msg : warnings) obj.value(msg); obj.finishArray(); obj.finishObject(); } obj.finishArray(); obj.finishObject(); return obj.build().getAsObject(); }
/** Parse an IRI (does not resolve it) */ public static IRI parseIRI(String iriStr) { return iriFactory.create(iriStr); }