Search in sources :

Example 1 with JenaAdapter

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

the class NumericVariableAtom method adapt.

@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption {
    org.apache.stanbol.rules.manager.atoms.NumericVariableAtom tmp = (org.apache.stanbol.rules.manager.atoms.NumericVariableAtom) ruleAtom;
    URI uri = tmp.getURI();
    String variable = uri.toString();
    variable = variable.replace(Symbols.variablesPrefix, "");
    if (variable.startsWith("?")) {
        variable = variable.substring(1);
    }
    Integer index = ((JenaAdapter) adapter).variableMap.get(variable);
    if (index == null) {
        index = ((JenaAdapter) adapter).variableMap.size();
        ((JenaAdapter) adapter).variableMap.put(variable, index);
    }
    Node_RuleVariable ruleVariable = new Node_RuleVariable("?" + variable, index.intValue());
    return (T) new NodeClauseEntry(ruleVariable);
}
Also used : Node_RuleVariable(com.hp.hpl.jena.reasoner.rulesys.Node_RuleVariable) URI(java.net.URI) JenaAdapter(org.apache.stanbol.rules.adapters.jena.JenaAdapter) NodeClauseEntry(org.apache.stanbol.rules.adapters.jena.NodeClauseEntry)

Example 2 with JenaAdapter

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

the class VariableAtom method adapt.

@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption {
    org.apache.stanbol.rules.manager.atoms.VariableAtom tmp = (org.apache.stanbol.rules.manager.atoms.VariableAtom) ruleAtom;
    URI uri = tmp.getURI();
    String variable = uri.toString();
    variable = variable.replace(Symbols.variablesPrefix, "");
    if (variable.startsWith("?")) {
        variable = variable.substring(1);
    }
    Integer index = ((JenaAdapter) adapter).variableMap.get(variable);
    if (index == null) {
        index = ((JenaAdapter) adapter).variableMap.size();
        ((JenaAdapter) adapter).variableMap.put(variable, index);
    }
    Node_RuleVariable ruleVariable = new Node_RuleVariable("?" + variable, index.intValue());
    return (T) new NodeClauseEntry(ruleVariable);
}
Also used : Node_RuleVariable(com.hp.hpl.jena.reasoner.rulesys.Node_RuleVariable) URI(java.net.URI) JenaAdapter(org.apache.stanbol.rules.adapters.jena.JenaAdapter) NodeClauseEntry(org.apache.stanbol.rules.adapters.jena.NodeClauseEntry)

Example 3 with JenaAdapter

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

the class StringVariableAtom method adapt.

@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption {
    org.apache.stanbol.rules.manager.atoms.StringVariableAtom tmp = (org.apache.stanbol.rules.manager.atoms.StringVariableAtom) ruleAtom;
    URI uri = tmp.getURI();
    String variable = uri.toString();
    variable = variable.replace(Symbols.variablesPrefix, "");
    if (variable.startsWith("?")) {
        variable = variable.substring(1);
    }
    Integer index = ((JenaAdapter) adapter).variableMap.get(variable);
    if (index == null) {
        index = ((JenaAdapter) adapter).variableMap.size();
        ((JenaAdapter) adapter).variableMap.put(variable, index);
    }
    Node_RuleVariable ruleVariable = new Node_RuleVariable("?" + variable, index.intValue());
    return (T) new NodeClauseEntry(ruleVariable);
}
Also used : Node_RuleVariable(com.hp.hpl.jena.reasoner.rulesys.Node_RuleVariable) URI(java.net.URI) JenaAdapter(org.apache.stanbol.rules.adapters.jena.JenaAdapter) NodeClauseEntry(org.apache.stanbol.rules.adapters.jena.NodeClauseEntry)

Aggregations

Node_RuleVariable (com.hp.hpl.jena.reasoner.rulesys.Node_RuleVariable)3 URI (java.net.URI)3 JenaAdapter (org.apache.stanbol.rules.adapters.jena.JenaAdapter)3 NodeClauseEntry (org.apache.stanbol.rules.adapters.jena.NodeClauseEntry)3