Search in sources :

Example 21 with IRI

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

the class IRIValidatorHTML method executeHTML.

public static void executeHTML(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 22 with IRI

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

the class CheckerIRI method checkURI.

// abstract
public final boolean checkURI(Node node, long line, long col) {
    if (cache != null && cache.containsKey(node))
        return true;
    // always works - no exceptions.
    IRI iri = iriFactory.create(node.getURI());
    boolean b = checkIRI(iri, line, col);
    // If OK, put in cache.
    if (cache != null && b)
        cache.put(node, iri);
    return b;
}
Also used : IRI(org.apache.jena.iri.IRI)

Example 23 with IRI

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

the class LangTurtleBase method directiveBase.

protected final void directiveBase() {
    Token token = peekToken();
    if (!lookingAt(IRI))
        exception(token, "@base requires an IRI (found '" + token + "')");
    String baseStr = token.getImage();
    IRI baseIRI = profile.makeIRI(baseStr, currLine, currCol);
    emitBase(baseIRI.toString());
    nextToken();
    IRIResolver newResolver = IRIResolver.create(baseIRI);
    profile.setIRIResolver(newResolver);
}
Also used : IRI(org.apache.jena.riot.tokens.TokenType.IRI) IRI(org.apache.jena.iri.IRI) Token(org.apache.jena.riot.tokens.Token)

Example 24 with IRI

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

the class ParserSupport method checkIdSymbol.

/**
	 * @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<>();
            idsUsed().put(uri, idsUsedForBase);
        }
        ARPLocation prev = idsUsedForBase.get(str);
        if (prev != null) {
            arp.warning(taintMe, WARN_REDEFINITION_OF_ID, "Redefinition of ID: " + str);
            arp.warning(taintMe, WARN_REDEFINITION_OF_ID, prev, "Previous definition of '" + str + "'.");
        } else {
            idsUsedForBase.put(str, arp.location());
            arp.idsUsedCount++;
            if (arp.idsUsedCount > 10000) {
                arp.idsUsed = null;
                arp.warning(taintMe, WARN_BIG_FILE, "Input is large. Switching off checking for illegal reuse of rdf:ID's.");
            }
        }
    }
    checkID_XMLName(taintMe, str);
    checkEncoding(taintMe, str);
}
Also used : IRI(org.apache.jena.iri.IRI)

Example 25 with IRI

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

the class URIReference method resolve.

/**
     * 
     * @param f
     *            A frame for error reporting. AbsXMLContext of frame is ignored.
     * @param ctxt
     *            The XML context for the base URI
     * @param uri
     *            Input string, may be relative etc.
     * @return The resolved URI
     * @throws SAXParseException
     */
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;
}
Also used : IRI(org.apache.jena.iri.IRI)

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