[owl-s] Exception when using castTo method -- needed help

ramesh.alamuri at cmcltd.com ramesh.alamuri at cmcltd.com
Tue Oct 25 00:41:02 EDT 2005


Hi Mike,

I have seen the OWLSConverters.java code for to avoid the
ConversionException in my code. This exception is getting at the time of
casting OWLIndividual object with its super class.  The problem is at
canCast() method. I have done couple of modifications to this code and
finally i am able to run the code without ConversionException.

(The code snippet for OWLSConverters.java)

public boolean canCast(OWLObject object) {
                return (object instanceof OWLIndividual) &&
		   (!OWLConfig.getStrictConversion() ||
		    ((OWLIndividual) object).isType(owlClass) ||
		    individuals.contains(object) ||
((OWLType)getOWLRootCls(((OWLIndividual)
object).getType())).isEquivalent(owlClass));
	}

newly added method into the OWLSConverters.java for getting the RootClass
of the object

private OWLClass getOWLRootCls(OWLClass oCls){
                        Set owlSet = oCls.getSuperClasses();
                        Iterator iSet = owlSet.iterator();
                        OWLClass oClsTmp = oCls;
                        while(iSet.hasNext()){
                            oClsTmp = (OWLClass) iSet.next();
                            if( oClsTmp != null && !oClsTmp.isAnon()){
                                oCls = getOWLRootCls(oClsTmp);
                            }else{
                                break;
                            }
                        }
                        return oCls;
		}

regards,
Taraka





More information about the OWL-S mailing list