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


Java RDF类代码示例

本文整理汇总了Java中com.hp.hpl.jena.vocabulary.RDF的典型用法代码示例。如果您正苦于以下问题:Java RDF类的具体用法?Java RDF怎么用?Java RDF使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RDF类属于com.hp.hpl.jena.vocabulary包,在下文中一共展示了RDF类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import com.hp.hpl.jena.vocabulary.RDF; //导入依赖的package包/类
public static void main(String[] args) {
	// Set up the ModelD2RQ using a mapping file
	ModelD2RQ m = new ModelD2RQ("file:doc/example/mapping-iswc.ttl");
	
	// Find anything with an rdf:type of iswc:InProceedings
	StmtIterator paperIt = m.listStatements(null, RDF.type, ISWC.InProceedings);
	
	// List found papers and print their titles
	while (paperIt.hasNext()) {
		Resource paper = paperIt.nextStatement().getSubject();
		System.out.println("Paper: " + paper.getProperty(DC.title).getString());
		
		// List authors of the paper and print their names
		StmtIterator authorIt = paper.listProperties(DC.creator);
		while (authorIt.hasNext()) {
			Resource author = authorIt.nextStatement().getResource();
			System.out.println("Author: " + author.getProperty(FOAF.name).getString());
		}
		System.out.println();
	}
	m.close();
}
 
开发者ID:d2rq,项目名称:r2rml-kit,代码行数:23,代码来源:JenaModelExample.java

示例2: getUndefinedResources

import com.hp.hpl.jena.vocabulary.RDF; //导入依赖的package包/类
public Collection<Resource> getUndefinedResources(Model model) {
	Set<Resource> result = new HashSet<Resource>();
	StmtIterator it = model.listStatements();
	while (it.hasNext()) {
		Statement stmt = it.nextStatement();
		if (stmt.getSubject().isURIResource()
				&& stmt.getSubject().getURI().startsWith(namespace)
				&& !resources.contains(stmt.getSubject())) {
			result.add(stmt.getSubject());
		}
		if (stmt.getPredicate().equals(RDF.type)) continue;
		if (stmt.getObject().isURIResource()
				&& stmt.getResource().getURI().startsWith(namespace)
				&& !resources.contains(stmt.getResource())) {
			result.add(stmt.getResource());
		}
	}
	return result;
}
 
开发者ID:d2rq,项目名称:r2rml-kit,代码行数:20,代码来源:VocabularySummarizer.java

示例3: testClassMapWithoutDuplicates

import com.hp.hpl.jena.vocabulary.RDF; //导入依赖的package包/类
@Test
public void testClassMapWithoutDuplicates() {
	sql.executeSQL("CREATE TABLE T (ID INT)");
	ClassMap cm1 = ClassMap.create(null, pattern1, mapping);
	// This asserts we have no duplicates. It's the default anyway for class maps. So we need no DISTINCT.
	cm1.setContainsDuplicates(false);
	PropertyBridge.create(null, RDF.type, cm1).setConstantValue(class1);
	// Check that we have no DISTINCT
	firstTripleRelation().getBaseTabular().accept(new OpVisitor.Default(true) {
		@Override
		public boolean visitEnter(DistinctOp table) {
			fail("There should be no Distinct(...) in " + table);
			return false;
		}
	});
	// Check that the asserted unique key is present
	assertFalse(firstTripleRelation().getBaseTabular().getUniqueKeys().isEmpty());
}
 
开发者ID:d2rq,项目名称:r2rml-kit,代码行数:19,代码来源:D2RQCompilerTest.java

示例4: setUp

import com.hp.hpl.jena.vocabulary.RDF; //导入依赖的package包/类
public void setUp() {
	this.model = ModelFactory.createDefaultModel();
	this.mapping = new Mapping();
	this.database = new Database(this.model.createResource());
	this.mapping.addDatabase(this.database);
	
	concept = createClassMap("http://example.com/concept#@@[email protected]@");
	conceptTypeBridge = createPropertyBridge(concept, RDF.type.getURI());
	conceptTypeBridge.setConstantValue(model.createResource("http://www.w3.org/2004/02/skos/core#Concept"));
	
	collection = createConstantClassMap("http://example.com/collection#MyConceptCollection");
	collectionTypeBridge = createPropertyBridge(collection, RDF.type.getURI());
	collectionTypeBridge.setConstantValue(model.createResource("http://www.w3.org/2004/02/skos/core#Collection"));

	memberBridge = createPropertyBridge(collection, "http://www.w3.org/2004/02/skos/core#member");
	memberBridge.setRefersToClassMap(concept);
	memberBridge.addCondition("c.foo = 1");
}
 
