本文整理汇总了Java中com.hp.hpl.jena.ontology.OntProperty.isAnnotationProperty方法的典型用法代码示例。如果您正苦于以下问题:Java OntProperty.isAnnotationProperty方法的具体用法?Java OntProperty.isAnnotationProperty怎么用?Java OntProperty.isAnnotationProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hp.hpl.jena.ontology.OntProperty
的用法示例。
在下文中一共展示了OntProperty.isAnnotationProperty方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: validateStatement
import com.hp.hpl.jena.ontology.OntProperty; //导入方法依赖的package包/类
/**
* Method to actually do the work of validating the statements
* @param or
* @param prop
* @param val
* @return
*/
private boolean validateStatement(OntResource or, OntProperty prop,
RDFNode val) {
boolean retval = true;
if (beginDeepValidation() ) {
try {
if (!prop.isAnnotationProperty()) {
OntResource dor = getDomain(prop);
if (dor != null && !instanceBelongsToClass(getJenaModel(), or, dor)) {
addValidationWarning(or, dor,
"is not in domain (" + classToString(dor)
+ ") of property " + prop.getLocalName());
retval = false;
}
if (val != null) {
OntResource ror = getRange(prop);
if (ror == null) {
addWarning(1, prop.toString() + " does not have a range.");
retval = false;
}
else if (!(ror.isURIResource() && isRDFDataType(ror.getURI())) && val instanceof OntResource) {
if (ror != null
&& !instanceBelongsToClass(getJenaModel(), (OntResource) val, ror)) {
addValidationWarning(
(OntResource) val,
ror,
"is not in the range (" + classToString(ror)
+ ") of property "
+ prop.getLocalName());
retval = false;
}
} else if (val instanceof Literal) {
// no need to look for pending errors here...
if (!literalValueCompatibleWithRange(ror, (Literal)val)) {
addError(new ModelError(val.toString()
+ " is not in range (" + classToString(ror)
+ ") of property " + prop.getLocalName(),
ErrorType.WARNING));
retval = false;
}
}
}
}
} catch (Throwable t) {
if (t.getMessage() == null) {
t.printStackTrace();
}
logger.error("Failed to validate statement: "
+ t.getLocalizedMessage());
}
endDeepValidation();
}
return retval;
}
示例4: 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);
}
}
}