Search in sources :

Example 1 with VariableAtom

use of org.apache.stanbol.rules.adapters.jena.atoms.VariableAtom in project stanbol by apache.

the class JenaAdapter method adaptRuleAtomTo.

@SuppressWarnings("unchecked")
@Override
protected <T> T adaptRuleAtomTo(RuleAtom ruleAtom, Class<T> type) throws RuleAtomCallExeption, UnsupportedTypeForExportException, UnavailableRuleObjectException {
    if (type == com.hp.hpl.jena.reasoner.rulesys.Rule.class) {
        String className = ruleAtom.getClass().getSimpleName();
        String canonicalName = ARTIFACT + "." + className;
        try {
            Class<AdaptableAtom> jenaAtomClass = (Class<AdaptableAtom>) Class.forName(canonicalName);
            try {
                AdaptableAtom jenaAtom = jenaAtomClass.newInstance();
                if (jenaAtom instanceof VariableAtom) {
                    System.out.println("Class equals");
                }
                jenaAtom.setRuleAdapter(this);
                return (T) jenaAtom.adapt(ruleAtom);
            } catch (InstantiationException e) {
                log.error(e.getMessage(), e);
            } catch (IllegalAccessException e) {
                log.error(e.getMessage(), e);
            }
        } catch (ClassNotFoundException e) {
            log.error(e.getMessage(), e);
        } catch (SecurityException e) {
            log.error(e.getMessage(), e);
        }
    } else {
        throw new UnsupportedTypeForExportException("The adapter " + getClass() + " does not support type : " + type.getCanonicalName());
    }
    return null;
}
Also used : VariableAtom(org.apache.stanbol.rules.adapters.jena.atoms.VariableAtom) AdaptableAtom(org.apache.stanbol.rules.adapters.AdaptableAtom) UnsupportedTypeForExportException(org.apache.stanbol.rules.base.api.UnsupportedTypeForExportException)

Aggregations

AdaptableAtom (org.apache.stanbol.rules.adapters.AdaptableAtom)1 VariableAtom (org.apache.stanbol.rules.adapters.jena.atoms.VariableAtom)1 UnsupportedTypeForExportException (org.apache.stanbol.rules.base.api.UnsupportedTypeForExportException)1