Search in sources :

Example 16 with IRI

use of org.apache.jena.iri.IRI in project jena by apache.

the class Additional method relDotSlash1.

@Test
public void relDotSlash1() throws MalformedURLException {
    IRIFactory f = IRIFactory.iriImplementation();
    IRI iri = f.construct("http://a/b/c/dddd;pppp?qqqqq");
    IRI iri2 = iri.resolve("./");
    test(iri2, "http://a/b/c/");
}
Also used : IRI(org.apache.jena.iri.IRI) IRIFactory(org.apache.jena.iri.IRIFactory) Test(org.junit.Test)

Example 17 with IRI

use of org.apache.jena.iri.IRI in project jena by apache.

the class MainGenerateLexers method checkOne.

static void checkOne(String s) {
    IRI iri = IRIFactory.iriImplementation().create(s);
    System.out.println(">> " + iri);
    for (Iterator<Violation> iter = iri.violations(true); iter.hasNext(); ) {
        Violation v = iter.next();
        System.out.println(v.getShortMessage());
    }
    System.out.println("<< " + iri);
    System.out.println();
}
Also used : Violation(org.apache.jena.iri.Violation) IRI(org.apache.jena.iri.IRI)

Example 18 with IRI

use of org.apache.jena.iri.IRI in project jena by apache.

the class RunIRI method processIRI.

private static void processIRI(String iriStr) {
    IRI iri = IRIFactory.iriImplementation().create(iriStr);
    System.out.println(iri);
    System.out.println("Relative: " + iri.isRelative());
    Iterator<Violation> vIter = iri.violations(true);
    for (; vIter.hasNext(); ) {
        System.out.println("** " + vIter.next().getShortMessage());
    }
    System.out.println(iriStr + " ==> " + iri);
    System.exit(0);
}
Also used : Violation(org.apache.jena.iri.Violation) IRI(org.apache.jena.iri.IRI)

Example 19 with IRI

use of org.apache.jena.iri.IRI in project jena by apache.

the class JenaOSGITest method testJenaIRI.

@Test
public void testJenaIRI() throws Exception {
    IRIFactory iriFactory = IRIFactory.iriImplementation();
    IRI iri = iriFactory.create("http://example.com/");
    assertEquals("http://example.com/", iri.toASCIIString());
}
Also used : IRI(org.apache.jena.iri.IRI) IRIFactory(org.apache.jena.iri.IRIFactory) Test(org.junit.Test)

Example 20 with IRI

use of org.apache.jena.iri.IRI in project jena by apache.

the class IRIValidatorJSON method execute.

public static 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();
}
Also used : JsonBuilder(org.apache.jena.atlas.json.JsonBuilder) Violation(org.apache.jena.iri.Violation) IRI(org.apache.jena.iri.IRI) ArrayList(java.util.ArrayList)

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