本文整理匯總了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();
}
示例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;
}
示例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());
}
示例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");
}
示例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));
}
示例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"));
}
示例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));
}
示例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;
}
示例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;
}
示例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;
}
}
示例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);
// }
}
示例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");
}
示例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));
}
}
示例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;
}
示例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);
}