本文整理汇总了Java中com.hp.hpl.jena.ontology.OntProperty.getRange方法的典型用法代码示例。如果您正苦于以下问题:Java OntProperty.getRange方法的具体用法?Java OntProperty.getRange怎么用?Java OntProperty.getRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hp.hpl.jena.ontology.OntProperty
的用法示例。
在下文中一共展示了OntProperty.getRange方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: tripleHasDecimalObject
import com.hp.hpl.jena.ontology.OntProperty; //导入方法依赖的package包/类
private boolean tripleHasDecimalObject(TripleElement gpe) {
Node pred = gpe.getPredicate();
Node obj = gpe.getObject();
if (!(obj instanceof NamedNode) && pred instanceof NamedNode && ((NamedNode)pred).getNamespace() != null) {
OntProperty prop = getTheModel().getOntProperty(((NamedNode)pred).toFullyQualifiedString());
if (prop != null && prop.isDatatypeProperty()) {
Resource rng = prop.getRange();
if (rng.toString().contains("double") || rng.toString().contains("float")) {
return true;
}
}
}
if (obj instanceof Literal) {
Object objval = ((Literal)obj).getValue();
if (objval instanceof Double || objval instanceof Float) {
return true;
}
}
return false;
}
示例2: getRange
import com.hp.hpl.jena.ontology.OntProperty; //导入方法依赖的package包/类
private OntResource getRange(OntProperty prop) {
OntResource range = prop.getRange();
if (range == null) {
ExtendedIterator<? extends OntProperty> titr = null;
if (prop.canAs(ObjectProperty.class)) {
titr = ((ObjectProperty) prop.as(ObjectProperty.class))
.listSuperProperties(true);
} else if (prop.canAs(DatatypeProperty.class)) {
titr = ((DatatypeProperty) prop.as(DatatypeProperty.class))
.listSuperProperties(true);
}
if (titr != null) {
while (titr.hasNext()) {
OntProperty tr = titr.next();
range = getRange((OntProperty) tr);
if (range != null) {
titr.close();
return range;
}
}
titr.close();
}
}
return range;
}
示例3: checkDataPropertyValueInRange
import com.hp.hpl.jena.ontology.OntProperty; //导入方法依赖的package包/类
public boolean checkDataPropertyValueInRange(OntModel theJenaModel2, Resource subj, OntProperty prop, Literal val) {
OntResource rng = prop.getRange();
if (rng == null) {
return true;
}
String ptype = prop.getRange().getURI();
if (ptype == null) {
return true;
}
String dtype = val.getDatatypeURI();
if (dtype.equals(ptype)) {
return true;
}
if (dtype.equals(XSD.xint.getURI())) { // the literal is an integer
if (ptype.equals(XSD.integer.getURI())) return true;
if (ptype.equals(XSD.xlong.getURI())) return true;
}
return false;
}
示例4: addRegularListProperty
import com.hp.hpl.jena.ontology.OntProperty; //导入方法依赖的package包/类
private void addRegularListProperty(Resource r, OntProperty p, List<String> el, TypeVO typeRemembranceOverride,IFCVO ivo) throws IOException, IfcDataFormatException {
OntResource range = p.getRange();
if (range.isClass()) {
OntResource listrange = getListContentType(range.asClass());
if (typeRemembranceOverride != null) {
OntClass cla = ontModel.getOntClass(getOntNS() + typeRemembranceOverride.getName());
listrange = cla;
}
if (listrange == null) {
LOGGER.log(Level.WARNING ,"We could not find what kind of content is expected in the LIST." + "\r\n");
} else {
if (listrange.asClass().hasSuperClass(listModel.getOntClass(getListns() + "OWLList"))) {
throw IfcDataFormatException.valueOutOfRange("#"+ivo.getLineNum(),el.toString(),range.getLocalName());
} else {
List<Resource> reslist = new ArrayList<Resource>();
// createrequirednumberofresources
for (int ii = 0; ii < el.size(); ii++) {
Resource r1 = getResource(getBaseURI() + createLocalName(range.getLocalName() + "_" + IDcounter), range);
// Resource r1 = getResource(getBaseURI() + range.getLocalName() + "_" + IDcounter, range);
reslist.add(r1);
IDcounter++;
if (ii == 0) {
getRdfWriter().triple(new Triple(r.asNode(), p.asNode(), r1.asNode()));
// if (logToFile)
// bw.write("*OK 7*: added property: " + r.getLocalName() + " - " + p.getLocalName() + " - " + r1.getLocalName() + "\r\n");
}
}
// bindtheproperties
addListInstanceProperties(reslist, el, listrange,ivo);
}
}
}
}
示例5: addListPropertyToGivenEntities
import com.hp.hpl.jena.ontology.OntProperty; //导入方法依赖的package包/类
private void addListPropertyToGivenEntities(Resource r, OntProperty p, List<Resource> el) throws IOException {
OntResource range = p.getRange();
if (range.isClass()) {
OntResource listrange = getListContentType(range.asClass());
if (listrange.asClass().hasSuperClass(listModel.getOntClass(getListns() + "OWLList"))) {
// if (logToFile)
// bw.write("*OK 20*: Handling list of list" + "\r\n");
listrange = range;
}
for (int i = 0; i < el.size(); i++) {
Resource r1 = el.get(i);
Resource r2 = ResourceFactory.createResource(getBaseURI() + createLocalName(range.getLocalName() + "_" + IDcounter));
// Resource r2 = ResourceFactory.createResource(getBaseURI() + range.getLocalName() + "_" + IDcounter); // was
// listrange
getRdfWriter().triple(new Triple(r2.asNode(), RDF.type.asNode(), range.asNode()));
// if (logToFile)
// bw.write("*OK 14*: added property: " + r2.getLocalName() + " - rdf:type - " + range.getLocalName() + "\r\n");
IDcounter++;
Resource r3 = ResourceFactory.createResource(getBaseURI() + createLocalName(range.getLocalName() + "_" + IDcounter));
// Resource r3 = ResourceFactory.createResource(getBaseURI() + range.getLocalName() + "_" + IDcounter);
if (i == 0) {
getRdfWriter().triple(new Triple(r.asNode(), p.asNode(), r2.asNode()));
// if (logToFile)
// bw.write("*OK 15*: added property: " + r.getLocalName() + " - " + p.getLocalName() + " - " + r2.getLocalName() + "\r\n");
}
getRdfWriter().triple(new Triple(r2.asNode(), listModel.getOntProperty(getListns() + "hasContents").asNode(), r1.asNode()));
// if (logToFile)
// bw.write("*OK 16*: added property: " + r2.getLocalName() + " - " + "-hasContents-" + " - " + r1.getLocalName() + "\r\n");
if (i < el.size() - 1) {
getRdfWriter().triple(new Triple(r2.asNode(), listModel.getOntProperty(getListns() + "hasNext").asNode(), r3.asNode()));
// if (logToFile)
// bw.write("*OK 17*: added property: " + r2.getLocalName() + " - " + "-hasNext-" + " - " + r3.getLocalName() + "\r\n");
}
}
}
}
示例6: validateClassInRange
import com.hp.hpl.jena.ontology.OntProperty; //导入方法依赖的package包/类
public boolean validateClassInRange(NamedNode pred, NamedNode rangeClass) {
if (beginDeepValidation()) {
OntProperty prop = getJenaModel().getOntProperty(
pred.toFullyQualifiedString());
if (prop != null && prop.isObjectProperty()) {
OntResource rr = prop.getRange();
OntClass rcls = getJenaModel().getOntClass(
rangeClass.toFullyQualifiedString());
if (rcls != null) {
if (rr == null) {
ExtendedIterator<? extends OntProperty> spitr = prop.listSuperProperties();
while (spitr.hasNext()) {
OntProperty sprop = spitr.next();
rr = sprop.getDomain();
if (rr != null) {
if (classIsSubclassOf(rcls, rr, true)) {
spitr.close();
endDeepValidation();
return true;
}
}
}
spitr.close();
}
else {
boolean breturn = classIsSubclassOf(rcls, rr, true);
endDeepValidation();
return breturn;
}
}
}
else if (prop == null) {
// TODO this might need more checking awc 9/15/2013
return true;
}
endDeepValidation();
return false;
}
return true;
}
示例7: getLiteralMatchingDataPropertyRange
import com.hp.hpl.jena.ontology.OntProperty; //导入方法依赖的package包/类
/**
* Call this method to convert a value (v) as a Java object to a typed
* Literal matching the range of the property.
*
* @param m
* @param prop
* @param v
* @return
* @throws CircularDependencyException
*/
public static synchronized Literal getLiteralMatchingDataPropertyRange(OntModel m, OntProperty prop, Object v) throws TranslationException {
Literal val = null;
String errMsg = null;
if (prop == null || prop.isAnnotationProperty()) {
return m.createTypedLiteral(v);
}
// SADL only has DoubleLiterals--if this property has range float convert v to Float.
OntResource rng = prop.getRange();
String rnguri = rng != null ? rng.getURI() : null;
if (rng == null) {
errMsg = "Range not given.";
}
else if (rng.isAnon()) {
// this is a complex range--needs work. Try to do something with it....
// If value is a String
if (v instanceof String) {
v = stripQuotes((String)v);
val = m.createTypedLiteral(v);
}
else {
val = m.createTypedLiteral(v);
if (val == null) {
errMsg = "Range is an unsupported complex type, failed to create a Literal value for '" + v.toString() + "'.";
}
}
}
else {
val = getLiteralMatchingDataPropertyRange(m, rnguri, v);
}
if (errMsg != null) {
errMsg += " (Property is '" + prop.getLocalName() + "'.)";
throw new TranslationException(errMsg);
}
return val;
}
示例8: isDatatypePropertyWithXSDRange
import com.hp.hpl.jena.ontology.OntProperty; //导入方法依赖的package包/类
private boolean isDatatypePropertyWithXSDRange(TripleElement gpe) {
Node pred = gpe.getPredicate();
OntProperty prop = getTheModel().getOntProperty(((NamedNode)pred).toFullyQualifiedString());
if (prop != null && prop.isDatatypeProperty()) {
Resource rng = prop.getRange();
if(rng.getNameSpace().equals(XSD.getURI())) {
return true;
}
}
return false;
}
示例9: tripleHasNumericObject
import com.hp.hpl.jena.ontology.OntProperty; //导入方法依赖的package包/类
private boolean tripleHasNumericObject(TripleElement gpe) {
Node pred = gpe.getPredicate();
OntProperty prop = getTheModel().getOntProperty(((NamedNode)pred).toFullyQualifiedString());
if (prop != null && prop.isDatatypeProperty()) {
Resource rng = prop.getRange();
if (rng.toString().contains("double") || rng.toString().contains("float") || rng.toString().contains("int") || rng.toString().contains("long") || rng.toString().contains("decimal")) {
return true;
}
}
return false;
}
示例10: getLiteralMatchingDataPropertyRange
import com.hp.hpl.jena.ontology.OntProperty; //导入方法依赖的package包/类
/**
* Call this method to convert a value (v) as a Java object to a typed
* Literal matching the range of the property.
*
* @param m
* @param prop
* @param v
* @return
* @throws Exception
*/
public static synchronized Literal getLiteralMatchingDataPropertyRange(OntModel m, OntProperty prop, Object v) throws Exception {
Literal val = null;
String errMsg = null;
if (prop.isAnnotationProperty()) {
return m.createTypedLiteral(v);
}
// SADL only has DoubleLiterals--if this property has range float convert v to Float.
OntResource rng = prop.getRange();
String rnguri = rng != null ? rng.getURI() : null;
if (rng == null) {
errMsg = "Range not given.";
}
else if (rng.isAnon()) {
// this is a complex range--needs work. Try to do something with it....
// If value is a String
if (v instanceof String) {
v = stripQuotes((String)v);
val = m.createTypedLiteral(v);
}
else {
val = m.createTypedLiteral(v);
if (val == null) {
errMsg = "Range is an unsupported complex type, failed to create a Literal value for '" + v.toString() + "'.";
}
}
}
else {
val = getLiteralMatchingDataPropertyRange(m, rnguri, v);
}
if (errMsg != null) {
errMsg += " (Property is '" + prop.getLocalName() + "'.)";
throw new Exception(errMsg);
}
return val;
}
示例11: fillPropertiesHandleStringObject
import com.hp.hpl.jena.ontology.OntProperty; //导入方法依赖的package包/类
private int fillPropertiesHandleStringObject(Resource r, EntityVO evo, String subject, int attributePointer, Object o,IFCVO ivo) throws IOException, IfcDataFormatException {
if (!((String) o).equals("$") && !((String) o).equals("*")) {
if (typ.get(ExpressReader.formatClassName((String) o)) == null) {
if ((evo != null) && (evo.getDerivedAttributeList() != null)) {
if (evo.getDerivedAttributeList().size() <= attributePointer) {
throw IfcDataFormatException.attributeOutOfBounds("#"+ivo.getLineNum()+"="+ivo.getFullLineAfterNum());
}
final AttributeVO avo=evo.getDerivedAttributeList().get(attributePointer);
final String propURI = getOntNS() + avo.getLowerCaseName();
final String literalString = filterExtras((String) o);
if (avo.isSet()){
throw IfcDataFormatException.valueOutOfRange("#"+ivo.getLineNum(),(String)o,"SET");
}
OntProperty p = ontModel.getOntProperty(propURI);
OntResource range = p.getRange();
if (range.isClass()) {
if (range.asClass().hasSuperClass(expressModel.getOntClass(getExpressns() + "ENUMERATION"))) {
// Check for ENUM
addEnumProperty(r, p, range, literalString,ivo);
} else if (range.asClass().hasSuperClass(expressModel.getOntClass(getExpressns() + "SELECT"))) {
// Check for SELECT
// if (logToFile)
// bw.write("*OK 25*: found subClass of SELECT Class, now doing nothing with it: " + p + " - " + range.getLocalName() + " - " + literalString + "\r\n");
createLiteralProperty(r, p, range, literalString,ivo);
} else if (range.asClass().hasSuperClass(listModel.getOntClass(getListns() + "OWLList"))) {
// Check for LIST
throw IfcDataFormatException.valueOutOfRange("#"+ivo.getLineNum(),(String)o,range.getLocalName());
} else {
createLiteralProperty(r, p, range, literalString,ivo);
}
} else {
LOGGER.log(Level.WARNING,"found other kind of property: " + p + " - " + range.getLocalName() + "\r\n");
}
} else {
LOGGER.log(Level.WARNING,"Nothing happened. Not sure if this is good or bad, possible or not." + "\r\n");
}
attributePointer++;
} else {
typeRemembrance = typ.get(ExpressReader.formatClassName((String) o));
// if (typeRemembrance == null) {
// if (logToFile)
// bw.write("*ERROR 11*: The following TYPE is not found: "
// + ExpressReader.formatClassName((String) o)
// + "\r\nQuitting the application without output!\r\n ");
// System.err.println(
// "*ERROR 11*: The following TYPE is not found: " +
// ExpressReader.formatClassName((String) o)
// + "\r\nQuitting the application without output!\r\n ");
// }
}
} else
attributePointer++;
return attributePointer;
}
示例12: loadProperties
import com.hp.hpl.jena.ontology.OntProperty; //导入方法依赖的package包/类
private void loadProperties() {
this.properties.put(Uris.RDF_TYPE_URI, new Label(Uris.RDF_TYPE_URI, Namespaces.RDF, Prefixes.RDF));
this.properties.put(Uris.RDF_VALUE_URI, new Label(Uris.RDF_VALUE_URI, Namespaces.RDF, Prefixes.RDF));
this.properties.put(Uris.RDFS_SUBCLASS_URI, new Label(Uris.RDFS_SUBCLASS_URI, Namespaces.RDFS, Prefixes.RDFS));
this.properties.put(Uris.RDFS_LABEL_URI, new Label(Uris.RDFS_LABEL_URI, Namespaces.RDFS, Prefixes.RDFS));
this.properties.put(Uris.RDFS_COMMENT_URI, new Label(Uris.RDFS_COMMENT_URI, Namespaces.RDFS, Prefixes.RDFS));
this.objectProperties.put(Uris.RDF_TYPE_URI, new Label(Uris.RDF_TYPE_URI, Namespaces.RDF, Prefixes.RDF));
this.objectProperties.put(Uris.RDF_VALUE_URI, new Label(Uris.RDF_VALUE_URI, Namespaces.RDF, Prefixes.RDF));
this.objectProperties.put(Uris.RDFS_SUBCLASS_URI, new Label(Uris.RDFS_SUBCLASS_URI, Namespaces.RDFS, Prefixes.RDFS));
this.dataProperties.put(Uris.RDFS_LABEL_URI, new Label(Uris.RDFS_LABEL_URI, Namespaces.RDFS, Prefixes.RDFS));
this.dataProperties.put(Uris.RDFS_COMMENT_URI, new Label(Uris.RDFS_COMMENT_URI, Namespaces.RDFS, Prefixes.RDFS));
this.properties.put(Uris.CLASS_INSTANCE_LINK_URI, new Label(Uris.CLASS_INSTANCE_LINK_URI, Namespaces.KARMA_DEV, Prefixes.KARMA_DEV));
this.properties.put(Uris.COLUMN_SUBCLASS_LINK_URI, new Label(Uris.COLUMN_SUBCLASS_LINK_URI, Namespaces.KARMA_DEV, Prefixes.KARMA_DEV));
this.properties.put(Uris.DATAPROPERTY_OF_COLUMN_LINK_URI, new Label(Uris.DATAPROPERTY_OF_COLUMN_LINK_URI, Namespaces.KARMA_DEV, Prefixes.KARMA_DEV));
this.properties.put(Uris.OBJECTPROPERTY_SPECIALIZATION_LINK_URI, new Label(Uris.OBJECTPROPERTY_SPECIALIZATION_LINK_URI, Namespaces.KARMA_DEV, Prefixes.KARMA_DEV));
this.properties.put(Uris.DEFAULT_LINK_URI, new Label(Uris.DEFAULT_LINK_URI, Namespaces.KARMA_DEV, Prefixes.KARMA_DEV));
ExtendedIterator<OntProperty> itrP = ontHandler.getOntModel().listAllOntProperties();
while (itrP.hasNext()) {
OntProperty p = itrP.next();
if (!p.isURIResource())
continue;
// if (p.isAnnotationProperty())
// continue;
if (!properties.containsKey(p.getURI()))
properties.put(p.getURI(), ontHandler.getResourceLabel(p));
if (p.isDatatypeProperty() || !p.isObjectProperty())
{
if (!dataProperties.containsKey(p.getURI()))
dataProperties.put(p.getURI(), ontHandler.getResourceLabel(p));
}
if (p.isObjectProperty() || !p.isDatatypeProperty())
{
if (p.getRange() != null && p.getRange().hasURI(Namespaces.RDFS + "Literal")) {
if (!dataProperties.containsKey(p.getURI())) {
dataProperties.put(p.getURI(), ontHandler.getResourceLabel(p));
}
} else if (!objectProperties.containsKey(p.getURI()))
objectProperties.put(p.getURI(), ontHandler.getResourceLabel(p));
}
}
}
示例13: objectValueToStringValue
import com.hp.hpl.jena.ontology.OntProperty; //导入方法依赖的package包/类
public String objectValueToStringValue(Object objValue, String predicate) throws ConfigurationException {
getReasonerOnlyWhenNeeded();
if (schemaModel != null) {
OntProperty pred = null;
Property nonOntPred = null;
if (predicate != null) {
pred = schemaModel.getOntProperty(predicate);
if (pred == null) {
nonOntPred = schemaModel.getProperty(predicate);
if (nonOntPred != null) {
String msg = "Found predicate but it isn't an OntProperty";
logger.debug(msg); addError(new ModelError(msg, ErrorType.ERROR));
}
}
}
RDFNode val = null;
if (pred != null && pred.isDatatypeProperty()) {
if (pred.getRange() != null) {
try {
val = UtilsForJena.getLiteralMatchingDataPropertyRange(schemaModel, pred, objValue);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else {
val = schemaModel.createTypedLiteral(objValue);
}
}
else {
if (pred == null && objValue instanceof String && !(((String)objValue).startsWith("http://" ) && ((String)objValue).contains("#"))) {
val = schemaModel.createTypedLiteral(objValue);
}
else {
val = schemaModel.getIndividual(objValue.toString());
}
}
if (val != null) {
return val.toString();
}
}
return objValue.toString();
}
示例14: objectValueToStringValue
import com.hp.hpl.jena.ontology.OntProperty; //导入方法依赖的package包/类
public String objectValueToStringValue(Object objValue, String predicate) throws ConfigurationException {
getReasonerOnlyWhenNeeded();
if (schemaModel != null) {
OntProperty pred = null;
Property nonOntPred = null;
if (predicate != null) {
pred = schemaModel.getOntProperty(predicate);
if (pred == null) {
nonOntPred = schemaModel.getProperty(predicate);
if (nonOntPred != null) {
String msg = "Found predicate but it isn't an OntProperty";
logger.debug(msg); addError(new ModelError(msg, ErrorType.ERROR));
}
}
}
RDFNode val = null;
if (pred != null && pred.isDatatypeProperty()) {
if (pred.getRange() != null) {
try {
val = SadlUtils.getLiteralMatchingDataPropertyRange(schemaModel, pred, objValue);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else {
val = schemaModel.createTypedLiteral(objValue);
}
}
else {
if (pred == null && objValue instanceof String && !(((String)objValue).startsWith("http://" ) && ((String)objValue).contains("#"))) {
val = schemaModel.createTypedLiteral(objValue);
}
else {
val = schemaModel.getIndividual(objValue.toString());
}
}
if (val != null) {
return val.toString();
}
}
return objValue.toString();
}