本文整理汇总了Java中com.hp.hpl.jena.ontology.Individual.addProperty方法的典型用法代码示例。如果您正苦于以下问题:Java Individual.addProperty方法的具体用法?Java Individual.addProperty怎么用?Java Individual.addProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hp.hpl.jena.ontology.Individual
的用法示例。
在下文中一共展示了Individual.addProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addUnittedQuantityAsInstancePropertyValue
import com.hp.hpl.jena.ontology.Individual; //导入方法依赖的package包/类
private void addUnittedQuantityAsInstancePropertyValue(Individual inst, OntProperty oprop, OntResource rng,
String literalNumber, String unit) {
Individual unittedVal;
if (rng != null && rng.canAs(OntClass.class)) {
unittedVal = getTheJenaModel().createIndividual(rng.as(OntClass.class));
} else {
unittedVal = getTheJenaModel().createIndividual(
getTheJenaModel().getOntClass(SadlConstants.SADL_IMPLICIT_MODEL_UNITTEDQUANTITY_URI));
}
// TODO this may need to check for property restrictions on a subclass of
// UnittedQuantity
unittedVal.addProperty(getTheJenaModel().getProperty(SadlConstants.SADL_IMPLICIT_MODEL_VALUE_URI),
getTheJenaModel().createTypedLiteral(literalNumber));
unittedVal.addProperty(getTheJenaModel().getProperty(SadlConstants.SADL_IMPLICIT_MODEL_UNIT_URI),
getTheJenaModel().createTypedLiteral(unit));
inst.addProperty(oprop, unittedVal);
}
示例2: addMarker
import com.hp.hpl.jena.ontology.Individual; //导入方法依赖的package包/类
@Override
public boolean addMarker(String subjectUri, String markerClassUri, String markerTypeUri) {
Individual marker = getTheJenaModel().createIndividual(getMarkerClass(markerClassUri));
Individual markerType = getMarkerTypeInstance(markerTypeUri);
if (marker != null && markerType != null) {
modelOntology.addProperty(getMarkerProperty(), marker);
marker.addProperty(getMarkerTypeProperty(), markerType);
return true;
}
return false;
}
示例3: processStatement
import com.hp.hpl.jena.ontology.Individual; //导入方法依赖的package包/类
protected void processStatement(ExternalEquationStatement element)
throws JenaProcessorException, InvalidNameException, InvalidTypeException, TranslationException {
String uri = element.getUri();
// if(uri.equals(SadlConstants.SADL_BUILTIN_FUNCTIONS_URI)){
// return;
// }
SadlResource nm = element.getName();
EList<SadlParameterDeclaration> params = element.getParameter();
SadlTypeReference rtype = element.getReturnType();
String location = element.getLocation();
Equation eq = createExternalEquation(nm, uri, rtype, params, location);
addEquation(element.eResource(), eq, nm);
Individual eqinst = getTheJenaModel().createIndividual(getDeclarationExtensions().getConceptUri(nm),
getTheJenaModel().getOntClass(SadlConstants.SADL_BASE_MODEL_EXTERNAL_URI));
DatatypeProperty dtp = getTheJenaModel().getDatatypeProperty(SadlConstants.SADL_BASE_MODEL_EXTERNALURI_URI);
Literal literal = uri != null ? getTheJenaModel().createTypedLiteral(uri) : null;
if (eqinst != null && dtp != null && literal != null) {
// these can be null if a resource is open in the editor and a clean/build is
// performed
eqinst.addProperty(dtp, literal);
if (location != null && location.length() > 0) {
DatatypeProperty dtp2 = getTheJenaModel()
.getDatatypeProperty(SadlConstants.SADL_BASE_MODEL_EXTERNALURI_LOCATIOIN);
Literal literal2 = getTheJenaModel().createTypedLiteral(location);
eqinst.addProperty(dtp2, literal2);
}
}
}
示例4: addInstancePropertyValue
import com.hp.hpl.jena.ontology.Individual; //导入方法依赖的package包/类
private void addInstancePropertyValue(Individual inst, Property prop, RDFNode value, EObject ctx) {
if (prop.getURI().equals(SadlConstants.SADL_IMPLICIT_MODEL_IMPLIED_PROPERTY_URI)) {
// check for ambiguity through duplication of property range
if (value.canAs(OntProperty.class)) {
NodeIterator ipvs = inst.listPropertyValues(prop);
if (ipvs.hasNext()) {
List<OntResource> valueRngLst = new ArrayList<OntResource>();
ExtendedIterator<? extends OntResource> vitr = value.as(OntProperty.class).listRange();
while (vitr.hasNext()) {
valueRngLst.add(vitr.next());
}
vitr.close();
boolean overlap = false;
while (ipvs.hasNext()) {
RDFNode ipv = ipvs.next();
if (ipv.canAs(OntProperty.class)) {
ExtendedIterator<? extends OntResource> ipvitr = ipv.as(OntProperty.class).listRange();
while (ipvitr.hasNext()) {
OntResource ipvr = ipvitr.next();
if (valueRngLst.contains(ipvr)) {
addError("Ambiguous condition--multiple implied properties ("
+ value.as(OntProperty.class).getLocalName() + ","
+ ipv.as(OntProperty.class).getLocalName() + ") have the same range ("
+ ipvr.getLocalName() + ")", ctx);
}
}
}
}
}
}
addImpliedPropertyClass(inst);
} else if (prop.getURI().equals(SadlConstants.SADL_IMPLICIT_MODEL_EXPANDED_PROPERTY_URI)) {
addExpandedPropertyClass(inst);
}
inst.addProperty(prop, value);
logger.debug("added value '" + value.toString() + "' to property '" + prop.toString() + "' for instance '"
+ inst.toString() + "'");
}
示例5: nuevo
import com.hp.hpl.jena.ontology.Individual; //导入方法依赖的package包/类
public void nuevo() {
Departamento departamentoNuevo = new Departamento();
departamentoNuevo.setCodDep(codDep);
departamentoNuevo.setNombre(nomDep.toUpperCase());
departamentoNuevo.setCodFac(facultadFacade.findByCodigo(codFac).get(0));
try {
this.departamentoFacade.create(departamentoNuevo);
ModeloBean ont = (ModeloBean) FacesContext.getCurrentInstance().getExternalContext().getApplicationMap().get("modeloBean");
String nS = ont.getPrefijo();
OntModel modelo = ont.getModelOnt();
OntClass claseDep = modelo.getOntClass(nS + clase);
Individual departamento = modelo.createIndividual(nS + clase + codDep, claseDep);
Individual facultad = modelo.getIndividual(nS + "Facultad" + codFac);
DatatypeProperty codigo_dep = modelo.getDatatypeProperty(nS + "codigo_departamento");
DatatypeProperty nombre_dep = modelo.getDatatypeProperty(nS + "nombre_departamento");
DatatypeProperty codigo = modelo.getDatatypeProperty(nS + "codigo_facultad");
DatatypeProperty nomFac = modelo.getDatatypeProperty(nS + "nombre_facultad");
ObjectProperty pertenece = modelo.getObjectProperty(nS + "es_inscrito");
departamento.setPropertyValue(codigo_dep, modelo.createTypedLiteral(departamentoNuevo.getCodDep()));
departamento.setPropertyValue(nombre_dep, modelo.createTypedLiteral(departamentoNuevo.getNombre()));
departamento.setPropertyValue(codigo, modelo.createTypedLiteral(departamentoNuevo.getCodFac().getCodFac()));
departamento.setPropertyValue(nomFac, modelo.createTypedLiteral(departamentoNuevo.getCodFac().getNombre()));
departamento.setPropertyValue(pertenece, facultad);
facultad.addProperty(pertenece.getInverse(), departamento);
ont.guardarModelo(modelo);
codDep = "";
nomDep = "";
codFac = "";
listaDepartamento = this.departamentoFacade.findAll();
FacesContext.getCurrentInstance().getExternalContext().redirect("Lista.xhtml");
} catch (Exception e) {
System.out.println(e.toString());
FacesContext.getCurrentInstance().
addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error al registrar departamento ", ""));
}
}
示例6: nueva
import com.hp.hpl.jena.ontology.Individual; //导入方法依赖的package包/类
public void nueva() {
Lineainvestigacion lineaInvestigacion = new Lineainvestigacion();
lineaInvestigacion.setCodigoLinea(codigoLinea);
lineaInvestigacion.setDescripcion(descripcion.toUpperCase());
lineaInvestigacion.setNombre(nombre.toUpperCase());
lineaInvestigacion.setCodDep(this.departamentoFacade.findByCodep(codDep).get(0));
try {
this.lineaInvestigacionFacade.create(lineaInvestigacion);
ModeloBean ont = (ModeloBean) FacesContext.getCurrentInstance().getExternalContext().getApplicationMap().get("modeloBean");
String nS = ont.getPrefijo();
OntModel modelo = ont.getModelOnt();
OntClass claseLin = modelo.getOntClass(nS + clase);
Individual linea = modelo.createIndividual(nS + clase + codigoLinea, claseLin);
Individual departamento = modelo.getIndividual(nS + "Departamento" + codDep);
DatatypeProperty codigo_lin = modelo.getDatatypeProperty(nS + "codigo_linea");
DatatypeProperty nombre_lin = modelo.getDatatypeProperty(nS + "nombre_linea");
DatatypeProperty desc = modelo.getDatatypeProperty(nS + "descripcion");
ObjectProperty pertenece = modelo.getObjectProperty(nS + "Pertenece_a");
linea.setPropertyValue(codigo_lin, modelo.createTypedLiteral(lineaInvestigacion.getCodigoLinea()));
linea.setPropertyValue(nombre_lin, modelo.createTypedLiteral(lineaInvestigacion.getNombre()));
linea.setPropertyValue(desc, modelo.createTypedLiteral(lineaInvestigacion.getDescripcion()));
linea.setPropertyValue(pertenece, departamento);
departamento.addProperty(pertenece.getInverse(), linea);
ont.guardarModelo(modelo);
reset();
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Registro Exitoso", ""));
} catch (Exception e) {
System.out.println(e.toString());
FacesContext.getCurrentInstance().
addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error al registrar la linea ", ""));
}
}
示例7: nuevo
import com.hp.hpl.jena.ontology.Individual; //导入方法依赖的package包/类
public void nuevo() {
Modalidad modalidad = new Modalidad();
modalidad.setCodDep(this.departamentoFacade.findByCodep(codDep).get(0));
modalidad.setCodModalidad(codModalidad);
modalidad.setModalidad(nombreModalidad.toUpperCase());
try {
this.modalidadFacade.create(modalidad);
ModeloBean ont = (ModeloBean) FacesContext.getCurrentInstance().getExternalContext().getApplicationMap().get("modeloBean");
String nS = ont.getPrefijo();
OntModel modelo = ont.getModelOnt();
OntClass claseMod = modelo.getOntClass(nS + clase);
Individual modalidadI = modelo.createIndividual(nS + clase + codModalidad, claseMod);
Individual departamentoI = modelo.getIndividual(nS + "Departamento" + codDep);
DatatypeProperty codigo_mod = modelo.getDatatypeProperty(nS + "codigo_modalidad");
DatatypeProperty nombre_mod = modelo.getDatatypeProperty(nS + "nombre_modalidad");
ObjectProperty pertenece = modelo.getObjectProperty(nS + "Es_del_departamento");
modalidadI.setPropertyValue(codigo_mod, modelo.createTypedLiteral(modalidad.getCodModalidad()));
modalidadI.setPropertyValue(nombre_mod, modelo.createTypedLiteral(modalidad.getModalidad()));
modalidadI.setPropertyValue(pertenece, departamentoI);
departamentoI.addProperty(pertenece.getInverse(), modalidadI);
ont.guardarModelo(modelo);
reset();
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Registro Exitoso", ""));
} catch (Exception e) {
System.out.println(e.toString());
FacesContext.getCurrentInstance().
addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error al registrar la modalidad ", ""));
}
}
示例8: modificar
import com.hp.hpl.jena.ontology.Individual; //导入方法依赖的package包/类
public void modificar() {
String codigoDepartamento = "";
boolean cambio = false;
try {
modalidadSeleccionada.setModalidad(modalidadSeleccionada.getModalidad().toUpperCase());
if(!modalidadSeleccionada.getCodDep().getCodDep().equals(codDep)){
codigoDepartamento =modalidadSeleccionada.getCodDep().getCodDep();
modalidadSeleccionada.setCodDep(this.departamentoFacade.findByCodep(codDep).get(0));
cambio=true;
}
this.modalidadFacade.edit(modalidadSeleccionada);
ModeloBean ont = (ModeloBean) FacesContext.getCurrentInstance().getExternalContext().getApplicationMap().get("modeloBean");
String nS = ont.getPrefijo();
OntModel modelo = ont.getModelOnt();
Individual modalidadI = modelo.getIndividual(nS + clase + modalidadSeleccionada.getCodModalidad());
DatatypeProperty codigo_mod = modelo.getDatatypeProperty(nS + "codigo_modalidad");
DatatypeProperty nombre_mod = modelo.getDatatypeProperty(nS + "nombre_modalidad");
modalidadI.setPropertyValue(codigo_mod, modelo.createTypedLiteral(modalidadSeleccionada.getCodModalidad()));
modalidadI.setPropertyValue(nombre_mod, modelo.createTypedLiteral(modalidadSeleccionada.getModalidad()));
if(cambio){
ObjectProperty pertenece = modelo.getObjectProperty(nS + "Es_del_departamento");
Individual departamento = modelo.getIndividual(nS + "Departamento" + codigoDepartamento);
modalidadI.removeProperty(pertenece, departamento);
departamento.removeProperty(pertenece.getInverse(), modalidadI);
departamento = modelo.getIndividual(nS + "Departamento" + codDep);
modalidadI.setPropertyValue(pertenece, departamento);
departamento.addProperty(pertenece.getInverse(), modalidadI);
}
ont.guardarModelo(modelo);
reset();
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("modalidad Modificada", ""));
} catch (Exception e) {
System.out.println(e.toString());
FacesContext.getCurrentInstance().
addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error al modificar modalidad ", ""));
}
}
示例9: main
import com.hp.hpl.jena.ontology.Individual; //导入方法依赖的package包/类
public static void main(String args[])
{
String filename = "example5.rdf";
// Create an empty model
OntModel model = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM);
// Use the FileManager to find the input file
InputStream in = FileManager.get().open(filename);
if (in == null)
throw new IllegalArgumentException("File: "+filename+" not found");
// Read the RDF/XML file
model.read(in, null);
// Create a new class named "Researcher"
OntClass researcher = model.createClass(ns + "Researcher");
// ** TASK 6.1: Create a new class named "University" **
OntClass university = model.createClass(ns + "University");
// ** TASK 6.2: Add "Researcher" as a subclass of "Person" **
OntClass person = model.getOntClass(ns + "Person");
person.addSubClass(researcher);
// ** TASK 6.3: Create a new property named "worksIn" **
Property worksIn = model.createProperty(ns + "worksIn");
// ** TASK 6.4: Create a new individual of Researcher named "Jane Smith" **
Individual janeSmith = researcher.createIndividual(ns + "JaneSmith");
// ** TASK 6.5: Add to the individual JaneSmith the fullName, given and family names **
janeSmith.addProperty(VCARD.FN, "JaneSmith");
janeSmith.addProperty(VCARD.Given, "Jane");
janeSmith.addProperty(VCARD.Family, "Smith");
// ** TASK 6.6: Add UPM as the university where John Smith works **
Individual upm = university.createIndividual(ns + "UPM");
model.getIndividual(ns + "JohnSmith").addProperty(worksIn, upm);
model.write(System.out, "RDF/XML-ABBREV");
}
示例10: main
import com.hp.hpl.jena.ontology.Individual; //导入方法依赖的package包/类
public static void main(String args[])
{
String filename = "rdf examples/example5.rdf";
// Create an empty model
OntModel model = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM);
// Use the FileManager to find the input file
InputStream in = FileManager.get().open(filename);
if (in == null)
throw new IllegalArgumentException("File: "+filename+" not found");
// Read the RDF/XML file
model.read(in, null);
// Create a new class named "Researcher"
OntClass researcher = model.createClass(ns+"Researcher");
// ** TASK 6.1: Create a new class named "University" **
OntClass university = model.createClass(ns+"University");
// ** TASK 6.2: Add "Researcher" as a subclass of "Person" **
model.getOntClass(ns+"Person").addSubClass(researcher);
// ** TASK 6.3: Create a new property named "worksIn" **
Property worksIn = model.createProperty(ns+"worksIn");
// ** TASK 6.4: Create a new individual of Researcher named "Jane Smith" **
Individual janeSmith = researcher.createIndividual(ns+"JaneSmith");
// ** TASK 6.5: Add to the individual JaneSmith the fullName, given and family names **
janeSmith.addProperty(VCARD.FN, "Jane Smith");
janeSmith.addProperty(VCARD.Given, "Jane");
janeSmith.addProperty(VCARD.Family, "Smith");
// ** TASK 6.6: Add UPM as the university where John Smith works **
// create an instance of university for upm
Individual upm = university.createIndividual(ns+"UPM");
// complete the property
model.getIndividual(ns+"JohnSmith").addProperty(worksIn, upm);
model.write(System.out, "TURTLE");
}
示例11: main
import com.hp.hpl.jena.ontology.Individual; //导入方法依赖的package包/类
public static void main(String args[])
{
String filename = "src/rdf examples/example5.rdf";
// Create an empty model
OntModel model = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM);
// Use the FileManager to find the input file
InputStream in = FileManager.get().open(filename);
if (in == null)
throw new IllegalArgumentException("File: "+filename+" not found");
// Read the RDF/XML file
model.read(in, null);
// Create a new class named "Researcher"
OntClass researcher = model.createClass(ns+"Researcher");
// ** TASK 6.1: Create a new class named "University" **
OntClass university = model.createClass(ns+"University");
// ** TASK 6.2: Add "Researcher" as a subclass of "Person" **
model.getOntClass(ns+"Person").addSubClass(researcher);
// ** TASK 6.3: Create a new property named "worksIn" **
Property worksIn = model.createProperty(ns+"WorksIn");
// ** TASK 6.4: Create a new individual of Researcher named "Jane Smith" **
Individual inJane = researcher.createIndividual(ns+"JaneSmith");
model.createIndividual(inJane);
// ** TASK 6.5: Add to the individual JaneSmith the fullName, given and family names **
inJane.addLiteral(VCARD.FN, "Jane Smith");
inJane.addLiteral(VCARD.Given, "Jane");
inJane.addLiteral(VCARD.Family, "Smith");
// ** TASK 6.6: Add UPM as the university where John Smith works **
Individual UPM = university.createIndividual(ns+"UPM");
Individual john = model.getIndividual(ns+"JohnSmith");
john.addProperty(worksIn, UPM);
model.write(System.out, "RDF/XML-ABBREV");
}
示例12: main
import com.hp.hpl.jena.ontology.Individual; //导入方法依赖的package包/类
public static void main(String args[])
{
String filename = "src/pruebasJena/examplesRDF/example5.rdf";
// Create an empty model
OntModel model = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM);
// Use the FileManager to find the input file
InputStream in = FileManager.get().open(filename);
if (in == null)
throw new IllegalArgumentException("File: "+filename+" not found");
// Read the RDF/XML file
model.read(in, null);
// Create a new class named "Researcher"
OntClass researcher = model.createClass(ns+"Researcher");
// ** TASK 6.1: Create a new class named "University" **
OntClass university = model.createClass(ns+"University");
// ** TASK 6.2: Add "Researcher" as a subclass of "Person" **
model.getOntClass(ns+"Person").addSubClass(researcher);
// ** TASK 6.3: Create a new property named "worksIn" **
Property worksIn = model.createProperty(ns+"worksIn");
// ** TASK 6.4: Create a new individual of Researcher named "Jane Smith" **
Individual janeSmith = researcher.createIndividual(ns+"JaneSmith");
// ** TASK 6.5: Add to the individual JaneSmith the fullName, given and family names **
janeSmith.addProperty(VCARD.FN, "JaneSmith");
janeSmith.addProperty(VCARD.Given, "Jane");
janeSmith.addProperty(VCARD.Family, "Smith");
// ** TASK 6.6: Add UPM as the university where John Smith works **
Individual johnSmith = model.getIndividual(ns+"JohnSmith");
Individual upm = university.createIndividual(ns+"UPM");
johnSmith.addProperty(worksIn, upm);
model.write(System.out, "RDF/XML-ABBREV");
}
开发者ID:FacultadInformatica-LinkedData,项目名称:Curso2014-2015,代码行数:45,代码来源:Task06JorgeFernandezManteca.java
示例13: main
import com.hp.hpl.jena.ontology.Individual; //导入方法依赖的package包/类
public static void main(String args[])
{
String filename = "rdf examples/example5.rdf";
// Create an empty model
OntModel model = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM);
// Use the FileManager to find the input file
InputStream in = FileManager.get().open(filename);
if (in == null)
throw new IllegalArgumentException("File: "+filename+" not found");
// Read the RDF/XML file
model.read(in, null);
// Create a new class named "Researcher"
OntClass researcher = model.createClass(ns+"Researcher");
// ** TASK 6.1: Create a new class named "University" **
OntClass university = model.createClass(ns+"University");
// ** TASK 6.2: Add "Researcher" as a subclass of "Person" **
model.getOntClass(ns+"Person").addSubClass(researcher);
// ** TASK 6.3: Create a new property named "worksIn" **
Property worksin = model.createProperty(ns + "worksIn");
// ** TASK 6.4: Create a new individual of Researcher named "Jane Smith" **
Individual janesmith = researcher.createIndividual(ns+"JaneSmith");
// ** TASK 6.5: Add to the individual JaneSmith the fullName, given and family names **
janesmith.addProperty(VCARD.FN, "Jane Smith");
janesmith.addProperty(VCARD.Given, "Jane");
janesmith.addProperty(VCARD.Family, "Smith");
// ** TASK 6.6: Add UPM as the university where John Smith works **
model.getIndividual(ns+"JohnSmith").addProperty( worksin,
university.createIndividual(ns+"UPM") );
model.write(System.out, "TURTLE");
}
示例14: main
import com.hp.hpl.jena.ontology.Individual; //导入方法依赖的package包/类
public static void main(String args[])
{
String filename = "example5.rdf";
// Create an empty model
OntModel model = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM);
// Use the FileManager to find the input file
InputStream in = FileManager.get().open(filename);
if (in == null)
throw new IllegalArgumentException("File: "+filename+" not found");
// Read the RDF/XML file
model.read(in, null);
// Create a new class named "Researcher"
OntClass researcher = model.createClass(ns+"Researcher");
// ** TASK 6.1: Create a new class named "University" **
OntClass university = model.createClass(ns+"University");
// ** TASK 6.2: Add "Researcher" as a subclass of "Person" **
model.getOntClass(ns+"Person").addSubClass(model.createClass(ns+"Researcher"));
// ** TASK 6.3: Create a new property named "worksIn" **
Property worksIn = model.createProperty(ns+"worksIn");
// ** TASK 6.4: Create a new individual of Researcher named "Jane Smith" **
Individual janeSmith = researcher.createIndividual(ns+"JaneSmith");
// ** TASK 6.5: Add to the individual JaneSmith the fullName, given and family names **
janeSmith.addProperty(VCARD.FN, "JaneSmith");
janeSmith.addProperty(VCARD.Given, "Jane");
janeSmith.addProperty(VCARD.Family, "Smith");
// ** TASK 6.6: Add UPM as the university where John Smith works **
Individual upm = university.createIndividual(ns + "UPM");
Individual john = model.getIndividual(ns + "JohnSmith");
john.addProperty(worksIn, upm);
model.write(System.out, "TURTLE");
}
示例15: main
import com.hp.hpl.jena.ontology.Individual; //导入方法依赖的package包/类
public static void main(String args[])
{
String filename = "example5.rdf";
// Create an empty model
OntModel model = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM);
// Use the FileManager to find the input file
InputStream in = FileManager.get().open(filename);
if (in == null)
throw new IllegalArgumentException("File: "+filename+" not found");
// Read the RDF/XML file
model.read(in, null);
// Create a new class named "Researcher"
OntClass researcher = model.createClass(ns+"Researcher");
// ** TASK 6.1: Create a new class named "University" **
OntClass university = model.createClass(ns+"University");
// ** TASK 6.2: Add "Researcher" as a subclass of "Person" **
OntClass person = model.getOntClass(ns + "Person");
person.addSubClass(researcher);
// ** TASK 6.3: Create a new property named "worksIn" **
Property worksIn = model.createProperty(ns + "WorksIn");
// ** TASK 6.4: Create a new individual of Researcher named "Jane Smith" **
Individual janeSmith = researcher.createIndividual(ns + "JaneSmith");
// ** TASK 6.5: Add to the individual JaneSmith the fullName, given and family names **
janeSmith.addProperty(VCARD.FN, "Jane Smith");
janeSmith.addProperty(VCARD.Given, "Jane");
janeSmith.addProperty(VCARD.Family, "Smith");
// ** TASK 6.6: Add UPM as the university where John Smith works **
Individual upm = university.createIndividual(ns + "UPM");
model.getIndividual(ns+"JonhSmith").addProperty(worksIn, upm);
model.write(System.out, "RDF/XML-ABBREV");
}