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


Java Model.close方法代碼示例

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


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

示例1: parse

import com.hp.hpl.jena.rdf.model.Model; //導入方法依賴的package包/類
/**
 * Parse RDF input as string
 *
 * @param input RDF values as String
 * @return an {@link Request} object which contains information about latitude, longitude and date
 * @throws IllegalStateException if RDF is not literal
 * @throws NullPointerException  if input is null
 */
public static Request parse(String input) {
    Objects.requireNonNull(input);
    Model model = ModelFactory.createDefaultModel();
    model.read(new ByteArrayInputStream(input.getBytes()), null, "TURTLE");

    Map<String, Object> map = new HashMap<>();
    model.listStatements().forEachRemaining(statement -> {
        RDFNode rdfNode = statement.getObject();
        if (rdfNode.isLiteral()) {
            try {
                map.put(statement.getPredicate().getLocalName(), statement.getObject().asLiteral().getValue());
            } catch (Exception e) {
                LOGGER.error("RDF statement is not literal");
                throw new IllegalStateException(e.getMessage());
            }
        }
    });

    model.close();
    return getDataFromMap(map);
}
 
開發者ID:IKB4Stream,項目名稱:IKB4Stream,代碼行數:30,代碼來源:RDFParser.java

示例2: main

import com.hp.hpl.jena.rdf.model.Model; //導入方法依賴的package包/類
public static void main(String[] args) {
	// Load assembler specification from file
	Model assemblerSpec = FileManager.get().loadModel("doc/example/assembler.ttl");
	
	// Get the model resource
	Resource modelSpec = assemblerSpec.createResource(assemblerSpec.expandPrefix(":myModel"));
	
	// Assemble a model
	Model m = Assembler.general.openModel(modelSpec);
	
	// Write it to System.out
	m.write(System.out);

	m.close();
}
 
開發者ID:d2rq,項目名稱:r2rml-kit,代碼行數:16,代碼來源:AssemblerExample.java

示例3: main

import com.hp.hpl.jena.rdf.model.Model; //導入方法依賴的package包/類
public static void main(String[] args) {
	// First, let's set up an in-memory HSQLDB database,
	// load a simple SQL database into it, and generate
	// a default mapping for this database using the
	// W3C Direct Mapping
	SystemLoader loader = new SystemLoader();
	loader.setJdbcURL("jdbc:hsqldb:mem:test");
	loader.setStartupSQLScript("doc/example/simple.sql");
	loader.setGenerateW3CDirectMapping(true);
	CompiledMapping mapping = loader.getMapping();

	// Print some internal stuff that shows how D2RQ maps the
	// database to RDF triples
	for (TripleRelation internal: mapping.getTripleRelations()) {
		System.out.println(internal);
	}

	// Write the contents of the virtual RDF model as N-Triples
	Model model = loader.getModelD2RQ();
	model.write(System.out, "N-TRIPLES");

	// Important -- close the model!
	model.close();
	
	// Now let's load an example mapping file that connects to
	// a MySQL database
	loader = new SystemLoader();
	loader.setMappingFileOrJdbcURL("doc/example/mapping-iswc.ttl");
	loader.setFastMode(true);
	loader.setSystemBaseURI("http://example.com/");

	// Get the virtual model and run a SPARQL query
	model = loader.getModelD2RQ();
	ResultSet rs = QueryExecutionFactory.create(
			"SELECT * {?s ?p ?o} LIMIT 10", model).execSelect();
	while (rs.hasNext()) {
		System.out.println(rs.next());
	}
	
	// Important -- close the model!
	model.close();
}
 
開發者ID:d2rq,項目名稱:r2rml-kit,代碼行數:43,代碼來源:SystemLoaderExample.java


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