本文整理匯總了Java中com.hp.hpl.jena.ontology.OntModel.getOntResource方法的典型用法代碼示例。如果您正苦於以下問題:Java OntModel.getOntResource方法的具體用法?Java OntModel.getOntResource怎麽用?Java OntModel.getOntResource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.hp.hpl.jena.ontology.OntModel
的用法示例。
在下文中一共展示了OntModel.getOntResource方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: updateRdfsLabel
import com.hp.hpl.jena.ontology.OntModel; //導入方法依賴的package包/類
@Override
public boolean updateRdfsLabel(String modelName, String uri, String label, String language) throws IOException, ConfigurationException, InvalidNameException, URISyntaxException {
OntModel ontModel = getOntModelForEditing(modelName);
boolean retval = false;
if (ontModel != null) {
OntResource rsrc = ontModel.getOntResource(uri);
if (rsrc == null) {
throw new InvalidNameException("'" + uri + "' was not found in model '" + modelName + "'");
}
String lbl = rsrc.getLabel(language);
if (lbl != null) {
if (!lbl.equals(label)) {
rsrc.removeLabel(lbl, language);
retval = true;
}
}
rsrc.addLabel(label, language);
}
return retval;
}
示例2: getOntResourceInNamedModel
import com.hp.hpl.jena.ontology.OntModel; //導入方法依賴的package包/類
private OntResource getOntResourceInNamedModel(ConceptName name, String modelUri) {
OntResource r = null;
String nameUri = getUri(modelUri + "#", name.getName());
if (imports != null && imports.size() > 0) {
ImportMapping im = imports.get(modelUri);
if (im != null) {
OntModel impModel = im.getModel();
if (impModel != null) {
r = impModel.getOntResource(nameUri);
}
else {
logger.debug("ConceptName '" + name.toString() + "' not found in model '" + modelUri + "' as OntModel is null.");
}
if (r != null) {
logger.debug("ConceptName '" + name.toString() + "' found in imported model: '" + r.getNameSpace() + "'");
setOrderedImportUris(modelUri);
return r;
}
}
else {
logger.debug("Import mapping for model '" + modelUri + "' not found.");
r = getJenaModel().getOntResource(nameUri);
}
}
else {
logger.debug("There are no import mappings!");
r = getJenaModel().getOntResource(nameUri);
}
return r;
}
示例3: getConceptByUri
import com.hp.hpl.jena.ontology.OntModel; //導入方法依賴的package包/類
/**
* Method to find a Resource in this model by URI and return it as a
* ConceptName
*
* @param uri
* -- the concept URI string
* @return
*/
public static ConceptName getConceptByUri(OntModel m, String uri) {
if (m == null) {
return null; // this may happen on startup
}
ConceptType ctype = null;
Resource r;
if (uri.equals(RDF.type.getURI())) {
r = RDF.type;
ctype = ConceptType.OBJECTPROPERTY;
}
else {
r = m.getOntResource(uri);
if (r != null) {
if (r instanceof Individual) {
ctype = ConceptType.INDIVIDUAL;
}
else if (r.canAs(DatatypeProperty.class)){
ctype = ConceptType.DATATYPEPROPERTY;
}
else if (r.canAs(ObjectProperty.class)) {
ctype = ConceptType.OBJECTPROPERTY;
}
else if (r.canAs(OntClass.class)) {
ctype = ConceptType.ONTCLASS;
}
else if (r.canAs(AnnotationProperty.class)) {
ctype = ConceptType.ANNOTATIONPROPERTY;
}
else if (r.canAs(Individual.class)) {
ctype = ConceptType.INDIVIDUAL;
}
}
}
if (r == null) {
if (uri.equals(RDFS.label.getURI())) {
r = RDFS.label;
ctype = ConceptType.ANNOTATIONPROPERTY;
}
else if (uri.equals(RDFS.domain.getURI())) {
r = RDFS.domain;
ctype = ConceptType.OBJECTPROPERTY;
}
else if (uri.equals(RDFS.range.getURI())) {
r = RDFS.range;
ctype = ConceptType.OBJECTPROPERTY;
}
else if (uri.equals(OWL.Class.getURI())) {
r = OWL.Class;
ctype = ConceptType.ONTCLASS;
}
else if (uri.equals(OWL.DatatypeProperty.getURI())) {
r = OWL.DatatypeProperty;
ctype = ConceptType.ONTCLASS;
}
else if (uri.equals(OWL.ObjectProperty.getURI())) {
r = OWL.ObjectProperty;
ctype = ConceptType.ONTCLASS;
}
}
if (r != null) {
ConceptName cn = new ConceptName(r.getLocalName());
cn.setNamespace(r.getNameSpace());
cn.setType(ctype);
return cn;
}
return null;
}
示例4: getConceptByUri
import com.hp.hpl.jena.ontology.OntModel; //導入方法依賴的package包/類
/**
* Method to find a Resource in this model by URI and return it as a
* ConceptName
*
* @param uri
* -- the concept URI string
* @return
*/
public ConceptName getConceptByUri(OntModel m, String uri) {
if (m == null) {
return null; // this may happen on startup
}
ConceptType ctype = null;
Resource r;
if (uri.equals(RDF.type.getURI())) {
r = RDF.type;
ctype = ConceptType.OBJECTPROPERTY;
}
else {
r = m.getOntResource(uri);
if (r != null) {
if (r instanceof Individual) {
ctype = ConceptType.INDIVIDUAL;
}
else if (r.canAs(DatatypeProperty.class)){
ctype = ConceptType.DATATYPEPROPERTY;
}
else if (r.canAs(ObjectProperty.class)) {
ctype = ConceptType.OBJECTPROPERTY;
}
else if (r.canAs(OntClass.class)) {
ctype = ConceptType.ONTCLASS;
}
else if (r.canAs(AnnotationProperty.class)) {
ctype = ConceptType.ANNOTATIONPROPERTY;
}
else if (r.canAs(Individual.class)) {
ctype = ConceptType.INDIVIDUAL;
}
}
}
if (r == null) {
if (uri.equals(RDFS.label.getURI())) {
r = RDFS.label;
ctype = ConceptType.ANNOTATIONPROPERTY;
}
else if (uri.equals(RDFS.domain.getURI())) {
r = RDFS.domain;
ctype = ConceptType.OBJECTPROPERTY;
}
else if (uri.equals(RDFS.range.getURI())) {
r = RDFS.range;
ctype = ConceptType.OBJECTPROPERTY;
}
else if (uri.equals(OWL.Class.getURI())) {
r = OWL.Class;
ctype = ConceptType.ONTCLASS;
}
else if (uri.equals(OWL.DatatypeProperty.getURI())) {
r = OWL.DatatypeProperty;
ctype = ConceptType.ONTCLASS;
}
else if (uri.equals(OWL.ObjectProperty.getURI())) {
r = OWL.ObjectProperty;
ctype = ConceptType.ONTCLASS;
}
}
if (r != null) {
ConceptName cn = new ConceptName(r.getLocalName());
cn.setNamespace(r.getNameSpace());
cn.setType(ctype);
return cn;
}
return null;
}
示例5: getUniqueOntUri
import com.hp.hpl.jena.ontology.OntModel; //導入方法依賴的package包/類
/**
* Method to generate a unique URI string in a given ontology model (OntModel), also given a baseUri.
* If the baseUri ends with a series of digits (a number without decimal or any character following),
* then the number will be extracted and used as a base "counter" and incremented by 1 until a unique
* URI is obtained. If the baseUri does not end with a number then a number will be found, with the
* search starting with 1, which when added to the baseUri gives a unique URI.
*
* @param ontModel -- the model in which the URI is to be unique
* @param baseUri -- the base URI to which the counter is to be added and incremented until unique
* @return -- the unique URI string
*/
public static synchronized String getUniqueOntUri(OntModel ontModel, String baseUri) {
Object[] split = splitUriIntoBaseAndCounter(baseUri);
baseUri = (String) split[0];
long cntr = (long) split[1];
String uri = baseUri + cntr;
while (ontModel.getOntResource(uri) != null) {
uri = baseUri + ++cntr;
}
return uri;
}