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;
}
Aggregations