本文整理汇总了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);
}
示例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();
}
示例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();
}