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


Java FOAF类代码示例

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


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

示例1: main

import com.hp.hpl.jena.sparql.vocabulary.FOAF; //导入依赖的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: testNonExistingColumnInJoin

import com.hp.hpl.jena.sparql.vocabulary.FOAF; //导入依赖的package包/类
@Test
public void testNonExistingColumnInJoin() {
	sql.executeSQL("CREATE TABLE T (COL1 INT)");
	sql.executeSQL("CREATE TABLE TBL (COL1 INT)");
	ClassMap cm1 = ClassMap.create(null, "http://example.com/@@[email protected]@", mapping);
	cm1.addClass(FOAF.Person);
	cm1.addJoin(Microsyntax.parseJoin("T.COL1=TBL.COL2"));
	try {
		firstTripleRelation();
		fail("Expected error due to non-existing table TBL.COL2");
	} catch (D2RQException ex) {
		assertEquals(D2RQException.SQL_COLUMN_NOT_FOUND, ex.errorCode());
		assertTrue("Error message was: " + ex.getMessage(), 
				ex.getMessage().contains("\"TBL\".\"COL2\""));
	}
}
 
开发者ID:d2rq,项目名称:r2rml-kit,代码行数:17,代码来源:D2RQCompilerTest.java

示例3: setModelPrefix

import com.hp.hpl.jena.sparql.vocabulary.FOAF; //导入依赖的package包/类
public static void setModelPrefix(Model model){
	model.setNsPrefix("biopax", Biopax_level3.getURI());
	model.setNsPrefix("gpml", Gpml.getURI());
	model.setNsPrefix("wp", Wp.getURI());
	model.setNsPrefix("xsd", XSD.getURI());
	model.setNsPrefix("rdf", RDF.getURI());
	model.setNsPrefix("rdfs", RDFS.getURI());
	model.setNsPrefix("dcterms", DCTerms.getURI());
	model.setNsPrefix("wprdf", "http://rdf.wikipathways.org/");
	model.setNsPrefix("foaf", FOAF.getURI());
	model.setNsPrefix("dc", DC.getURI());
	model.setNsPrefix("skos", Skos.getURI());
	model.setNsPrefix("void", Void.getURI());
	model.setNsPrefix("wprdf", "http://rdf.wikipathways.org/");
	model.setNsPrefix("pav", Pav.getURI());
	model.setNsPrefix("prov", Prov.getURI());
	model.setNsPrefix("dcterms", DCTerms.getURI());
	model.setNsPrefix("freq", Freq.getURI());
}
 
开发者ID:wikipathways,项目名称:GPML2RDF,代码行数:20,代码来源:Utils.java

示例4: CreatePersonModel

import com.hp.hpl.jena.sparql.vocabulary.FOAF; //导入依赖的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

示例5: getURIWithManagedId

import com.hp.hpl.jena.sparql.vocabulary.FOAF; //导入依赖的package包/类
/**
 * Identifiers for managed URI must be be directly served by the dictionary, without involving the decoratee.
 * 
 * @throws Exception never otherwise the test fails.
 */
@Test
public void getURIWithManagedId() throws Exception {
	final Node managedUri = buildResource(FOAF.NS + System.currentTimeMillis());

	final String n3 = NTriples.asNtURI(managedUri);

	when(dummyIndex.getValue(any(byte[].class))).thenReturn(n3);
	when(dummyIndex.getId(n3)).thenReturn(TopLevelDictionaryBase.NOT_SET);

	byte[] id = cut.getID(managedUri, isPredicate);

	final Node value = cut.getValue(id, isPredicate);
	assertEquals(managedUri, value);

	verify(decoratee, times(0)).getValue(id, isPredicate);
}
 
开发者ID:spaziocodice,项目名称:jena-nosql,代码行数:22,代码来源:KnownURIsDictionaryTestCase.java

示例6: removeManagedURI

import com.hp.hpl.jena.sparql.vocabulary.FOAF; //导入依赖的package包/类
/**
 * Tests remove() method with managed URI.
 * 
 * @throws Exception never otherwise the test fails.
 */
@Test
public void removeManagedURI() throws Exception {
	final String[] managedNamespaces = {
			FOAF.NS,
			RDFS.getURI(),
			OWL.NS};

	for (final String managedNamespace : managedNamespaces) {
		assertTrue(cut.contains(managedNamespace));

		final Node uri = buildResource(managedNamespace + randomString());
		final String n3 = NTriples.asNtURI(uri);

		cut.removeValue(uri, isPredicate);
		verify(dummyIndex).remove(n3);

		reset(dummyIndex);
	}
}
 
开发者ID:spaziocodice,项目名称:jena-nosql,代码行数:25,代码来源:KnownURIsDictionaryTestCase.java

示例7: main

import com.hp.hpl.jena.sparql.vocabulary.FOAF; //导入依赖的package包/类
/**
 * 
 * @param args
 */
