/** * The base of this IRIResolver. * @return String */ public String getBaseIRI() { return base.toString(); }
@Override protected String uriToPrefix(String uri) { return pmap.getMapping().entrySet().stream() .filter(e->Objects.equals(uri, e.getValue().toString())) .map(Entry::getKey) .findFirst() .orElse(null); }
@Override public void add(String prefix, IRI iri) { prefix = canonicalPrefix(prefix); prefixes.put(prefix, iri); uriToPrefix.put(iri.toString(), prefix) ; }
/** * Resolving relative IRIs, return a string, but do not throw exception on * bad a IRI */ public String resolveToStringSilent(String uriStr) { return resolveSilent(uriStr).toString(); }
@Override protected String prefixToUri(String prefix) { IRI iri = pmap.getMapping().get(prefix); if ( iri == null ) return null; return iri.toString(); }
@Override protected void apply(BiConsumer<String, String> action) { BiConsumer<String, IRI> a = (p, iri)->action.accept(p, iri.toString()); pmap.forEach(a); }
@Override public Map<String, String> getMappingCopyStr() { return getMapping().entrySet().stream() .collect(toMap(Map.Entry::getKey, v -> v.getValue().toString())); }
@Override public String expand(String prefix, String localName) { prefix = canonicalPrefix(prefix); IRI x = prefixes.get(prefix); if (x == null) return null; return x.toString() + localName; }
/** * Resolve a URI against a base. If baseStr is a relative file IRI * then it is first resolved against the current working directory. * If it is an absolute URI, it is normalized. * * @param uriStr * @return String An absolute URI */ static public String resolveStringSilent(String uriStr) throws RiotException { return globalResolver.resolveSilent(uriStr).toString(); }
@Override public void delete(String prefix) { prefix = canonicalPrefix(prefix); IRI iri = this.prefixes.get(prefix); if (iri == null) return; // Delete the abbreviation mapping this.abbrevs.remove(iri.toString()); // Delete the mapping this.prefixes.remove(prefix); }
@Override void checkBaseUse(XMLHandler forErrors, Taint taintMe, String relUri, IRI rslt) throws SAXParseException { String resolvedURI = rslt.toString(); if (relUri.equals(resolvedURI) && rslt.isAbsolute()) return; forErrors.warning(taintMe, errno, errmsg + ": <" + relUri + ">"); }
public InputStreamFactoryTests(IRI baseDir, String propDir) { createMe = "new TestInputStreamFactory(URI.create(\""+baseDir.toString() +"\"),\""+propDir+"\")"; base = baseDir; mapBase = null; this.zip = null; property = propDir.endsWith("/") ? propDir : propDir + "/"; }
/** * Resolve the relative URI str against the current * working directory. * @param str * @return String */ public static String resolveGlobal(String str) { return exceptions(cwd.resolve(str)).toString(); }
/** * Appends an IRI to the command text as a constant using appropriate * formatting * * @param iri * IRI to append */ public void appendIri(IRI iri) { this.appendNode(NodeFactory.createURI(iri.toString())); }
/** Abbreviate the URI */ private String abbrevByBase(String uri) { IRI rel = iriResolver.relativize(uri, relFlags) ; String r = null ; try { r = rel.toASCIIString() ; } catch (MalformedURLException ex) { r = rel.toString() ; } return r ; }
@Override public IRI create(IRI i) { if (i instanceof AbsIRIImpl && ((AbsIRIImpl)i).getFactory()==this) return i; return create(i.toString()); }
private static Node createNode(String x) { try { IRI iri = resolver.resolve(x) ; return NodeFactory.createURI(iri.toString()) ; } catch (Exception ex) { ServletOps.errorBadRequest("SPARQL Update: bad IRI: "+x) ; return null ; } } }
Test2(String r) { super( WGTestSuite.this.testDir.relativize(r, IRI.CHILD).toString()); // testID = r; } Model read(String file, boolean type) throws IOException {
static public String abbrevByBase(String uri, String base) { if ( hasScheme(uri) ) return uri ; IRI baseIRI = IRIResolver.iriFactory().construct(base) ; IRI rel = baseIRI.relativize(uri, relFlags) ; String r = rel.toString() ; return r ; }
protected final void directiveBase() { Token token = peekToken() ; if ( !lookingAt(IRI) ) exception(token, "@base requires an IRI (found '" + token + "')") ; String baseStr = token.getImage() ; IRI baseIRI = profile.makeIRI(baseStr, currLine, currCol) ; emitBase(baseIRI.toString()) ; nextToken() ; IRIResolver newResolver = IRIResolver.create(baseIRI) ; profile.setIRIResolver(newResolver); }