當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。