public static void main(String args[])
{
	// Create an empty model
	Model model = ModelFactory.createDefaultModel();
			
	String fullName = "John Smith";
	String johnURI = ns+"JohnSmith";
	
	// ** TASK 2.1: Create the resource John Smith
	Resource johnSmith = ResourceFactory.createResource("John Smith");

	// Add to johnSmith the datatype property full name (from the VCARD vocabulary)
	johnSmith.addProperty(VCARD.FN, fullName);
	
	// ** TASK 2.2: Create a new resource for Jane Smith, specifying her full name and email **
	Resource janeSmith = ResourceFactory.createResource("Jane Smith");
	janeSmith.addProperty(VCARD.FN, "Jane Smith");
	janeSmith.addProperty(VCARD.EMAIL, "[email protected]");		
	
	// ** TASK 2.3: Add Jane as a person who John knows through an object property from the FOAF vocabulary**
	johnSmith.addProperty(FOAF.knows, janeSmith);
	
	
	model.write(System.out, "RDF/XML-ABBREV");
}
 
开发者ID:FacultadInformatica-LinkedData,项目名称:Curso2014-2015,代码行数:30,代码来源:Task02.java

示例8: insertComponentStatements

import com.hp.hpl.jena.sparql.vocabulary.FOAF; //导入依赖的package包/类
/**
 * Given the component instance, this function will generate all triples for an insert query
 * 
 * @param component
 * @return String containing the triples that can be used in a insert statement
 */
private String insertComponentStatements(Component component) {
  // get all components and the services list
  String servicesStatements = "";

  for (Service s : component.getServices()) {
    servicesStatements +=
        "<" + component.getUri() + "> <" + LDIS.providesService + ">  <" + s.getUri() + "> .";
    servicesStatements += insertServiceStatements(s);
  }

  // get all components and the services list
  String statemets =
      " <" + component.getUri() + "> a <" + LDIS.StackComponent.getURI() + "> ;   <"
          + RDFS.label.getURI() + "> \"" + component.getLabel() + "\" ^^ xsd:string ; <"
          + DCTerms.hasVersion + "> \"" + component.getVersion() + "\" ^^ xsd:string ; <"
          + FOAF.homepage.getURI() + "> <" + component.getHomepage() + "> . "
          + servicesStatements + " ";

  return statemets;
}
 
开发者ID:GeoKnow,项目名称:GeoKnowGeneratorUI,代码行数:27,代码来源:ComponentManager.java

示例9: link

import com.hp.hpl.jena.sparql.vocabulary.FOAF; //导入依赖的package包/类
@Override
public void link(Model m, Group t, AccessRights rights,
                 Resource p, Provider<UriBuilder> uriBuilder) {
    UriBuilder b = uriBuilder.get().path(RootResource.class)
            .path(RootResource.USERS).path(UsersResource.USER);

    m.setNsPrefix(PREFIX, FOAF.NS);
    p.addProperty(RDF.type, FOAF.Group);
    if (rights.canSeeNameOf(t)) {
        p.addLiteral(FOAF.name, t.getName());
    }
    if (rights.canSeeOwnerOf(t)) {
        p.addProperty(FOAF.maker, m.createResource(
                b.build(t.getOwner().getName()).toASCIIString(),
                FOAF.Person));
    }
    if (rights.canSeeMembersOf(t)) {
        for (User u : groupService.getGroupMembers(t, null)) {
            p.addProperty(FOAF.member, m.createResource(
                    b.build(u.getName()).toASCIIString(),
                    FOAF.Person));
        }
    }
}
 
开发者ID:enviroCar,项目名称:enviroCar-server,代码行数:25,代码来源:GroupFOAFLinker.java

示例10: write

import com.hp.hpl.jena.sparql.vocabulary.FOAF; //导入依赖的package包/类
@Override
public void write( OutputStream out )
{

	if( null == jenaModel )
	{
		jenaModel = ModelFactory.createDefaultModel();
		jenaModel.setNsPrefix( "rdfs", "http://www.w3.org/2000/01/rdf-schema#" );
		jenaModel.setNsPrefix( "foaf", "http://xmlns.com/foaf/0.1/" );
		jenaModel.setNsPrefix( "dc", "http://purl.org/dc/elements/1.1/" );
	}

	for( FoafPerson person : persons )
	{
		Resource jenaPerson = jenaModel.createResource( FOAF.Person );
		populatePersonProperties( person, jenaPerson );
	}
	
	RDFWriter w = jenaModel.getWriter();
	w.setProperty( "showXmlDeclaration", "true" );
	w.write( jenaModel, out, "RDF/XML" );
	
	
}
 
开发者ID:fogbeam,项目名称:jFriendOfAFriend,代码行数:25,代码来源:JenaFoafModel.java

示例11: filterTripleRelations