开发者ID:d2rq,项目名称:r2rml-kit,代码行数:19,代码来源:ConstantValueClassMapTest.java

示例5: testNodePrettyPrinting

import com.hp.hpl.jena.vocabulary.RDF; //导入依赖的package包/类
@Test
public void testNodePrettyPrinting() {
	assertEquals("\"foo\"", 
			PrettyPrinter.toString(Node.createLiteral("foo")));
	assertEquals("\"foo\"@en", 
			PrettyPrinter.toString(Node.createLiteral("foo", "en", null)));
	assertEquals("\"1\"^^xsd:int",
			PrettyPrinter.toString(Node.createLiteral("1", null, XSDDatatype.XSDint)));
	assertEquals("\"1\"^^xsd:int",
			PrettyPrinter.toString(Node.createLiteral("1", null, XSDDatatype.XSDint), PrefixMapping.Standard));
	assertEquals("_:foo", 
			PrettyPrinter.toString(Node.createAnon(new AnonId("foo"))));
	assertEquals("<http://example.org/>", 
			PrettyPrinter.toString(Node.createURI("http://example.org/")));
	assertEquals("<" + RDF.type.getURI() + ">", 
			PrettyPrinter.toString(RDF.type.asNode(), new PrefixMappingImpl()));
	assertEquals("rdf:type", 
			PrettyPrinter.toString(RDF.type.asNode(), PrefixMapping.Standard));
	assertEquals("?x", 
			PrettyPrinter.toString(Node.createVariable("x")));
	assertEquals("?ANY",
			PrettyPrinter.toString(Node.ANY));
}
 
开发者ID:d2rq,项目名称:r2rml-kit,代码行数:24,代码来源:PrettyPrinterTest.java

示例6: setUp

import com.hp.hpl.jena.vocabulary.RDF; //导入依赖的package包/类
public void setUp() {
	this.model = ModelFactory.createDefaultModel();
	this.mapping = new Mapping();
	this.database = new Database(this.model.createResource());
	database.useConnectedDB(new DummyDB());
	this.mapping.addDatabase(this.database);

	employees = createClassMap("http://test/[email protected]@[email protected]@");
	employees.addAlias("employees AS e");
	employees.addJoin("e.ID = foo.bar");
	employees.addCondition("e.status = 'active'");
	managerBridge = createPropertyBridge(employees, "http://terms.example.org/manager");
	managerBridge.addAlias("e AS m");
	managerBridge.setRefersToClassMap(this.employees);
	managerBridge.addJoin("e.manager = m.ID");
	
	cities = createClassMap("http://test/[email protected]@[email protected]@");
	citiesTypeBridge = createPropertyBridge(cities, RDF.type.getURI());
	citiesTypeBridge.setConstantValue(model.createResource("http://terms.example.org/City"));
	citiesNameBridge = createPropertyBridge(cities, "http://terms.example.org/name");
	citiesNameBridge.setColumn("c.name");
	countries = createClassMap("http://test/countries/@@[email protected]@");
	countries.setContainsDuplicates(true);
	countriesTypeBridge = createPropertyBridge(countries, RDF.type.getURI());
	countriesTypeBridge.setConstantValue(model.createResource("http://terms.example.org/Country"));
}
 
开发者ID:aitoralmeida,项目名称:c4a_data_repository,代码行数:27,代码来源:CompileTest.java

示例7: testNodePrettyPrinting

