Package org.apache.jena.iri

Examples of org.apache.jena.iri.IRI


  /*
   * No exception thrown by this method.
   */
  static private IRI resolveIRI(String relStr, String baseStr) {
    IRI i = factory.create(relStr);
    if (i.isAbsolute())
      // removes excess . segments
      return cwd.create(i);

    IRI base = factory.create(baseStr);

    if ("file".equalsIgnoreCase(base.getScheme()))
      return cwd.create(base).create(i);
    return base.create(i);
  }
View Full Code Here


        a JenaException that encapsulates a MalformedURIException. There doesn't
        appear to be a convenient URI.checkGood() kind of method, alas.
     */
    private String checkURI( String uri ) {
        if (demandGoodURIs) {
            IRI iri = factory.create( uri );
           
            if (iri.hasViolation(false) )
            throw new BadURIException( "Only well-formed absolute URIrefs can be included in RDF/XML output: "
                     + (iri.violations(false).next()).getShortMessage());
        }
            
           
        return uri;
    }
View Full Code Here

    @Override
    public AbsXMLContext withBase(XMLHandler forErrors, String b)
            throws SAXParseException {
        TaintImpl taintB = new TaintImpl();
        IRI newB = resolveAsURI(forErrors, taintB, b, false);
        if (newB.isRelative() )
            return new XMLBaselessContext(forErrors,errno,newB.create(""));
       
        if (newB.hasViolation(false))
            return new XMLBaselessContext(forErrors,ERR_RESOLVING_AGAINST_MALFORMED_BASE,newB);
        return new XMLContext(keepDocument(forErrors), document, newB
                .create(""), taintB, lang, langTaint);
    }
View Full Code Here

   * @param str The fully expanded URI
   */
  protected void checkIdSymbol(Taint taintMe, AbsXMLContext ctxt, String str)
    throws SAXParseException {
    if (arp.idsUsed != null) {
      IRI uri = ctxt.uri;
            Map<String,ARPLocation> idsUsedForBase = idsUsed().get(uri);
      if (idsUsedForBase == null) {
        idsUsedForBase = new HashMap<String, ARPLocation>();
        idsUsed().put(uri, idsUsedForBase);
      }
View Full Code Here

    public XMLHandler getXMLHandler() {
        return arp;
    }

    protected String resolve(Taint taintMe,AbsXMLContext x, String uri) throws SAXParseException {
        IRI ref = x.resolveAsURI(arp,taintMe,uri);
//        checkBadURI(taintMe,ref);
        return ref.toString();
    }
View Full Code Here

        if (uri == null || uri.equals(""))
            localName = "";
        else
//            try
        {
                IRI u = BaseXMLWriter.factory.create(uri);
                u = u.create("");
                localName = u.toString();
            }
//        catch (MalformedURIException e) {
//                throw new BadURIException(uri, e);
//            }
    }
View Full Code Here

    private void checkNamespaceURI(String uri) throws SAXParseException {
        ((Frame) frame).checkEncoding(null,uri);
        if (uri.length() != 0)
             {
                IRI u = iriFactory().create(uri);
//                if (u.isVeryBad()) {
//                    warning(null,
//                            WARN_BAD_NAMESPACE_URI,
//                            "The namespace URI: <"
//                                    + uri
//                                    + "> is not well formed.");
//                    return;
//                
//                }
                if (!u.isAbsolute()) {
                    warning(null,
                            WARN_RELATIVE_NAMESPACE_URI_DEPRECATED,
                            "The namespace URI: <"
                                    + uri
                                    + "> is relative. Such use has been deprecated by the W3C, and may result in RDF interoperability failures. Use an absolute namespace URI.");
                }
                try {
                    if (!u.toASCIIString().equals(u.toString()))
                        warning(null,
                                WARN_BAD_NAMESPACE_URI,
                                "Non-ascii characters in a namespace URI may not be completely portable: <"
                                        + u.toString()
                                        + ">. Resulting RDF URI references are legal.");
                } catch (MalformedURLException e) {
                    warning(null,
                            WARN_BAD_NAMESPACE_URI,
                            "toAscii failed for namespace URI: <"
                                    + u.toString()
                                    + ">. " + e.getMessage());
              }

                if (uri.startsWith(rdfns) && !uri.equals(rdfns))
                    warning(null,WARN_BAD_RDF_NAMESPACE_URI, "Namespace URI ref <"
View Full Code Here

     */
    public static URIReference resolve(Frame f, AbsXMLContext ctxt, String uri)
            throws SAXParseException {

        Taint taintMe = new TaintImpl();
        IRI iri = ctxt.resolveAsURI(f.arp,taintMe,uri);
        f.checkEncoding(taintMe,uri);

        URIReference rslt = new URIReference(iri.toString());
        if (taintMe.isTainted())
            rslt.taint();
        return rslt;
    }
View Full Code Here

    public static URIReference fromQName(Frame f, String ns, String local)
            throws SAXParseException {
        URIReference rslt = new URIReference(ns + local);
        f.checkEncoding(rslt,local);
        // TODO: not for 2.3 move some of the check upwards ...
        IRI iri = f.arp.iriFactory().create(ns+local);
        AbsXMLContext.checkURI(f.arp,rslt,iri);
        return rslt;
    }
View Full Code Here

            String prefix = peekToken().getImage() ;
            nextToken() ;
            if ( ! lookingAt(IRI) )
                exception(peekToken(), "@prefix requires an IRI (found '"+peekToken()+"')") ;
            String iriStr = peekToken().getImage() ;
            IRI iri = profile.makeIRI(iriStr, currLine, currCol) ;
            profile.getPrologue().getPrefixMap().add(prefix, iri) ;
            nextToken() ;
            expect("PREFIX directive not terminated by a dot", DOT) ;
        }
View Full Code Here

TOP

Related Classes of org.apache.jena.iri.IRI

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.