import com.hp.hpl.jena.sparql.vocabulary.FOAF; //导入依赖的package包/类
private Collection<TripleRelation> filterTripleRelations(Collection<TripleRelation> entityDescription) {
	List<TripleRelation> result = new ArrayList<TripleRelation>();
	for (TripleRelation triples: entityDescription) {
		triples = triples.orderBy(TripleRelation.SUBJECT, true);
		if (!OpUtil.isEmpty(triples.selectTriple(new Triple(Node.ANY, RDF.Nodes.type, Node.ANY)).getBaseTabular())) {
			result.add(triples);
		}
		// TODO: The list of label properties is redundantly specified in PageServlet
		if (!OpUtil.isEmpty(triples.selectTriple(new Triple(Node.ANY, RDFS.label.asNode(), Node.ANY)).getBaseTabular())) {
			result.add(triples);
		} else if (!OpUtil.isEmpty(triples.selectTriple(new Triple(Node.ANY, SKOS.prefLabel.asNode(), Node.ANY)).getBaseTabular())) {
			result.add(triples);
		} else if (!OpUtil.isEmpty(triples.selectTriple(new Triple(Node.ANY, DC.title.asNode(), Node.ANY)).getBaseTabular())) {
			result.add(triples);					
		} else if (!OpUtil.isEmpty(triples.selectTriple(new Triple(Node.ANY, DCTerms.title.asNode(), Node.ANY)).getBaseTabular())) {
			result.add(triples);					
		} else if (!OpUtil.isEmpty(triples.selectTriple(new Triple(Node.ANY, FOAF.name.asNode(), Node.ANY)).getBaseTabular())) {
			result.add(triples);					
		}
	}
	if (result.isEmpty()) {
		result.add(new TripleRelation(sqlConnection, entityTable, 
				entityMaker, 
				new FixedNodeMaker(RDF.type.asNode()), 
				new FixedNodeMaker(RDFS.Resource.asNode())));
	}
	return result;
}
 
开发者ID:d2rq,项目名称:r2rml-kit,代码行数:29,代码来源:ResourceCollection.java

示例12: testFindSubjectWhereObjectURIPattern

import com.hp.hpl.jena.sparql.vocabulary.FOAF; //导入依赖的package包/类
@Test
	public void testFindSubjectWhereObjectURIPattern() {
		find(null, FOAF.mbox, createResource("mailto:[email protected]"));
//		dump();
		assertStatement(resource("persons/6"), FOAF.mbox, createResource("mailto:[email protected]"));
		assertStatementCount(1);
    }
 
开发者ID:d2rq,项目名称:r2rml-kit,代码行数:8,代码来源:FindTest.java

示例13: testCatchUnsupportedDatatype

import com.hp.hpl.jena.sparql.vocabulary.FOAF; //导入依赖的package包/类
@Test
public void testCatchUnsupportedDatatype() {
	sql.executeSQL("CREATE TABLE T (COL1 OTHER)");
	ClassMap.create(null, "http://example.com/@@[email protected]@", mapping).addClass(FOAF.Person);
	try {
		firstTripleRelation();
		fail("Expected error due to unsupported datatype OTHER");
	} catch (D2RQException ex) {
		assertEquals(D2RQException.DATATYPE_UNMAPPABLE, ex.errorCode());
		assertTrue(ex.getMessage().contains("OTHER"));
		assertTrue(ex.getMessage().contains("\"T\".\"COL1\""));
	}
}
 
开发者ID:d2rq,项目名称:r2rml-kit,代码行数:14,代码来源:D2RQCompilerTest.java

示例14: testOverrideDatatype

import com.hp.hpl.jena.sparql.vocabulary.FOAF; //导入依赖的package包/类
@Test
public void testOverrideDatatype() {
	sql.executeSQL("CREATE TABLE T (COL1 OTHER)");
	database.addTextColumn("T.COL1");
	ClassMap.create(null, "http://example.com/@@[email protected]@", mapping).addClass(FOAF.Person);
	assertFalse(firstTripleRelation().getBaseTabular().getColumnType(t_col1).isUnsupported());
	assertEquals("VARCHAR",
			firstTripleRelation().getBaseTabular().getColumnType(t_col1).name());
}
 
开发者ID:d2rq,项目名称:r2rml-kit,代码行数:10,代码来源:D2RQCompilerTest.java

示例15: testNonExistingTable

import com.hp.hpl.jena.sparql.vocabulary.FOAF; //导入依赖的package包/类
@Test
public void testNonExistingTable() {
	ClassMap.create(null, "http://example.com/@@[email protected]@", mapping).addClass(FOAF.Person);
	try {
		firstTripleRelation();
		fail("Expected error due to non-existing table TBL");
	} catch (D2RQException ex) {
		assertEquals(D2RQException.SQL_TABLE_NOT_FOUND, ex.errorCode());
		assertTrue("Error message was: " + ex.getMessage(), 
				ex.getMessage().contains("TBL"));
	}
}
 
开发者ID:d2rq,项目名称:r2rml-kit,代码行数:13,代码来源:D2RQCompilerTest.java


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