import com.hp.hpl.jena.vocabulary.RDF; //导入依赖的package包/类
public void testNodePrettyPrinting() {
	assertEquals("\"foo\"", 
			PrettyPrinter.toString(Node.createLiteral("foo")));
	assertEquals("\"foo\"@en", 
			PrettyPrinter.toString(Node.createLiteral("foo", "en", null)));
	assertEquals("\"1\"^^<" + XSDDatatype.XSDint.getURI() + ">",
			PrettyPrinter.toString(Node.createLiteral("1", null, XSDDatatype.XSDint)));
	assertEquals("\"1\"^^xsd:int",
			PrettyPrinter.toString(Node.createLiteral("1", null, XSDDatatype.XSDint), PrefixMapping.Standard));
	assertEquals("_:foo", 
			PrettyPrinter.toString(Node.createAnon(new AnonId("foo"))));
	assertEquals("<http://example.org/>", 
			PrettyPrinter.toString(Node.createURI("http://example.org/")));
	assertEquals("<" + RDF.type.getURI() + ">", 
			PrettyPrinter.toString(RDF.type.asNode(), new PrefixMappingImpl()));
	assertEquals("rdf:type", 
			PrettyPrinter.toString(RDF.type.asNode(), PrefixMapping.Standard));
	assertEquals("?x", 
			PrettyPrinter.toString(Node.createVariable("x")));
	assertEquals("?ANY",
			PrettyPrinter.toString(Node.ANY));
}
 
开发者ID:aitoralmeida,项目名称:c4a_data_repository,代码行数:23,代码来源:PrettyPrinterTest.java

示例8: getRelatedSubjects

import com.hp.hpl.jena.vocabulary.RDF; //导入依赖的package包/类
@Override
protected HashSet<Node> getRelatedSubjects(Node node, ExecutionContext execCxt) {
	HashSet<Node> results = new HashSet<Node>();

	Graph graph = execCxt.getActiveGraph();

	Node clazz = NodeFactory.createURI(Namespace.IFC2X3_TC1 + "IfcBuildingStorey");
	LinkedList<Storey> storeys = new LinkedList<Storey>();
	if (graph.contains(node, RDF.type.asNode(), clazz)) {
		Storey storey = new Storey(node, elevation(node, graph));
		ExtendedIterator<Triple> triples = graph.find(null, RDF.type.asNode(), clazz);
		while (triples.hasNext()) {
			Node subject = triples.next().getSubject();
			Storey s = new Storey(subject, elevation(subject, graph));
			if (s.elevation > storey.elevation) {
				addStorey(storeys, s, graph);
			}
		}
		if (storeys.size() > 0) {
			results.add(storeys.get(0).storey);
		}
	}
	return results;
}
 
开发者ID:BenzclyZhang,项目名称:BimSPARQL,代码行数:25,代码来源:HasLowerStoreyPF.java

示例9: getRelatedObjects

import com.hp.hpl.jena.vocabulary.RDF; //导入依赖的package包/类
@Override
protected HashSet<Node> getRelatedObjects(Node node, ExecutionContext execCxt) {
	HashSet<Node> results = new HashSet<Node>();

	Graph graph = execCxt.getActiveGraph();

	Node clazz = NodeFactory.createURI(Namespace.IFC2X3_TC1 + "IfcBuildingStorey");
	LinkedList<Storey> storeys = new LinkedList<Storey>();
	if (graph.contains(node, RDF.type.asNode(), clazz)) {
		Storey storey = new Storey(node, elevation(node, graph));
		ExtendedIterator<Triple> triples = graph.find(null, RDF.type.asNode(), clazz);
		while (triples.hasNext()) {
			Node subject = triples.next().getSubject();
			Storey s = new Storey(subject, elevation(subject, graph));
			if (s.elevation < storey.elevation) {
				addStorey(storeys, s, graph);
			}
		}
		if (storeys.size() > 0) {
			results.add(storeys.get(storeys.size() - 1).storey);
		}
	}
	return results;

}
 
开发者ID:BenzclyZhang,项目名称:BimSPARQL,代码行数:26,代码来源:HasLowerStoreyPF.java

示例10: convertEntityToResource

import com.hp.hpl.jena.vocabulary.RDF; //导入依赖的package包/类
public Resource convertEntityToResource(IfcEntityBase value) {
	if (value instanceof IfcEntity) {
		IfcEntity entity = (IfcEntity)value;
		if (entity.hasName()) {
			return super.createUriResource(super.formatModelName(entity.getName()));
		} else {
			return super.createAnonResource(String.format(Ifc2RdfVocabulary.IFC.BLANK_NODE_ENTITY_URI_FORMAT, entity.getLineNumber()));
		}
	} else { // entityBase instanceof IfcShortEntity
		Resource resource = super.createAnonResource();
		resource.addProperty(RDF.type, createUriResource(super.formatTypeName(value.getTypeInfo())));
		IfcLiteralValue literalValue = ((IfcShortEntity)value).getValue();
		resource.addProperty(RDF.value, convertLiteralToNode(literalValue));
		return resource;
	}
}
 
