当前位置: 首页>>代码示例>>Java>>正文


Java NodeIterator.close方法代码示例

本文整理汇总了Java中com.hp.hpl.jena.rdf.model.NodeIterator.close方法的典型用法代码示例。如果您正苦于以下问题:Java NodeIterator.close方法的具体用法?Java NodeIterator.close怎么用?Java NodeIterator.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.hp.hpl.jena.rdf.model.NodeIterator的用法示例。


在下文中一共展示了NodeIterator.close方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: describe

import com.hp.hpl.jena.rdf.model.NodeIterator; //导入方法依赖的package包/类
public void describe(Resource resource) {
	try {
	Model description = ModelFactory.createDefaultModel();
	Model seeAlsos = ModelFactory.createDefaultModel();
	Model dataModel = server.dataset().getDefaultModel();
	description.add(dataModel.listStatements(resource, null, (RDFNode) null));

	if (!server.isVocabularyResource(resource) || server.getConfig().getVocabularyIncludeInstances()) {
		description.add(dataModel.listStatements(null, null, resource));
		description.add(dataModel.listStatements(null, (Property) resource.as(Property.class), (RDFNode) null));
	}
	ResIterator rit = description.listSubjects();
	while (rit.hasNext()) {
		addSeeAlsoStatement(rit.nextResource(), seeAlsos, resource.getURI());
	}
	rit.close();
	NodeIterator nit = description.listObjects();
	while (nit.hasNext()) {
		addSeeAlsoStatement(nit.nextNode(), seeAlsos, resource.getURI());
	}
	nit.close();
	resultModel.add(description);
	resultModel.add(seeAlsos);
	} catch (RuntimeException ex) {
		ex.printStackTrace(System.out);
		throw ex;
	}
}
 
开发者ID:vaibhavkhadilkar,项目名称:D2RQ-Update,代码行数:29,代码来源:FindDescribeHandler.java

示例2: test_buildTblToTM_2

import com.hp.hpl.jena.rdf.model.NodeIterator; //导入方法依赖的package包/类
@Test
public void test_buildTblToTM_2() {
    Model r2rml = readR2RML(r2rml2);
    R2RMLSpec spec = new R2RMLSpec(r2rml);

    List<Pair<LogicalTable, TriplesMap>> expctdLtTmEntries =
            new ArrayList<Pair<LogicalTable, TriplesMap>>();

    // entry 1
    Resource expectedTMSubject1 = ResourceFactory.createResource(prefix + "TriplesMap2");
    NodeIterator tmpRes1 = r2rml.listObjectsOfProperty(expectedTMSubject1, RR.logicalTable);
    Resource expectedTblSubject1 = tmpRes1.next().asResource();
    tmpRes1.close();
    LogicalTable logTbl1 = new LogicalTable(r2rml, expectedTblSubject1);
    Pair<LogicalTable, TriplesMap> expectedLtTm1 =
            new Pair<LogicalTable, TriplesMap>(
                    logTbl1, new TriplesMap(r2rml, expectedTMSubject1));
    expctdLtTmEntries.add(expectedLtTm1);
    // entry 2
    Resource expectedTMSubject2 = ResourceFactory.createResource(prefix + "TriplesMap3");
    NodeIterator tmpRes2 = r2rml.listObjectsOfProperty(expectedTMSubject2, RR.logicalTable);
    Resource expectedTblSubject2 = tmpRes2.next().asResource();
    tmpRes2.close();
    LogicalTable logTbl2 = new LogicalTable(r2rml, expectedTblSubject2);
    Pair<LogicalTable, TriplesMap> expectedLtTm2 =
            new Pair<LogicalTable, TriplesMap>(
                    logTbl2, new TriplesMap(r2rml, expectedTMSubject2));
    expctdLtTmEntries.add(expectedLtTm2);

    int expectedNumLtTmEntries = 2;

    Map<LogicalTable, Collection<TriplesMap>> tableToTMs =
            R2RML2SMLConverter.buildTblToTM(spec);
    assertEquals(expectedNumLtTmEntries, tableToTMs.size());
    assertEquals(expectedNumLtTmEntries, tableToTMs.keySet().size());
    Set<LogicalTable> tbls = tableToTMs.keySet();
    System.out.println(tableToTMs.values());
    System.out.println(expctdLtTmEntries);
    Collection<TriplesMap> triplesMaps = new ArrayList<TriplesMap>();
    for (Collection<TriplesMap> tMs : tableToTMs.values()) {
        triplesMaps.addAll(tMs);
    }
    for (Pair<LogicalTable, TriplesMap> expctdVal : expctdLtTmEntries) {

        assertTrue(tbls.contains(expctdVal.first));
        assertTrue(triplesMaps.contains(expctdVal.second));
    }
}
 
