/**
* get direct restrictions associated with a given class
* @return
*/
public ILogicExpression getEquivalentRestrictions(){
ILogicExpression exp = ontology.createLogicExpression();
exp.setExpressionType(ILogicExpression.AND);
if(cls instanceof OWLNamedClass){
ArrayList<PClass> list = new ArrayList<PClass>();
// get list of anonymous classes
for(IClass cls : getEquivalentClasses()){
if(cls.isAnonymous())
list.add((PClass)cls);
}
// if we have just one anonymous class that is an expression
// return it, else build our own expression from what we've got
if(list.size() == 1 && list.get(0).getResource() instanceof OWLLogicalClass){
return list.get(0).getLogicExpression();
}else{
// else we've got several equivalent expressions that should be ANDed
for(PClass pc : list){
if(pc.isAnonymous()){
if(pc.getResource() instanceof OWLRestriction){
exp.add((pc instanceof IRestriction)?pc:new PRestriction((OWLRestriction)pc.getResource(),getOntology()));
}else if(pc.getResource() instanceof OWLIntersectionClass){
exp.addAll(pc.getLogicExpression());
}else if(pc.getResource() instanceof OWLLogicalClass){
exp.add(pc.getLogicExpression());
}
}
}
}
}