Search in sources :

Example 1 with RuleImpl

use of org.apache.stanbol.rules.manager.RuleImpl in project stanbol by apache.

the class RuleParserImpl method prefix.

public final void prefix() throws ParseException {
    String nsPrefix;
    Object obj;
    Rule rule;
    nsPrefix = getVariable();
    switch((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
        case EQUAL:
            obj = equality();
            String prefixURI = (String) obj;
            prefixURI = prefixURI.substring(1, prefixURI.length() - 1);
            kb.addPrefix(nsPrefix, prefixURI);
            break;
        case LQUAD:
            obj = rule();
            AtomList[] atoms = (AtomList[]) obj;
            String ruleStorePrefix = kb.getPrefixURI("rmi2");
            ruleStorePrefix = ruleStorePrefix.substring(0, ruleStorePrefix.length());
            if (atoms.length == 1) {
                AtomList body = atoms[0];
                if (body.size() == 1) {
                // FIXME it previously managed SPARQL code injection.
                }
            } else {
                rule = new RuleImpl(new IRI(ruleStorePrefix + nsPrefix), nsPrefix, atoms[0], atoms[1]);
                kb.addRule(rule);
            }
            break;
        default:
            jj_la1[1] = jj_gen;
            jj_consume_token(-1);
            throw new ParseException();
    }
}
Also used : IRI(org.apache.clerezza.commons.rdf.IRI) AtomList(org.apache.stanbol.rules.base.api.util.AtomList) RuleImpl(org.apache.stanbol.rules.manager.RuleImpl) Rule(org.apache.stanbol.rules.base.api.Rule)

Aggregations

IRI (org.apache.clerezza.commons.rdf.IRI)1 Rule (org.apache.stanbol.rules.base.api.Rule)1 AtomList (org.apache.stanbol.rules.base.api.util.AtomList)1 RuleImpl (org.apache.stanbol.rules.manager.RuleImpl)1