本文整理汇总了Java中com.hp.hpl.jena.sparql.core.DatasetGraph.add方法的典型用法代码示例。如果您正苦于以下问题:Java DatasetGraph.add方法的具体用法?Java DatasetGraph.add怎么用?Java DatasetGraph.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hp.hpl.jena.sparql.core.DatasetGraph
的用法示例。
在下文中一共展示了DatasetGraph.add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: save
import com.hp.hpl.jena.sparql.core.DatasetGraph; //导入方法依赖的package包/类
/**
* Method to save the nanopub.
* @param f Receives the file.
* @throws Exception It can throw an exception.
*/
public void save(String f) throws Exception {
this.quads = this.getAllQuads();
if (quads == null) {
throw new Exception(
"Quad list is null. Do you call createNanoPub() first?");
}
if (quads.size() == 0) {
throw new Exception("Quad list is empty.");
}
Dataset ds = TDBFactory.createDataset();
DatasetGraph dsg = ds.asDatasetGraph();
for (int i = 0; i < quads.size(); i++) {
dsg.add(quads.get(i));
}
RDFDataMgr.write(new FileOutputStream(new File(f)), dsg,
RDFFormat.NQUADS);
}
示例2: load
import com.hp.hpl.jena.sparql.core.DatasetGraph; //导入方法依赖的package包/类
@Override
public void load(
final SolrQueryRequest request,
final SolrQueryResponse response,
final ContentStream stream,
final UpdateRequestProcessor processor) throws Exception {
final PipedRDFIterator<Quad> iterator = new PipedRDFIterator<Quad>();
final StreamRDF inputStream = new PipedQuadsStream(iterator);
executor.submit(new Runnable() {
@Override
public void run() {
try {
RDFDataMgr.parse(
inputStream,
stream.getStream(),
RDFLanguages.contentTypeToLang(stream.getContentType()));
} catch (final IOException exception) {
throw new SolrException(ErrorCode.SERVER_ERROR, exception);
}
}
});
final DatasetGraph dataset = new LocalDatasetGraph(request, response);
while (iterator.hasNext()) {
dataset.add(iterator.next());
}
}
示例3: insertIdentity
import com.hp.hpl.jena.sparql.core.DatasetGraph; //导入方法依赖的package包/类
private static void insertIdentity (DatasetGraph g, Node e1, Node e2){
g.add(identityGraphNode, e1, identityNode, e2);
}