开发者ID:AKSW,项目名称:sml-converters,代码行数:49,代码来源:R2RML2SMLConverterTest.java

示例3: test_buildTblToTM_3

import com.hp.hpl.jena.rdf.model.NodeIterator; //导入方法依赖的package包/类
@Test
public void test_buildTblToTM_3() {
    Model r2rml = readR2RML(r2rml3);
    R2RMLSpec spec = new R2RMLSpec(r2rml);

    List<Pair<LogicalTable, TriplesMap>> expctdLtTmEntries =
            new ArrayList<Pair<LogicalTable,TriplesMap>>();

    // entry 1
    Resource expectedTMSubject1 = ResourceFactory.createResource(prefix + "TriplesMap4");
    NodeIterator tmpRes1 = r2rml.listObjectsOfProperty(expectedTMSubject1, RR.logicalTable);
    Resource expectedTblSubject1 = tmpRes1.next().asResource();
    tmpRes1.close();
    Pair<LogicalTable, TriplesMap> expectedLtTm1 =
            new Pair<LogicalTable, TriplesMap>(
                    new LogicalTable(r2rml, expectedTblSubject1),
                    new TriplesMap(r2rml, expectedTMSubject1));
    expctdLtTmEntries.add(expectedLtTm1);
    // entry 2
    Resource expectedTMSubject2 = ResourceFactory.createResource(prefix + "TriplesMap5");
    NodeIterator tmpRes2 = r2rml.listObjectsOfProperty(expectedTMSubject2, RR.logicalTable);
    Resource expectedTblSubject2 = tmpRes2.next().asResource();
    tmpRes2.close();
    Pair<LogicalTable, TriplesMap> expectedLtTm2 =
            new Pair<LogicalTable, TriplesMap>(
                    new LogicalTable(r2rml, expectedTblSubject2),
                    new TriplesMap(r2rml, expectedTMSubject2));
    expctdLtTmEntries.add(expectedLtTm2);
    // entry 3
    Resource expectedTMSubject3 = ResourceFactory.createResource(prefix + "TriplesMap6");
    NodeIterator tmpRes3 = r2rml.listObjectsOfProperty(expectedTMSubject2, RR.logicalTable);
    Resource expectedTblSubject3 = tmpRes3.next().asResource();
    tmpRes2.close();
    Pair<LogicalTable, TriplesMap> expectedLtTm3 =
            new Pair<LogicalTable, TriplesMap>(
                    new LogicalTable(r2rml, expectedTblSubject3),
                    new TriplesMap(r2rml, expectedTMSubject3));
    expctdLtTmEntries.add(expectedLtTm3);

    int expectedNumLtTmEntries = 3;

    Map<LogicalTable, Collection<TriplesMap>> tableToTMs =
            R2RML2SMLConverter.buildTblToTM(spec);

    assertEquals(expectedNumLtTmEntries, tableToTMs.size());
    assertEquals(expectedNumLtTmEntries, tableToTMs.keySet().size());
    Set<LogicalTable> tbls = tableToTMs.keySet();
    Collection<TriplesMap> triplesMaps = new ArrayList<TriplesMap>();
    for (Collection<TriplesMap> tMs : tableToTMs.values()) {
        triplesMaps.addAll(tMs);
    }
    for (Pair<LogicalTable, TriplesMap> expctdVal : expctdLtTmEntries) {
        assertTrue(tbls.contains(expctdVal.first));
        assertTrue(triplesMaps.contains(expctdVal.second));
    }
}
 
开发者ID:AKSW,项目名称:sml-converters,代码行数:57,代码来源:R2RML2SMLConverterTest.java


注:本文中的com.hp.hpl.jena.rdf.model.NodeIterator.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。