当前位置: 首页>>代码示例>>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;未经允许,请勿转载。