當前位置: 首頁>>代碼示例>>Java>>正文


Java Lang.N3屬性代碼示例

本文整理匯總了Java中org.apache.jena.riot.Lang.N3屬性的典型用法代碼示例。如果您正苦於以下問題:Java Lang.N3屬性的具體用法?Java Lang.N3怎麽用?Java Lang.N3使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.apache.jena.riot.Lang的用法示例。


在下文中一共展示了Lang.N3屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: writeTo

@Override
public void writeTo(Model t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType,
		MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
		throws IOException, WebApplicationException {
	
	Lang lang = null;
	
	if(mediaType.equals(KRFormat.N3_TYPE))
		lang = Lang.N3;
	else if(mediaType.equals(KRFormat.N_TRIPLE_TYPE))
		lang = Lang.NTRIPLES;
	else if(mediaType.equals(KRFormat.RDF_JSON_TYPE))
		lang = Lang.RDFJSON;
	else if(mediaType.equals(new MediaType("application", "json-ld")))
		lang = Lang.JSONLD;
	else lang = Lang.TURTLE;
	
	RDFDataMgr.write(entityStream, t, lang);
	
}
 
開發者ID:teamdigitale,項目名稱:ontonethub,代碼行數:20,代碼來源:ModelWriter.java

示例2: getLangFromType

private Lang getLangFromType(String type) {
	if(type.contains("application/x-turtle")||type.contains("text/turtle"))
		return Lang.TTL;
	if(type.contains("application/rdf+xml")||type.contains("application/xml"))
		return Lang.RDFXML;
	if(type.contains("text/plain"))
		return Lang.RDFXML;
	if(type.contains("text/rdf+n3"))
		return Lang.N3;

	return Lang.RDFXML;
}
 
開發者ID:pyvandenbussche,項目名稱:sparqles,代碼行數:12,代碼來源:DTask.java

示例3: fetch

@Override
    public File fetch(CrawleableUri uri/*, Sink sink*/) {
        int tripleCount = 0;
        String filePath = this.downloadFile(uri, "/tmp/");
        if (filePath == null) {
            return null;
//            return 0;
        }
        LOGGER.debug("{} is saved to {}", uri.toString(), filePath);
        String fileType = this.detectFileType(uri, filePath);
        LOGGER.debug("Detected file type: {}", fileType);

        if (fileType.contains("application/zip")) {
            String unzipPath = filePath + "__extracted";
            File[] files = ZipArchiver.unzip(filePath, unzipPath, "emptypassword");
            File firstFile = files[0];
            filePath = firstFile.getPath().toString();
        }

        Lang hint;
        if (matchesSerialization(uri.toString(), "rdf")) {
            LOGGER.debug("Detected rdf/xml serialization.");
            hint = Lang.RDFXML;
        } else if (matchesSerialization(uri.toString(), "ttl")) {
            LOGGER.debug("Detected ttl serialization.");
            hint = Lang.TURTLE;
        } else if (matchesSerialization(uri.toString(), "nt")) {
            LOGGER.debug("Detected nt serialization.");
            hint = Lang.NT;
        } else if (matchesSerialization(uri.toString(), "n3")) {
            hint = Lang.N3;
            LOGGER.debug("Detected n3 serialization.");
        } else {
            LOGGER.error("Could not detect serialization for {}. Skipping.", uri.toString());
//            return tripleCount;
            return null;
        }
        PipedRDFIterator<Triple> iterator = new PipedRDFIterator<>();
        final PipedRDFStream<Triple> inStream = new PipedTriplesStream(iterator);

        ExecutorService executor = Executors.newSingleThreadExecutor();
        final String finalFilePath = filePath;
        Runnable parser = new Runnable() {
            @Override
            public void run() {
                LOGGER.debug("Parsing {}", finalFilePath);
                RDFDataMgr.parse(inStream, finalFilePath, hint, null);
            }
        };

        executor.submit(parser);

//        LOGGER.debug("Opening sink for {}", filePath);
//        sink.openSinkForUri(uri);
        while (iterator.hasNext()) {
            Triple next = iterator.next();
//            sink.addTriple(uri, next);
            ++tripleCount;
        }
//        sink.closeSinkForUri(uri);
//        return tripleCount;

        return null;
    }
 
開發者ID:dice-group,項目名稱:Squirrel,代碼行數:64,代碼來源:DumpFetcher.java

示例4: getLanguage

protected Lang getLanguage(String href) {
    String language = getOption(_language, (String) null);

    if (language == null && href != null) {
        String ext = null;
        if (href.contains(".")) {
            int pos = href.lastIndexOf(".");
            ext = href.substring(pos);
        }

        if (ext == null) {
            // nevermind
        } else if (".rdf".equals(ext)) {
            language = "rdf/xml";
        } else if (".ttl".equals(ext)) {
            language = "turtle";
        } else if (".json".equals(ext)) {
            language = "rdf/json";
        } else if (".n3".equals(ext)) {
            language = "n3";
        } else if (".nt".equals(ext)) {
            language = "ntriples";
        } else if (".nq".equals(ext)) {
            language = "nquads";
        } else if (".trig".equals(ext)) {
            language = "trig";
        }
    }

    Lang lang = null;
    if ("rdf/xml".equals(language)) {
        lang = Lang.RDFXML;
    } else if ("turtle".equals(language)) {
        lang = Lang.TURTLE;
    } else if ("rdf/json".equals(language)) {
        lang = Lang.RDFJSON;
    } else if ("n3".equals(language)) {
        lang = Lang.N3;
    } else if ("ntriples".equals(language)) {
        lang = Lang.NTRIPLES;
    } else if ("nquads".equals(language)) {
        lang = Lang.NQUADS;
    } else if ("trig".equals(language)) {
        lang = Lang.TRIG;
    }

    if (lang == null) {
        throw new XProcException("Could not deduce language for RDFLoad data: " + language);
    }

    return lang;
}
 
開發者ID:ndw,項目名稱:xmlcalabash1-rdf,代碼行數:52,代碼來源:RDFStep.java


注:本文中的org.apache.jena.riot.Lang.N3屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。