Search in sources :

Example 11 with Lang

use of org.apache.jena.riot.Lang in project jena by apache.

the class rdfcompare method read.

protected static void read(Model model, String in, String langStr, String base) {
    Lang lang = null;
    if (langStr != null)
        lang = RDFLanguages.nameToLang(langStr);
    RDFDataMgr.read(model, in, base, lang);
}
Also used : Lang(org.apache.jena.riot.Lang)

Example 12 with Lang

use of org.apache.jena.riot.Lang in project jena by apache.

the class QueryEngineHTTP method execQuads.

private Iterator<Quad> execQuads() {
    Pair<InputStream, Lang> p = execConstructWorker(datasetContentType);
    InputStream in = p.getLeft();
    Lang lang = p.getRight();
    // Base URI?
    return RDFDataMgr.createIteratorQuads(in, lang, null);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Lang(org.apache.jena.riot.Lang)

Example 13 with Lang

use of org.apache.jena.riot.Lang in project jena by apache.

the class QueryEngineHTTP method execModel.

private Model execModel(Model model) {
    Pair<InputStream, Lang> p = execConstructWorker(modelContentType);
    InputStream in = p.getLeft();
    Lang lang = p.getRight();
    try {
        RDFDataMgr.read(model, in, lang);
    } finally {
        this.close();
    }
    return model;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Lang(org.apache.jena.riot.Lang)

Example 14 with Lang

use of org.apache.jena.riot.Lang in project jena by apache.

the class QueryEngineHTTP method setDatasetContentType.

public void setDatasetContentType(String contentType) {
    // Check that this is a valid setting
    Lang lang = RDFLanguages.contentTypeToLang(contentType);
    if (lang == null)
        throw new IllegalArgumentException("Given Content Type '" + contentType + "' is not supported by RIOT");
    if (!RDFLanguages.isQuads(lang))
        throw new IllegalArgumentException("Given Content Type '" + contentType + "' is not a RDF Dataset format");
    datasetContentType = contentType;
}
Also used : Lang(org.apache.jena.riot.Lang)

Example 15 with Lang

use of org.apache.jena.riot.Lang in project jena by apache.

the class QueryEngineHTTP method execConstructWorker.

private Pair<InputStream, Lang> execConstructWorker(String contentType) {
    checkNotClosed();
    HttpQuery httpQuery = makeHttpQuery();
    httpQuery.setAccept(contentType);
    InputStream in = httpQuery.exec();
    // Don't assume the endpoint actually gives back the content type we
    // asked for
    String actualContentType = httpQuery.getContentType();
    httpResponseContentType = actualContentType;
    // the server returned the type we asked for
    if (actualContentType == null || actualContentType.equals("")) {
        actualContentType = WebContent.defaultDatasetAcceptHeader;
    }
    Lang lang = RDFLanguages.contentTypeToLang(actualContentType);
    if (!RDFLanguages.isQuads(lang) && !RDFLanguages.isTriples(lang))
        throw new QueryException("Endpoint returned Content Type: " + actualContentType + " which is not a valid RDF syntax");
    return Pair.create(in, lang);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Lang(org.apache.jena.riot.Lang)

Aggregations

Lang (org.apache.jena.riot.Lang)41 InputStream (java.io.InputStream)10 CmdException (jena.cmd.CmdException)8 IOException (java.io.IOException)6 Model (org.apache.jena.rdf.model.Model)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 GZIPInputStream (java.util.zip.GZIPInputStream)4 ServletOutputStream (javax.servlet.ServletOutputStream)4 ContentType (org.apache.jena.atlas.web.ContentType)4 MediaType (org.apache.jena.atlas.web.MediaType)4 RiotException (org.apache.jena.riot.RiotException)4 Dataset (org.apache.jena.query.Dataset)3 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)3 ArrayList (java.util.ArrayList)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 FileItemIterator (org.apache.commons.fileupload.FileItemIterator)2 FileItemStream (org.apache.commons.fileupload.FileItemStream)2 ServletFileUpload (org.apache.commons.fileupload.servlet.ServletFileUpload)2 BaseTest (org.apache.jena.atlas.junit.BaseTest)2