本文整理了Java中org.apache.jena.rdf.model.Model.size()
方法的一些代码示例,展示了Model.size()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Model.size()
方法的具体详情如下:
包路径:org.apache.jena.rdf.model.Model
类名称:Model
方法名:size
[英]size will return the number of statements in a concrete model, for a virtualized model such as one created by an inference engine, it will return an estimated lower bound for the numberof statements in the model but it is possible for a subsequent listStatements on such a model to discover more statements than size() indicated.
[中]size将返回一个具体模型中的语句数,对于一个虚拟化模型,例如一个由推理机创建的模型,它将返回模型中语句数的估计下限,但这样一个模型上的后续listStatements可能会发现比size()指示的更多的语句。
代码示例来源:origin: apache/jena
@Override
public long size() throws ReadDeniedException, AuthenticationRequiredException {
checkRead();
return holder.getBaseItem().size();
}
代码示例来源:origin: apache/jena
public void testAddDuplicateLeavesSizeSame()
{
final Statement s = model.createStatement(S, RDF.value, "something");
model.add(s);
final long size = model.size();
model.add(s);
Assert.assertEquals(size, model.size());
}
代码示例来源:origin: apache/jena
public void testAddByModel()
{
ModelHelper.modelAdd(model, "a P b; c P d; x Q 1; y Q 2");
model2.add(model);
Assert.assertEquals(model.size(), model2.size());
assertSameStatements(model, model2);
}
代码示例来源:origin: apache/jena
public void testXMLProperty() throws IOException {
Model m = createMemModel();
InputStream in = new FileInputStream("testing/arp/xml-prop.rdf");
m.read(in, "");
assertEquals(1, m.size());
}
代码示例来源:origin: org.apache.jena/jena-core
public void testXMLProperty() throws IOException {
Model m = createMemModel();
InputStream in = new FileInputStream("testing/arp/xml-prop.rdf");
m.read(in, "");
assertEquals(1, m.size());
}
代码示例来源:origin: apache/jena
public void testBulkRemoveSelf()
{
final Model m = ModelHelper.modelWithStatements(this,
"they sing together; he sings alone");
m.remove(m);
Assert.assertEquals("", 0, m.size());
}
代码示例来源:origin: apache/jena
@Test public void blankNodes2()
{
// Duplicate.
String s = "_:a <http://example/p> 'foo' . _:a <http://example/p> 'foo' ." ;
StringReader r = new StringReader(s) ;
Model m = ModelFactory.createDefaultModel() ;
RDFDataMgr.read(m, r, null, RDFLanguages.TURTLE) ;
assertEquals(1, m.size()) ;
}
代码示例来源:origin: apache/jena
private static void jenaread(String dataurl) {
dataurl = filename(dataurl);
Model m = ModelFactory.createDefaultModel();
m.read(dataurl);
assertTrue(m.size() != 0);
}
代码示例来源:origin: apache/jena
protected void testRemoveAll( String statements )
{
modelAdd( model, statements );
assertSame( model, model.removeAll() );
assertEquals( "model should have size 0 following removeAll(): ", 0, model.size() );
}
代码示例来源:origin: apache/jena
@Test public void trans_02() {
Model model = dataset.getDefaultModel() ;
Txn.executeWrite(dataset, ()->{
RDFDataMgr.read(model, new StringReader(data2), null, Lang.TURTLE) ;
}) ;
Txn.executeRead(dataset, ()->{
assertEquals(4, model.size()) ;
}) ;
}
代码示例来源:origin: apache/jena
@Test public void insert_where_01() {
Model m = ModelFactory.createDefaultModel();
Resource anon = m.createResource();
anon.addProperty(RDF.type, OWL.Thing);
assertEquals(1, m.size());
UpdateRequest req = UpdateFactory.create("INSERT { ?s ?p ?o } WHERE { ?o ?p ?s }");
UpdateAction.execute(req, m);
assertEquals(2, m.size());
assertEquals(1, m.listStatements(anon, null, (RDFNode)null).toList().size());
assertEquals(1, m.listStatements(null, null, anon).toList().size());
}
代码示例来源:origin: apache/jena
private static void read(String dataName)
{
try {
StreamManager.setGlobal(streamMgrDir) ;
Model m = ModelFactory.createDefaultModel() ;
RDFDataMgr.read(m, dataName) ;
assertNotEquals("Read "+dataName, 0, m.size()) ;
} finally {
StreamManager.setGlobal(streamMgrStd) ;
}
}
}
代码示例来源:origin: apache/jena
@Test public void optionalDotInBase()
{
Model model = ModelFactory.createDefaultModel() ;
StringReader reader = new StringReader("@base <http://example/> <x> <p> <o> .") ;
RDFDataMgr.read(model, reader, null, RDFLanguages.TURTLE) ;
assertEquals(1, model.size()) ;
Resource r = model.createResource("http://example/x") ;
Property p = model.createProperty("http://example/p") ;
assertTrue(model.contains(r,p)) ;
}
代码示例来源:origin: org.apache.jena/jena-core
public void testReadLocalNTriple() {
model.read(getInputStream("TestReaders.nt"), "", "N-TRIPLE") ;
Assert.assertEquals("Wrong size model", 5, model.size()) ;
final StmtIterator iter = model.listStatements(null, null, "foo\"\\\n\r\tbar") ;
Assert.assertTrue("No next statement found", iter.hasNext()) ;
}
代码示例来源:origin: apache/jena
@Test public void query_construct_01() {
try ( RDFConnection conn = connection() ) {
Txn.executeWrite(conn, ()->conn.loadDataset(DIR+"data.trig"));
Txn.executeRead(conn, ()-> {
Model m = conn.queryConstruct("CONSTRUCT WHERE { ?s ?p ?o }");
assertEquals(2, m.size());
});
}
}
代码示例来源:origin: apache/jena
@Test public void special5()
{
Dataset ds = dataset() ;
//load1(ds.getDefaultModel()) ;
load1(ds.getNamedModel("http://example/graph1")) ; // Same triples, different graph
load1(ds.getNamedModel("http://example/graph2")) ;
Model m = ds.getNamedModel(unionGraph) ;
assertEquals(2, m.size()) ;
}
代码示例来源:origin: apache/jena
@Test public void special5()
{
Dataset ds = create() ;
//load1(ds.getDefaultModel()) ;
load1(ds.getNamedModel("http://example/graph1")) ; // Same triples, different graph
load1(ds.getNamedModel("http://example/graph2")) ;
Model m = ds.getNamedModel(unionGraph) ;
assertEquals(2, m.size()) ;
}
代码示例来源:origin: apache/jena
@Test
public void nt_model_1() {
Model m1 = parseToModel("<x> <p> \"abc-\\u00E9\". ");
assertEquals(1, m1.size());
Model m2 = parseToModel("<x> <p> \"abc-\\u00E9\". ");
assertTrue(m1.isIsomorphicWith(m2));
Graph g1 = SSE.parseGraph("(graph (triple <x> <p> \"abc-é\"))");
assertTrue(g1.isIsomorphicWith(m1.getGraph()));
}
代码示例来源:origin: apache/jena
@Test public void testInitialBindingsConstruct2()
{
try(QueryExecution qExec = makeQExec("CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o }")) {
QuerySolutionMap init = new QuerySolutionMap() ;
init.add("o", m.createLiteral("x1"));
qExec.setInitialBinding(init) ;
Model r = qExec.execConstruct() ;
assertTrue("Empty model", r.size() > 0 ) ;
Property p1 = m.createProperty(ns+"p1") ;
assertTrue("Empty model", r.contains(null, p1, init.get("x1"))) ;
}
}
代码示例来源:origin: apache/jena
@Test public void testInitialBindingsConstruct1()
{
try(QueryExecution qExec = makeQExec("CONSTRUCT {?s ?p ?z} {?s ?p 'x1'}")) {
QuerySolutionMap init = new QuerySolutionMap() ;
init.add("z", m.createLiteral("zzz"));
qExec.setInitialBinding(init) ;
Model r = qExec.execConstruct() ;
assertTrue("Empty model", r.size() > 0 ) ;
Property p1 = m.createProperty(ns+"p1") ;
assertTrue("Empty model", r.contains(null,p1, init.get("z"))) ;
}
}
内容来源于网络,如有侵权,请联系作者删除!