本文整理汇总了Java中com.hp.hpl.jena.rdf.model.Model.createProperty方法的典型用法代码示例。如果您正苦于以下问题:Java Model.createProperty方法的具体用法?Java Model.createProperty怎么用?Java Model.createProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hp.hpl.jena.rdf.model.Model
的用法示例。
在下文中一共展示了Model.createProperty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createModel
import com.hp.hpl.jena.rdf.model.Model; //导入方法依赖的package包/类
private Model createModel() {
Model model = ModelFactory.createDefaultModel();
String NS = "http://www.computas.no/zebra/";
model.setNsPrefix("", NS);
model.setNsPrefix("xsd", "http://www.w3.org/2001/XMLSchema#");
Resource subject = model.createResource(NS + "Joe");
Property predicate = model.createProperty(NS + "hasSentMessage");
String object = "Hello World!";
subject.addProperty(predicate, object, XSDDatatype.XSDstring);
return model;
}
示例2: extract
import com.hp.hpl.jena.rdf.model.Model; //导入方法依赖的package包/类
public static void extract(Model m,String name){
Property groups=m.createProperty("http://www.buildingsmart-tech.org/ifc/IFC4/final#groups");
Property isGroupedBy=m.createProperty("http://www.buildingsmart-tech.org/ifc/IFC4/final#isGroupedBy");
Resource SingleValue=m.createResource("http://www.buildingsmart-tech.org/ifc/IFC4/final#P_SINGLEVALUE");
Model vocabulary=ModelFactory.createDefaultModel();
StmtIterator stmt1=m.listStatements(null, RDFS.comment,(String)null);
StmtIterator stmt2=m.listStatements(null,RDFS.domain,(RDFNode)null);
StmtIterator stmt3=m.listStatements(null,RDFS.range,(RDFNode)null);
StmtIterator stmt4=m.listStatements(null, RDF.type, RDF.Property);
StmtIterator stmt6=m.listStatements(null, RDFS.label, (String)null);
StmtIterator stmt8=m.listStatements(null, groups, (RDFNode)null);
StmtIterator stmt9=m.listStatements(null, isGroupedBy, (RDFNode)null);
vocabulary.add(stmt1);
vocabulary.add(stmt2);
vocabulary.add(stmt3);
vocabulary.add(stmt4);
vocabulary.add(stmt6);
vocabulary.add(stmt8);
vocabulary.add(stmt9);
m.remove(vocabulary);
StmtIterator stmt7=m.listStatements(null, RDF.type, (RDFNode)null);
List<Statement> ss=new ArrayList<Statement>();
while(stmt7.hasNext()){
Statement s=stmt7.next();
if(s.getObject().asResource().getURI().startsWith("http://www.buildingsmart-tech.org/ifc/IFC4/final")){
ss.add(s);
}
}
m.remove(ss);
try {
OutputStream voc=new FileOutputStream("C:\\users\\chi\\desktop\\output\\"+name+".ttl");
OutputStream rule=new FileOutputStream("C:\\users\\chi\\desktop\\output\\"+name+"_rule.ttl");
vocabulary.setNsPrefixes(m.getNsPrefixMap());
vocabulary.write(voc,"TTL");
m.write(rule,"TTL");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}