Package com.hp.hpl.jena.iri

Examples of com.hp.hpl.jena.iri.IRIFactory


        return null;
    }

    public void checkValid(CharSequence literal) throws DatatypeException {
        // TODO Find out if it is safe to put this in a field
        IRIFactory fac = new IRIFactory();
        fac.shouldViolation(true, false);
        fac.securityViolation(true, false);
        fac.dnsViolation(true, false);
        fac.mintingViolation(false, false);
        fac.useSpecificationIRI(true);
        fac.useSchemeSpecificRules("http", true);
        fac.useSchemeSpecificRules("https", true);
        fac.useSchemeSpecificRules("ftp", true);
        fac.useSchemeSpecificRules("mailto", true); // XXX broken
        fac.useSchemeSpecificRules("file", true);
        fac.useSchemeSpecificRules("data", true); // XXX broken
        // XXX javascript?
        // fac.setQueryCharacterRestrictions(false);
        IRI iri;
        boolean data = false;
        try {
            CharSequencePair pair = splitScheme(literal);
            if (pair == null) {
                // no scheme or scheme is private
                iri = fac.construct(trimHtmlSpaces(literal.toString()));
            } else {
                CharSequence scheme = pair.getHead();
                CharSequence tail = pair.getTail();
                if (isWellKnown(scheme)) {
                    iri = fac.construct(trimHtmlSpaces(literal.toString()));
                } else if ("javascript".contentEquals(scheme)) {
                    // StringBuilder sb = new StringBuilder(2 +
                    // literal.length());
                    // sb.append("x-").append(literal);
                    // iri = fac.construct(sb.toString());
                    iri = null; // Don't bother user with generic IRI syntax
                    Reader reader = new BufferedReader(
                            new Utf8PercentDecodingReader(new StringReader(
                                    "function(event){" + tail.toString() + "}")));
                    // XXX CharSequenceReader
                    reader.mark(1);
                    int c = reader.read();
                    if (c != 0xFEFF) {
                        reader.reset();
                    }
                    try {
                        Context context = ContextFactory.getGlobal().enterContext();
                        context.setOptimizationLevel(0);
                        context.setLanguageVersion(Context.VERSION_1_6);
                        // -1 for lineno arg prevents Rhino from appending
                        // "(unnamed script#1)" to all error messages
                        context.compileReader(reader, null, -1, null);
                    } finally {
                        Context.exit();
                    }
                } else if ("data".contentEquals(scheme)) {
                    data = true;
                    iri = fac.construct(trimHtmlSpaces(literal.toString()));
                } else if (isHttpAlias(scheme)) {
                    StringBuilder sb = new StringBuilder(5 + tail.length());
                    sb.append("http:").append(tail);
                    iri = fac.construct(trimHtmlTrailingSpaces(sb.toString()));
                } else {
                    StringBuilder sb = new StringBuilder(2 + literal.length());
                    sb.append("x-").append(literal);
                    iri = fac.construct(trimHtmlTrailingSpaces(sb.toString()));
                }
            }
        } catch (IRIException e) {
            Violation v = e.getViolation();
            /*
 
View Full Code Here


  }
 
  public void testIRIRules_2()
  {
        Model model = ModelFactory.createDefaultModel() ;
      IRIFactory f = ARPOptions.getIRIFactoryGlobal() ;
      try {
          ARPOptions.setIRIFactoryGlobal(IRIFactory.iriImplementation()) ;
          RDFReader r =  model.getReader("RDF/XML") ;
            expected = new int[] { WARN_MALFORMED_URI , WARN_MALFORMED_URI };
          r.setErrorHandler(this);
View Full Code Here

        return new JUnit4TestAdapter(Additional.class) ;
    }
   
    @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/") ;
    }
View Full Code Here

       test(iri2, "http://a/b/c/") ;
    }
   
    @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") ;
    }
View Full Code Here

    super(s);
  }

 
  public void testRelativizeFrag1() {
    IRIFactory f = IRIFactory.jenaImplementation();
    IRI base = f.create("http://example.org/somefolder/mybase.rdf");
    IRI frag = f.create("http://example.org#foo");
    IRI rel = base.relativize(frag);
    assertEquals(frag,rel);
//    System.err.println(rel.toString());
    IRI back = base.resolve(rel);
    assertEquals(frag,back);
View Full Code Here

    IRI back = base.resolve(rel);
    assertEquals(frag,back);
  }

  public void testRelativizeFrag2() {
    IRIFactory f = IRIFactory.jenaImplementation();
    IRI base = f.create("http://example.org/somefolder/mybase.rdf");
    IRI frag = f.create("http://example.org/#foo");
    IRI rel = base.relativize(frag);
    assertEquals("/#foo",rel.toString());
    IRI back = base.resolve(rel);
    assertEquals(frag,back);
  }
View Full Code Here

    IRI back = base.resolve(rel);
    assertEquals(frag,back);
  }
 
  public void testXPointer() {
    IRIFactory f = IRIFactory.jenaImplementation();
    IRI base = f.create("http://example.org/");
    IRI frag = base.resolve("http://eg.com/test.txt#xpointer(/unit[5])");
    Iterator<Violation> it = frag.violations(false);
        assertTrue(it.hasNext()) ;

//    while (it.hasNext()) {
View Full Code Here

//      System.err.println(it.next().getLongMessage());
//    }
   
  }
  public void testNotIDN() {
    IRIFactory f = IRIFactory.jenaImplementation();
    IRI base = f.create("http://example.org/");
    IRI frag = base.resolve("outbind://4-00000000C45F478BF9F2A048A7A59DE"+
        "3AE35F7230700D3E3AEE226D20A49A390BCD779EC5D4700"+
        "00003DB3650000D3E3AEE226D20A49A390BCD779EC5D470"+
          "00001182DB0000/www.uconnectevent.org");
    Iterator <Violation>it = frag.violations(false);
View Full Code Here

        else
            runTestSpec();
    }

    private void runTestJustSpec() {
        IRIFactory f =
            specs[specID].isSchemeSpec()?
                    IRIFactory.iriImplementation():
                    all[specID][Force.MUST];
       
        IRI iri = f.create(uri);
        if (iri.hasViolation(false)) {
            if (good) fail("Unexpected violation found: "+
            ((iri.violations(false).next())).codeName()
           
            );
View Full Code Here

    }

 

    private void runTestErrorCode() {
        IRIFactory f = new IRIFactory();
        f.setIsError(violation.getCode(), true);

        runTest(f,
                true,
                false,
                "Just this error");
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.iri.IRIFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.