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);
}
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);
}
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;
}
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;
}
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);
}
Aggregations