开发者ID:Web-of-Building-Data,项目名称:Ifc2Rdf,代码行数:17,代码来源:Ifc2RdfModelExporter.java

示例11: exportSelectTypeInfo

import com.hp.hpl.jena.vocabulary.RDF; //导入依赖的package包/类
private void exportSelectTypeInfo(IfcSelectTypeInfo typeInfo) {

		Resource typeResource = super.createUriResource(super.formatTypeName(typeInfo)); 
		adapter.exportTriple(typeResource, RDF.type, OWL.Class);

		List<String> subTypeNames = typeInfo.getSelectTypeInfoNames();
		List<Resource> nodes = new ArrayList<>();
		for (String typeName : subTypeNames) {
			nodes.add(super.createUriResource(super.formatOntologyName(typeName)));
		}			
		RDFList rdfList = super.createList(nodes);			

		// See samples: [2, p.250]
		adapter.exportTriple(typeResource, OWL.unionOf, rdfList);
		
//		See samples: [2, pp.135-136]
//		for (String subTypeName : subTypeNames) {
//			writeSentence(generateName(subTypeName), RDFS.subClassOf, typeName);
//		}

	}
 
开发者ID:Web-of-Building-Data,项目名称:Ifc2Rdf,代码行数:22,代码来源:Ifc2RdfSchemaExporter.java

示例12: CreatePersonModel

import com.hp.hpl.jena.vocabulary.RDF; //导入依赖的package包/类
public void CreatePersonModel()
{
    Model pm = ModelFactory.createDefaultModel();
    pm.setNsPrefix("RDF", RDF.getURI());
    pm.setNsPrefix("foaf", FOAF.getURI());
    pm.setNsPrefix("DC", DCTerms.getURI());
    
    ArrayList<String> persons = new ArrayList<String>();
    persons.add("Kumar");
    persons.add("Arjun");
    
    int i = 1;
    for(String p : persons)
    {
        Resource p1 = pm.createResource("http://www.testsite.com/persons/p"+i);
        p1.addProperty(FOAF.firstName, p);
        p1.addProperty(DCTerms.description, "Description of person "+i);
        p1.addProperty(FOAF.mbox, p+i+"[email protected]");
        
        i++;
    }
    
    this.writeModelToFile(pm, "RDF/XML", "personData");
}
 
开发者ID:kumarsharma,项目名称:CSV2LOD,代码行数:25,代码来源:CSV2RDF.java

示例13: exportEnumerationTypeInfo

import com.hp.hpl.jena.vocabulary.RDF; //导入依赖的package包/类
private void exportEnumerationTypeInfo(IfcEnumerationTypeInfo typeInfo) {
	
	String typeUri = super.formatTypeName(typeInfo);
	Resource typeResource = createUriResource(typeUri);
	adapter.exportTriple(typeResource, RDF.type, OWL.Class);
	adapter.exportTriple(typeResource, RDFS.subClassOf, Ifc2RdfVocabulary.EXPRESS.Enum);		

	List<String> enumValues = typeInfo.getValues(); 
	List<RDFNode> enumValueNodes = new ArrayList<>();

	for (String value : enumValues) {
		enumValueNodes.add(super.createUriResource(super.formatOntologyName(value)));
	}		
	
	if (owlProfileList.supportsRdfProperty(OWL.oneOf, EnumSet.of(RdfTripleObjectTypeEnum.ZeroOrOneOrMany))) {			
		Resource equivalentTypeResource = super.createAnonResource();
		adapter.exportTriple(typeResource, OWL.equivalentClass, equivalentTypeResource);

		RDFList rdfList = super.createList(enumValueNodes);			
		adapter.exportTriple(equivalentTypeResource, OWL.oneOf, rdfList);
	} else { // if (!context.isEnabledOption(Ifc2RdfConversionOptionsEnum.ForceConvertEnumerationValuesToString)) {
		enumValueNodes.stream().forEach(node ->
				adapter.exportTriple((Resource)node, RDF.type, typeResource));			
	}	
	
}
 
