Search in sources :

Example 11 with IRI

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);
}
Also used : IRI(org.apache.jena.iri.IRI)

Example 12 with IRI

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;
}
Also used : IRI(org.apache.jena.iri.IRI) MalformedURLException(java.net.MalformedURLException)

Example 13 with IRI

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();
}
Also used : IRI(org.apache.jena.iri.IRI)

Example 14 with IRI

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) {
    }
}
Also used : Violation(org.apache.jena.iri.Violation) PrintStream(java.io.PrintStream) IRI(org.apache.jena.iri.IRI) ServletOutputStream(javax.servlet.ServletOutputStream) IOException(java.io.IOException)

Example 15 with IRI

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");
}
Also used : IRI(org.apache.jena.iri.IRI) IRIFactory(org.apache.jena.iri.IRIFactory) Test(org.junit.Test)

Aggregations

IRI (org.apache.jena.iri.IRI)51 Violation (org.apache.jena.iri.Violation)12 IRIFactory (org.apache.jena.iri.IRIFactory)9 IOException (java.io.IOException)3 Node (org.apache.jena.graph.Node)3 Test (org.junit.Test)3 PrintStream (java.io.PrintStream)2 MalformedURLException (java.net.MalformedURLException)2 ServletOutputStream (javax.servlet.ServletOutputStream)2 Lang (org.apache.jena.riot.Lang)2 RiotException (org.apache.jena.riot.RiotException)2 CheckerIRI (org.apache.jena.riot.checker.CheckerIRI)2 IRI (org.apache.jena.riot.tokens.TokenType.IRI)2 InputStream (java.io.InputStream)1 BigDecimal (java.math.BigDecimal)1 URI (java.net.URI)1 URL (java.net.URL)1 Date (java.sql.Date)1 SQLException (java.sql.SQLException)1 Time (java.sql.Time)1