use of org.apache.jena.iri.IRI in project jena by apache.
the class FastAbbreviatingPrefixMap method delete.
@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);
}
use of org.apache.jena.iri.IRI in project jena by apache.
the class NodeFormatterTTL method abbrevByBase.
/** 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;
}
use of org.apache.jena.iri.IRI in project jena by apache.
the class PrefixMapBase method toString.
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{ ");
boolean first = true;
for (Entry<String, IRI> e : this.getMapping().entrySet()) {
String prefix = e.getKey();
IRI iri = e.getValue();
if (first)
first = false;
else
sb.append(" ,");
sb.append(prefix);
sb.append(":=");
sb.append(iri.toString());
}
sb.append(" }");
return sb.toString();
}
use of org.apache.jena.iri.IRI in project jena by apache.
the class IRIValidator method execute.
@Override
protected void execute(HttpServletRequest httpRequest, HttpServletResponse httpResponse) {
try {
String[] args = httpRequest.getParameterValues(paramIRI);
ServletOutputStream outStream = httpResponse.getOutputStream();
PrintStream stdout = System.out;
PrintStream stderr = System.err;
System.setOut(new PrintStream(outStream));
System.setErr(new PrintStream(outStream));
setHeaders(httpResponse);
outStream.println("<html>");
printHead(outStream, "Jena IRI Validator Report");
outStream.println("<body>");
outStream.println("<h1>IRI Report</h1>");
startFixed(outStream);
try {
boolean first = true;
for (String iriStr : args) {
if (!first)
System.out.println();
first = false;
IRI iri = iriFactory.create(iriStr);
System.out.println(iriStr + " ==> " + iri);
if (iri.isRelative())
System.out.println("Relative IRI: " + iriStr);
Iterator<Violation> vIter = iri.violations(true);
for (; vIter.hasNext(); ) {
String str = vIter.next().getShortMessage();
str = htmlQuote(str);
System.out.println(str);
}
}
} finally {
finishFixed(outStream);
System.out.flush();
System.err.flush();
System.setOut(stdout);
System.setErr(stdout);
}
outStream.println("</body>");
outStream.println("</html>");
} catch (IOException ex) {
}
}
use of org.apache.jena.iri.IRI in project jena by apache.
the class Additional method relDotSlash2.
@Test
public void relDotSlash2() throws MalformedURLException {
IRIFactory f = IRIFactory.iriImplementation();
IRI iri = f.construct("http://a/b/c/dddd;pppp?qqqqq");
IRI iri2 = iri.resolve("./foo");
test(iri2, "http://a/b/c/foo");
}
Aggregations