开发者ID:Web-of-Building-Data,项目名称:Ifc2Rdf,代码行数:27,代码来源:Ifc2RdfSchemaExporter.java

示例14: readContent

import com.hp.hpl.jena.vocabulary.RDF; //导入依赖的package包/类
private Content readContent(Model modelTpl, String hostAbout, String about, String inputFormat, String outputFormat, boolean isImport) throws UnsupportedEncodingException, ConfigurationException, URISyntaxException {
	Iterator<Statement> iterator = modelTpl.getResource(hostAbout).listProperties(RDF.type);
	Content result = null;
	while (iterator.hasNext()) {
		Resource resourceType = iterator.next().getResource();
		if (resourceType.toString().equalsIgnoreCase(LDPVoc.Container.stringValue())) {
			result = new Content(about, BygleSystemUtils.RESOURCE_TYPE_RDF_CONTAINER, resourceType, modelTpl, inputFormat, outputFormat != null ? outputFormat : BygleSystemUtils.defaultOutputFormat);
			break;
		} else if (resourceType.toString().equalsIgnoreCase(LDPVoc.BasicContainer.stringValue())) {
			result = new Content(about, BygleSystemUtils.RESOURCE_TYPE_RDF_BASIC_CONTAINER, resourceType, modelTpl, inputFormat, outputFormat != null ? outputFormat : BygleSystemUtils.defaultOutputFormat);
			break;
		} else if (resourceType.toString().equalsIgnoreCase(LDPVoc.DirectContainer.stringValue())) {
			result = new Content(about, BygleSystemUtils.RESOURCE_TYPE_RDF_DIRECT_CONTAINER, resourceType, modelTpl, inputFormat, outputFormat != null ? outputFormat : BygleSystemUtils.defaultOutputFormat);
			break;
		} else if (resourceType.toString().equalsIgnoreCase(LDPVoc.IndirectContainer.stringValue())) {
			result = new Content(about, BygleSystemUtils.RESOURCE_TYPE_RDF_INDIRECT_CONTAINER, resourceType, modelTpl, inputFormat, outputFormat != null ? outputFormat : BygleSystemUtils.defaultOutputFormat);
			break;
		} else if (resourceType.toString().equalsIgnoreCase(LDPVoc.RDFSource.stringValue())) {
			result = new Content(about, BygleSystemUtils.RESOURCE_TYPE_RDF_RESOURCE, resourceType, modelTpl, inputFormat, outputFormat != null ? outputFormat : BygleSystemUtils.defaultOutputFormat);
		} else if (isImport) {
			result = new Content(about, BygleSystemUtils.RESOURCE_TYPE_RDF_RESOURCE, resourceType, modelTpl, inputFormat, outputFormat != null ? outputFormat : BygleSystemUtils.defaultOutputFormat);
		}
	}
	return result;
}
 
开发者ID:regestaexe,项目名称:bygle-ldp,代码行数:26,代码来源:LDPService.java

示例15: parseAnchorGpml

import com.hp.hpl.jena.vocabulary.RDF; //导入依赖的package包/类
/**
 * conversion only GPML vocabulary
 */
public static void parseAnchorGpml(MAnchor anchor, Model model, Resource lineRes, DataHandlerGpml data) {
	Resource anchorRes = model.createResource(lineRes.getURI() + "/Anchor/" + anchor.getGraphId());

	anchorRes.addProperty(RDF.type, Gpml.ANCHOR);
	anchorRes.addProperty(DCTerms.isPartOf, lineRes);
	anchorRes.addProperty(DCTerms.isPartOf, data.getPathwayRes());
	
	lineRes.addProperty(Gpml.HAS_ANCHOR, anchorRes);
	
	anchorRes.addLiteral(Gpml.GRAPH_ID, anchor.getGraphId());
	anchorRes.addLiteral(Gpml.POSITION, anchor.getPosition());
	anchorRes.addLiteral(Gpml.SHAPE, anchor.getShape().getName());
	
	data.getAnchors().put(anchor, anchorRes);
}
 
开发者ID:wikipathways,项目名称:GPML2RDF,代码行数:19,代码来源:AnchorConverter.java


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