本文整理汇总了Java中com.hp.hpl.jena.ontology.OntClass.asRestriction方法的典型用法代码示例。如果您正苦于以下问题:Java OntClass.asRestriction方法的具体用法?Java OntClass.asRestriction怎么用?Java OntClass.asRestriction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hp.hpl.jena.ontology.OntClass
的用法示例。
在下文中一共展示了OntClass.asRestriction方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: maxCardinalityRestrictionAlreadyExists
import com.hp.hpl.jena.ontology.OntClass; //导入方法依赖的package包/类
private boolean maxCardinalityRestrictionAlreadyExists(OntClass domainCls,
OntProperty prop, int mxcard) {
ExtendedIterator<OntClass> eitr = domainCls.listSuperClasses(true);
while (eitr.hasNext()) {
OntClass supercls = eitr.next();
if (supercls.isRestriction()) {
Restriction rstrctn = supercls.asRestriction();
if (rstrctn.isMaxCardinalityRestriction()) {
MaxCardinalityRestriction maxrest = rstrctn.asMaxCardinalityRestriction();
if (maxrest.getOnProperty().equals(prop) && maxrest.getMaxCardinality() == mxcard) {
eitr.close();
return true;
}
}
}
}
eitr.close();
return false;
}
示例2: ontClassToString
import com.hp.hpl.jena.ontology.OntClass; //导入方法依赖的package包/类
private String ontClassToString(OntClass cls, OntClass subclass) {
if (cls.isUnionClass()) {
return getUnionClassRangeString(cls.asUnionClass());
}
else if (cls.isIntersectionClass()) {
return getIntersectionClassRangeString(cls.asIntersectionClass());
}
else if (cls.isRestriction()) {
if (!shouldResourceBeOutput(cls, true, false, false)) {
Restriction rest = cls.asRestriction();
Property onProp = rest.getOnProperty();
if (rest.isAllValuesFromRestriction()) {
Resource avfr = rest.asAllValuesFromRestriction().getAllValuesFrom();
addRestriction(subclass, resourceToString(onProp, false) + " of " + resourceToString(subclass, false) + " only has values of type " +
resourceToString(avfr, false) + ".\n");
}
else if (rest.isSomeValuesFromRestriction()) {
Resource svfr = rest.asSomeValuesFromRestriction().getSomeValuesFrom();
addRestriction(subclass, resourceToString(onProp, false) + " of " + resourceToString(subclass, false) + " has at least one value of type " +
resourceToString(svfr, false) + ".\n");
}
else if (rest.isMaxCardinalityRestriction()) {
int maxCard = rest.asMaxCardinalityRestriction().getMaxCardinality();
addRestriction(subclass, resourceToString(onProp, false) + " of " + resourceToString(subclass, false) + " has at most " +
maxCard + (maxCard > 1 ? " values.\n" : " value.\n"));
}
else if (rest.isMinCardinalityRestriction()) {
int minCard = rest.asMinCardinalityRestriction().getMinCardinality();
addRestriction(subclass, resourceToString(onProp, false) + " of " + resourceToString(subclass, false) + " has at least " +
minCard + (minCard > 1 ? " values.\n" : " value.\n"));
}
else if (rest.isCardinalityRestriction()) {
int card = rest.asCardinalityRestriction().getCardinality();
addRestriction(subclass, resourceToString(onProp, false) + " of " + resourceToString(subclass, false) + " has exactly " +
card + (card > 1 ? " values.\n" : " value.\n"));
}
else if (rest.isHasValueRestriction()) {
RDFNode hvr = rest.asHasValueRestriction().getHasValue();
addRestriction(subclass, resourceToString(onProp, false) + " of " + resourceToString(subclass, false) + " always has value " +
rdfNodeToString(hvr, 0) + " .\n");
}
else {
System.out.println("Unhandled restriction: " + rest.getClass());
}
resourcesOutput.add(cls);
}
if (cls.isAnon()) {
// System.out.println("returning null on anon restriction--should this happen??");
return null;
}
else {
return cls.toString();
}
}
else if (cls.isEnumeratedClass()) {
EnumeratedClass enumcls = cls.asEnumeratedClass();
return enumeratedClassToString(enumcls);
}
else if (cls.isComplementClass()) {
ComplementClass ccls = cls.asComplementClass();
OntClass thecls = ccls.getDisjointWith();
if (thecls != null) {
return resourceToString(thecls, false);
}
else {
return null;
}
}
else if (!cls.isAnon()) {
return resourceToString(cls, false);
}
else {
System.out.println("Anon class; returning string equivalent--this shouldn't happen.");
return cls.toString();
}
}
示例3: isSingleValued
import com.hp.hpl.jena.ontology.OntClass; //导入方法依赖的package包/类
public static boolean isSingleValued(OntClass cls, OntProperty prop, String rngString) {
if (prop.isFunctionalProperty()) {
return true;
}
if (cls != null) {
ExtendedIterator<OntClass> eitr = cls.listSuperClasses(false);
while (eitr.hasNext()) {
OntClass supercls = eitr.next();
if (supercls.isRestriction()) {
Restriction rstrct = supercls.asRestriction();
if (rstrct.isMaxCardinalityRestriction()) {
MaxCardinalityRestriction mxcr = rstrct.asMaxCardinalityRestriction();
if (mxcr.getOnProperty().equals(prop) && mxcr.getMaxCardinality() == 1) {
return true;
}
}
else if (rstrct.isCardinalityRestriction()) {
if (rstrct.isCardinalityRestriction()) {
CardinalityRestriction cr = rstrct.asCardinalityRestriction();
if (cr.getOnProperty().equals(prop) && cr.getCardinality() == 1) {
return true;
}
}
}
else {
if (rstrct.hasProperty(OWL2.maxQualifiedCardinality)) {
if (rstrct.getOnProperty().equals(prop) && rstrct.getProperty(OWL2.maxQualifiedCardinality).getInt() == 1) {
// check class
if (rstrct.getProperty(OWL2.onClass).getResource().toString().equals(rngString)) {
return true;
}
}
}
else if (rstrct.hasProperty(OWL2.qualifiedCardinality)) {
if (rstrct.getOnProperty().equals(prop) && rstrct.getProperty(OWL2.qualifiedCardinality).getInt() == 1) {
// check class
if (rstrct.getProperty(OWL2.onClass).getResource().toString().equals(rngString)) {
return true;
}
}
}
// StmtIterator siter = rstrct.listProperties();
// while (siter.hasNext()) {
// System.out.println(siter.nextStatement().toString());
// }
}
}
}
}
return false;
}
示例4: isSingleValued
import com.hp.hpl.jena.ontology.OntClass; //导入方法依赖的package包/类
public static synchronized boolean isSingleValued(OntClass cls, OntProperty prop, String rngString) {
if (prop.isFunctionalProperty()) {
return true;
}
if (cls != null) {
ExtendedIterator<OntClass> eitr = cls.listSuperClasses(false);
while (eitr.hasNext()) {
OntClass supercls = eitr.next();
if (supercls.isRestriction()) {
Restriction rstrct = supercls.asRestriction();
if (rstrct.isMaxCardinalityRestriction()) {
MaxCardinalityRestriction mxcr = rstrct.asMaxCardinalityRestriction();
if (mxcr.getOnProperty().equals(prop) && mxcr.getMaxCardinality() == 1) {
return true;
}
}
else if (rstrct.isCardinalityRestriction()) {
if (rstrct.isCardinalityRestriction()) {
CardinalityRestriction cr = rstrct.asCardinalityRestriction();
if (cr.getOnProperty().equals(prop) && cr.getCardinality() == 1) {
return true;
}
}
}
else {
if (rstrct.hasProperty(OWL2.maxQualifiedCardinality)) {
if (rstrct.getOnProperty().equals(prop) && rstrct.getProperty(OWL2.maxQualifiedCardinality).getInt() == 1) {
// check class
if (rstrct.getProperty(OWL2.onClass).getResource().toString().equals(rngString)) {
return true;
}
}
}
else if (rstrct.hasProperty(OWL2.qualifiedCardinality)) {
if (rstrct.getOnProperty().equals(prop) && rstrct.getProperty(OWL2.qualifiedCardinality).getInt() == 1) {
// check class
if (rstrct.getProperty(OWL2.onClass).getResource().toString().equals(rngString)) {
return true;
}
}
}
}
}
}
}
return false;
}
示例5: isSingleValued
import com.hp.hpl.jena.ontology.OntClass; //导入方法依赖的package包/类
public static synchronized boolean isSingleValued(OntClass cls, OntProperty prop, String rngString) {
if (prop.isFunctionalProperty()) {
return true;
}
if (cls != null) {
ExtendedIterator<OntClass> eitr = cls.listSuperClasses(false);
while (eitr.hasNext()) {
OntClass supercls = eitr.next();
if (supercls.isRestriction()) {
Restriction rstrct = supercls.asRestriction();
if (rstrct.isMaxCardinalityRestriction()) {
MaxCardinalityRestriction mxcr = rstrct.asMaxCardinalityRestriction();
if (mxcr.getOnProperty().equals(prop) && mxcr.getMaxCardinality() == 1) {
return true;
}
}
else if (rstrct.isCardinalityRestriction()) {
if (rstrct.isCardinalityRestriction()) {
CardinalityRestriction cr = rstrct.asCardinalityRestriction();
if (cr.getOnProperty().equals(prop) && cr.getCardinality() == 1) {
return true;
}
}
}
else {
if (rstrct.hasProperty(OWL2.maxQualifiedCardinality)) {
if (rstrct.getOnProperty().equals(prop) && rstrct.getProperty(OWL2.maxQualifiedCardinality).getInt() == 1) {
// check class
if (rstrct.getProperty(OWL2.onClass).getResource().toString().equals(rngString)) {
return true;
}
}
}
else if (rstrct.hasProperty(OWL2.qualifiedCardinality)) {
if (rstrct.getOnProperty().equals(prop) && rstrct.getProperty(OWL2.qualifiedCardinality).getInt() == 1) {
// check class
if (rstrct.getProperty(OWL2.onClass).getResource().toString().equals(rngString)) {
return true;
}
}
}
// StmtIterator siter = rstrct.listProperties();
// while (siter.hasNext()) {
// System.out.println(siter.nextStatement().toString());
// }
}
}
}
}
return false;
}