use of org.apache.stanbol.rules.base.api.Rule in project stanbol by apache.
the class SPARQLAdapter method adaptRecipeTo.
@SuppressWarnings("unchecked")
protected <T> T adaptRecipeTo(Recipe recipe, Class<T> type) throws UnsupportedTypeForExportException, UnavailableRuleObjectException {
List<SPARQLObject> sparqlObjects = null;
if (type == SPARQLObject.class) {
RuleList ruleList = recipe.getRuleList();
Iterator<Rule> ruleIterator = ruleList.iterator();
sparqlObjects = new ArrayList<SPARQLObject>();
for (int i = 0; ruleIterator.hasNext(); i++) {
sparqlObjects.add((SPARQLObject) adaptRuleTo(ruleIterator.next(), type));
}
} else {
throw new UnsupportedTypeForExportException("The SPARQL Export Provider does not support the selected serialization : " + type.getCanonicalName());
}
return (T) sparqlObjects;
}
use of org.apache.stanbol.rules.base.api.Rule in project stanbol by apache.
the class ClerezzaAdapter method adaptRecipeTo.
@SuppressWarnings("unchecked")
@Override
protected <T> T adaptRecipeTo(Recipe recipe, Class<T> type) throws RuleAtomCallExeption, UnsupportedTypeForExportException, UnavailableRuleObjectException {
List<ConstructQuery> constructQueries = null;
if (type == ConstructQuery.class) {
constructQueries = new ArrayList<ConstructQuery>();
RuleList ruleList = recipe.getRuleList();
Iterator<Rule> ruleIterator = ruleList.iterator();
for (int i = 0; ruleIterator.hasNext(); i++) {
constructQueries.add((ConstructQuery) adaptRuleTo(ruleIterator.next(), type));
}
} else {
throw new UnsupportedTypeForExportException("The adapter for Clerezza does not support the selected serialization : " + type.getCanonicalName());
}
return (T) constructQueries;
}
use of org.apache.stanbol.rules.base.api.Rule in project stanbol by apache.
the class SWRLAdapter method adaptRecipeTo.
@SuppressWarnings("unchecked")
@Override
protected <T> T adaptRecipeTo(Recipe recipe, Class<T> type) throws RuleAtomCallExeption, UnsupportedTypeForExportException, UnavailableRuleObjectException {
List<SWRLRule> swrlRules = null;
if (type == SWRLRule.class) {
RuleList ruleList = recipe.getRuleList();
swrlRules = new ArrayList<SWRLRule>();
if (ruleList != null && !ruleList.isEmpty()) {
Iterator<Rule> ruleIterator = ruleList.iterator();
while (ruleIterator.hasNext()) {
Rule rule = ruleIterator.next();
swrlRules.add(adaptRuleTo(rule, SWRLRule.class));
}
}
} else {
throw new UnsupportedTypeForExportException("The SPARQL Export Provider does not support the selected serialization : " + type.getCanonicalName());
}
return (T) swrlRules;
}
use of org.apache.stanbol.rules.base.api.Rule in project stanbol by apache.
the class RuleList method removeAll.
public boolean removeAll(Collection<?> c) {
if (contains(c)) {
for (Object o : c) {
boolean removed = false;
for (int i = 0; i < rules.length && !removed; i++) {
Rule semionRule = rules[i];
if (semionRule.equals(o)) {
Rule[] semionRulesCopy = new Rule[rules.length - 1];
System.arraycopy(rules, 0, semionRulesCopy, 0, i);
System.arraycopy(rules, i + 1, semionRulesCopy, 0, semionRulesCopy.length - i);
rules = semionRulesCopy;
removed = true;
}
}
}
return true;
} else {
return false;
}
}
use of org.apache.stanbol.rules.base.api.Rule in project stanbol by apache.
the class RuleIterator method next.
public Rule next() {
Rule semionRule = semionRules[currentIndex];
currentIndex++;
return semionRule;
}
Aggregations