本文整理汇总了Java中com.hp.hpl.jena.ontology.OntProperty.isDatatypeProperty方法的典型用法代码示例。如果您正苦于以下问题:Java OntProperty.isDatatypeProperty方法的具体用法?Java OntProperty.isDatatypeProperty怎么用?Java OntProperty.isDatatypeProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hp.hpl.jena.ontology.OntProperty
的用法示例。
在下文中一共展示了OntProperty.isDatatypeProperty方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
示例3: 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;
}
示例4: getDataProperties
import com.hp.hpl.jena.ontology.OntProperty; //导入方法依赖的package包/类
public Set<OntProperty> getDataProperties(Object c, int local, int asserted, int named) {
return new EntityFilter<OntProperty>( ((OntClass) c).listDeclaredProperties(asserted==OntologyFactory.DIRECT).toSet(),this) {
protected boolean isFiltered(OntProperty obj) {
return super.isFiltered(obj) && !obj.isDatatypeProperty();
}
};
}
示例5: 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));
}
}
}
示例6: 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();
}
示例7: addPropertyDomain
import com.hp.hpl.jena.ontology.OntProperty; //导入方法依赖的package包/类
/**
* Call this method to add domain information to a property
*
* @param propName
* -- the property to which the domain information is to be added
* @param domain
* -- the domain information (may be null if defining a
* subproperty)
* @param objIdentifier
* @return -- errors encountered of null if none
*/
public List<ModelError> addPropertyDomain(ConceptName propName,
ConceptIdentifier domain, boolean isSingleValuedOnClass, Object objIdentifier) {
OntProperty prop = getOntProperty(propName);
if (prop == null) {
try {
Resource pr = getOntResourceInExistingModel(propName);
if (pr == null) {
addError(
0,
"Property '"
+ propName.toString()
+ "' not found. "
+ getModelReference()
+ ". If this property is declared later, please move declaration before this statement so that property type (object or data) will be known.");
}
// else {
// I think this gets reported elsewhere awc 2/28/2014
// }
} catch (ConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else if (domain != null) {
if (updatePropertyDomain(1, prop, domain)) {
if (isSingleValuedOnClass) {
OntClass domainCls = ontClassInThisModel(conceptIdentifierToOntClass(1, 0,
domain));
if (domainCls == null) {
addError(1, "Domain class '" + domain.toString()
+ "' not found.");
} else {
if (prop.isDatatypeProperty()) {
// must be trying to restrict property on class for datatype property
if (maxCardinalityRestrictionAlreadyExists(domainCls, prop, 1)) {
addWarning(2, "A single-valued restriction has been given to this class and data type property elsewhere so a maximum cardinality restriction of 1 already exists. This does NOT create a qualified cardinality restriction for a specific range class.");
}
addMaxCardinalityRestriction(1, domainCls, propName, prop, new ClassRestrictionCondition(RestrictionType.MAXCARDINALIY, 1));
}
else if (objIdentifier != null) {
if (objIdentifier instanceof ConceptIdentifier) {
addMaxCardinalityRestriction(1, domainCls, propName, prop,
new ClassRestrictionCondition(RestrictionType.MAXCARDINALIY, 1, (ConceptIdentifier) objIdentifier));
}
else {
addError(2, "Restricted-to class of a single-valued restriction is not of the expected type: " + objIdentifier.toString());
}
}
}
}
} else {
addError(1, "Error adding domain '" + domain.toString()
+ "' to property '" + propName.toString() + "'");
}
}
return getErrorsFinal();
}
示例8: 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();
}
示例9: validateTripleTypes
import com.hp.hpl.jena.ontology.OntProperty; //导入方法依赖的package包/类
private void validateTripleTypes(EObject subjeo, EObject predeo, EObject objeo, TripleElement tr, Expression expr)
throws TranslationException, InvalidTypeException, CircularDependencyException, InvalidNameException {
if (getModelValidator() != null) {
Node nsubj = tr.getSubject();
boolean isCrVar = nsubj instanceof VariableNode ? ((VariableNode) nsubj).isCRulesVariable() : false;
String varName = nsubj instanceof NamedNode ? ((NamedNode) nsubj).getName() : null;
OntResource subj = null;
if (nsubj == null) {
addError("Triple has null subject in validation", expr);
return;
} else if (nsubj instanceof ProxyNode) {
Object pf = ((ProxyNode) nsubj).getProxyFor();
if (pf instanceof TripleElement) {
Node pfPred = ((TripleElement) pf).getPredicate();
if (pfPred instanceof NamedNode) {
TypeCheckInfo pfpredtci;
try {
pfpredtci = getModelValidator().getTypeInfoFromRange(
namedNodeToConceptName((NamedNode) pfPred),
getTheJenaModel().getProperty(((NamedNode) pfPred).toFullyQualifiedString()),
subjeo);
if (pfpredtci.getTypeCheckType() != null) {
Node pfpredrngtype = pfpredtci.getTypeCheckType();
if (pfpredrngtype instanceof NamedNode) {
subj = getTheJenaModel()
.getOntResource(((NamedNode) pfpredrngtype).toFullyQualifiedString());
}
}
} catch (DontTypeCheckException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
} else {
subj = getOntResource(tr.getSubject());
}
Node pnode = tr.getPredicate();
OntProperty pred = getTheJenaModel().getOntProperty(tr.getPredicate().toFullyQualifiedString());
if (pred == null) {
if (tr.getPredicate() instanceof VariableNode) {
if (EcoreUtil2.getContainerOfType(expr, QueryStatement.class) != null) {
return; // variables as property in queries is OK
}
addError("Property '" + ((VariableNode) tr.getPredicate()).toDescriptiveString()
+ "' is a variable, unable to validate", expr);
} else {
addError("Unexpected error finding property '" + tr.getPredicate().toDescriptiveString()
+ "' in ontology, cannot validate", expr);
}
return;
}
getModelValidator().checkPropertyDomain(getTheJenaModel(), subj, pred, expr, true,
isCrVar ? varName : null);
NodeType pnodetype;
if (pnode instanceof NamedNode) {
pnodetype = ((NamedNode) pnode).getNodeType();
} else {
if (pred.isObjectProperty()) {
pnodetype = NodeType.ObjectProperty;
} else if (pred.isDatatypeProperty()) {
pnodetype = NodeType.DataTypeProperty;
} else if (pred.isAnnotationProperty()) {
pnodetype = NodeType.AnnotationProperty;
} else {
pnodetype = NodeType.PropertyNode;
}
}
if (pnodetype.equals(NodeType.AnnotationProperty)) {
return; // can't check annotation property as there should be no range specified (OWL
// 1). What about local restrictions on annotation properties?
}
Node obj = tr.getObject();
if (obj != null) {
handleLocalRestriction(expr, tr);
checkTripleRange(subjeo, predeo, objeo, expr, tr.getSubject(), tr.getPredicate(), pred, pnodetype, obj,
false);
}
}
}