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