Examples of IRIFactory


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

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

  }
 
  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

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

        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

Examples of org.apache.jena.iri.IRIFactory

            }
        }
       
        if ( str.equals("IRI-RULES") )
        {
            IRIFactory old = options.getIRIFactory() ;
            if ( v.equals("STRICT") )   { options.setIRIFactory(IRIFactory.semanticWebImplementation()) ; }
            else if ( v.equals("IRI") ) { options.setIRIFactory(IRIFactory.iriImplementation()) ; }
            else if ( v.equals("LAX") ) { options.setIRIFactory(IRIFactory.jenaImplementation()) ; }
            else
                eh.error(new IllegalArgumentException(
View Full Code Here

Examples of org.apache.jena.iri.IRIFactory

    public static void main(String[] args) throws Exception {
        /// turn off the "No BGP optimizer warning"
        TDB.setOptimizerWarningFlag(false);

        final IRIFactory iriFactory = IRIFactory.semanticWebImplementation();

        final String DATASET_DIR_NAME = "data0";
        final Dataset data0 = TDBFactory.createDataset( DATASET_DIR_NAME );

        // show the currently registered names
        for (Iterator<String> it = data0.listNames(); it.hasNext(); ) {
            out.println("NAME="+it.next());
        }

        out.println("getting named model...");
        /// this is the OWL portion
        final Model model = data0.getNamedModel( MY_NS );
        out.println("Model := "+model);

        out.println("getting graph...");
        /// this is the DATA in that MODEL
        final Graph graph = model.getGraph();
        out.println("Graph := "+graph);

        if (graph.isEmpty()) {
            final Resource product1 = model.createResource(
                    iriFactory.construct( MY_NS +"product/1" )
                        .toString() );

            final Property hasName = model.createProperty( MY_NS, "#hasName");
            final Statement stmt = model.createStatement(
                    product1, hasName, model.createLiteral("Beach Ball","en") );
View Full Code Here

Examples of org.apache.jena.iri.IRIFactory

public class iri
{

    public static void main(String[] args)
    {
        IRIFactory iriFactory = IRIFactory.iriImplementation() ;
        iriFactory = IRIResolver.iriFactory ;
       
        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.isRelative()) ;

            Iterator<Violation> vIter = iri.violations(true) ;
View Full Code Here

Examples of org.apache.jena.iri.IRIFactory

  }
 
  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

Examples of org.apache.jena.iri.IRIFactory

  }
 
  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

Examples of org.apache.jena.iri.IRIFactory

            }
        }
       
        if ( str.equals("IRI-RULES") )
        {
            IRIFactory old = options.getIRIFactory() ;
            if ( v.equals("STRICT") )   { options.setIRIFactory(IRIFactory.semanticWebImplementation()) ; }
            else if ( v.equals("IRI") ) { options.setIRIFactory(IRIFactory.iriImplementation()) ; }
            else if ( v.equals("LAX") ) { options.setIRIFactory(IRIFactory.jenaImplementation()) ; }
            else
                eh.error(new IllegalArgumentException(
View Full Code Here

Examples of org.apache.jena.iri.IRIFactory

        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
TOP
Copyright © 2018 www.massapi.com. 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.