You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by an...@apache.org on 2012/03/28 16:10:00 UTC
svn commit: r1306351 [2/3] - in
/incubator/stanbol/trunk/rules/adapters/jena: ./ src/ src/license/
src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/stanbol/ src/main/java/org/apache/stanbol/rules/
src/main/...
Added: incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/EndsWithAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/EndsWithAtom.java?rev=1306351&view=auto
==============================================================================
--- incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/EndsWithAtom.java (added)
+++ incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/EndsWithAtom.java Wed Mar 28 14:09:58 2012
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.rules.adapters.jena.atoms;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.stanbol.rules.adapters.AbstractAdaptableAtom;
+import org.apache.stanbol.rules.adapters.jena.HigherOrderClauseEntry;
+import org.apache.stanbol.rules.adapters.jena.NodeClauseEntry;
+import org.apache.stanbol.rules.base.api.RuleAtom;
+import org.apache.stanbol.rules.base.api.RuleAtomCallExeption;
+import org.apache.stanbol.rules.base.api.UnavailableRuleObjectException;
+import org.apache.stanbol.rules.base.api.UnsupportedTypeForExportException;
+import org.apache.stanbol.rules.manager.atoms.ExpressionAtom;
+
+import com.hp.hpl.jena.graph.Node;
+import com.hp.hpl.jena.graph.impl.LiteralLabel;
+import com.hp.hpl.jena.reasoner.rulesys.BuiltinRegistry;
+import com.hp.hpl.jena.reasoner.rulesys.ClauseEntry;
+import com.hp.hpl.jena.reasoner.rulesys.Functor;
+import com.hp.hpl.jena.reasoner.rulesys.Node_RuleVariable;
+import com.hp.hpl.jena.reasoner.rulesys.Rule;
+
+/**
+ *
+ * It adapts any EndsWithAtom to a regex functor in Jena.
+ *
+ * @author anuzzolese
+ *
+ */
+public class EndsWithAtom extends AbstractAdaptableAtom {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption,
+ UnavailableRuleObjectException,
+ UnsupportedTypeForExportException {
+
+ Node arg1Node = null;
+ Node arg2Node = null;
+
+ org.apache.stanbol.rules.manager.atoms.EndsWithAtom tmp = (org.apache.stanbol.rules.manager.atoms.EndsWithAtom) ruleAtom;
+
+ ExpressionAtom argument = tmp.getArgument();
+ ExpressionAtom term = tmp.getTerm();
+
+ ClauseEntry clauseEntry1 = adapter.adaptTo(argument, Rule.class);
+ ClauseEntry clauseEntry2 = adapter.adaptTo(term, Rule.class);
+
+ List<ClauseEntry> clauseEntries = new ArrayList<ClauseEntry>();
+
+ if (clauseEntry1 instanceof HigherOrderClauseEntry) {
+ arg1Node = ((HigherOrderClauseEntry) clauseEntry1).getBindableNode();
+
+ clauseEntries.addAll(((HigherOrderClauseEntry) clauseEntry1).getClauseEntries());
+ } else if (clauseEntry1 instanceof NodeClauseEntry) {
+ arg1Node = ((NodeClauseEntry) clauseEntry1).getNode();
+ } else {
+ throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
+ }
+
+ if (clauseEntry2 instanceof HigherOrderClauseEntry) {
+ arg2Node = ((HigherOrderClauseEntry) clauseEntry2).getBindableNode();
+
+ clauseEntries.addAll(((HigherOrderClauseEntry) clauseEntry2).getClauseEntries());
+ } else if (clauseEntry2 instanceof NodeClauseEntry) {
+ Node tmpNode = ((NodeClauseEntry) clauseEntry2).getNode();
+ LiteralLabel literalLabel = tmpNode.getLiteral();
+ String lexicalForm = literalLabel.getLexicalForm();
+
+ StringBuilder sb = new StringBuilder();
+ sb.append(lexicalForm);
+ sb.append("$");
+
+ String regex = sb.toString();
+
+ arg2Node = Node_RuleVariable.createLiteral(regex);
+ } else {
+ throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
+ }
+
+ java.util.List<Node> nodes = new ArrayList<Node>();
+
+ nodes.add(arg1Node);
+ nodes.add(arg2Node);
+
+ return (T) new Functor("regex", nodes, new BuiltinRegistry());
+
+ }
+
+}
Added: incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/GreaterEqualThanAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/GreaterEqualThanAtom.java?rev=1306351&view=auto
==============================================================================
--- incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/GreaterEqualThanAtom.java (added)
+++ incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/GreaterEqualThanAtom.java Wed Mar 28 14:09:58 2012
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.rules.adapters.jena.atoms;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.stanbol.rules.adapters.AbstractAdaptableAtom;
+import org.apache.stanbol.rules.adapters.jena.HigherOrderClauseEntry;
+import org.apache.stanbol.rules.adapters.jena.NodeClauseEntry;
+import org.apache.stanbol.rules.base.api.RuleAtom;
+import org.apache.stanbol.rules.base.api.RuleAtomCallExeption;
+import org.apache.stanbol.rules.base.api.UnavailableRuleObjectException;
+import org.apache.stanbol.rules.base.api.UnsupportedTypeForExportException;
+import org.apache.stanbol.rules.manager.atoms.ExpressionAtom;
+
+import com.hp.hpl.jena.graph.Node;
+import com.hp.hpl.jena.reasoner.rulesys.BuiltinRegistry;
+import com.hp.hpl.jena.reasoner.rulesys.ClauseEntry;
+import com.hp.hpl.jena.reasoner.rulesys.Functor;
+import com.hp.hpl.jena.reasoner.rulesys.Rule;
+
+/**
+ *
+ * It adapts a GreaterEqualThanAtom to the ge functor of Jena.
+ *
+ * @author anuzzolese
+ *
+ */
+public class GreaterEqualThanAtom extends AbstractAdaptableAtom {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption,
+ UnavailableRuleObjectException,
+ UnsupportedTypeForExportException {
+
+ Node arg1Node = null;
+ Node arg2Node = null;
+
+ org.apache.stanbol.rules.manager.atoms.GreaterEqualThanAtom tmp = (org.apache.stanbol.rules.manager.atoms.GreaterEqualThanAtom) ruleAtom;
+
+ ExpressionAtom argument1 = tmp.getArgument1();
+ ExpressionAtom argument2 = tmp.getArgument2();
+
+ ClauseEntry clauseEntry1 = adapter.adaptTo(argument1, Rule.class);
+ ClauseEntry clauseEntry2 = adapter.adaptTo(argument2, Rule.class);
+
+ List<ClauseEntry> clauseEntries = new ArrayList<ClauseEntry>();
+
+ if (clauseEntry1 instanceof HigherOrderClauseEntry) {
+ arg1Node = ((HigherOrderClauseEntry) clauseEntry1).getBindableNode();
+
+ clauseEntries.addAll(((HigherOrderClauseEntry) clauseEntry1).getClauseEntries());
+ } else if (clauseEntry1 instanceof NodeClauseEntry) {
+ arg1Node = ((NodeClauseEntry) clauseEntry1).getNode();
+ } else {
+ throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
+ }
+
+ if (clauseEntry2 instanceof HigherOrderClauseEntry) {
+ arg2Node = ((HigherOrderClauseEntry) clauseEntry2).getBindableNode();
+
+ clauseEntries.addAll(((HigherOrderClauseEntry) clauseEntry2).getClauseEntries());
+ } else if (clauseEntry2 instanceof NodeClauseEntry) {
+ arg2Node = ((NodeClauseEntry) clauseEntry2).getNode();
+ } else {
+ throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
+ }
+
+ List<Node> nodes = new ArrayList<Node>();
+
+ nodes.add(arg1Node);
+ nodes.add(arg2Node);
+
+ Functor functor = new Functor("ge", nodes, new BuiltinRegistry());
+
+ clauseEntries.add(functor);
+
+ return (T) new HigherOrderClauseEntry(arg1Node, clauseEntries);
+
+ }
+
+}
Added: incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/GreaterThanAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/GreaterThanAtom.java?rev=1306351&view=auto
==============================================================================
--- incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/GreaterThanAtom.java (added)
+++ incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/GreaterThanAtom.java Wed Mar 28 14:09:58 2012
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.rules.adapters.jena.atoms;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.stanbol.rules.adapters.AbstractAdaptableAtom;
+import org.apache.stanbol.rules.adapters.jena.HigherOrderClauseEntry;
+import org.apache.stanbol.rules.adapters.jena.NodeClauseEntry;
+import org.apache.stanbol.rules.base.api.RuleAtom;
+import org.apache.stanbol.rules.base.api.RuleAtomCallExeption;
+import org.apache.stanbol.rules.base.api.UnavailableRuleObjectException;
+import org.apache.stanbol.rules.base.api.UnsupportedTypeForExportException;
+import org.apache.stanbol.rules.manager.atoms.ExpressionAtom;
+
+import com.hp.hpl.jena.graph.Node;
+import com.hp.hpl.jena.reasoner.rulesys.BuiltinRegistry;
+import com.hp.hpl.jena.reasoner.rulesys.ClauseEntry;
+import com.hp.hpl.jena.reasoner.rulesys.Functor;
+import com.hp.hpl.jena.reasoner.rulesys.Rule;
+
+/**
+ *
+ * It adapts a GreaterThanAtom to the greaterThan functor of Jena.
+ *
+ * @author anuzzolese
+ *
+ */
+public class GreaterThanAtom extends AbstractAdaptableAtom {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption,
+ UnavailableRuleObjectException,
+ UnsupportedTypeForExportException {
+
+ Node arg1Node = null;
+ Node arg2Node = null;
+
+ org.apache.stanbol.rules.manager.atoms.GreaterThanAtom tmp = (org.apache.stanbol.rules.manager.atoms.GreaterThanAtom) ruleAtom;
+
+ ExpressionAtom argument1 = tmp.getArgument1();
+ ExpressionAtom argument2 = tmp.getArgument2();
+
+ ClauseEntry clauseEntry1 = adapter.adaptTo(argument1, Rule.class);
+ ClauseEntry clauseEntry2 = adapter.adaptTo(argument2, Rule.class);
+
+ List<ClauseEntry> clauseEntries = new ArrayList<ClauseEntry>();
+
+ if (clauseEntry1 instanceof HigherOrderClauseEntry) {
+ arg1Node = ((HigherOrderClauseEntry) clauseEntry1).getBindableNode();
+
+ clauseEntries.addAll(((HigherOrderClauseEntry) clauseEntry1).getClauseEntries());
+ } else if (clauseEntry1 instanceof NodeClauseEntry) {
+ arg1Node = ((NodeClauseEntry) clauseEntry1).getNode();
+ } else {
+ throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
+ }
+
+ if (clauseEntry2 instanceof HigherOrderClauseEntry) {
+ arg2Node = ((HigherOrderClauseEntry) clauseEntry2).getBindableNode();
+
+ clauseEntries.addAll(((HigherOrderClauseEntry) clauseEntry2).getClauseEntries());
+ } else if (clauseEntry2 instanceof NodeClauseEntry) {
+ arg2Node = ((NodeClauseEntry) clauseEntry2).getNode();
+ } else {
+ throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
+ }
+
+ java.util.List<Node> nodes = new ArrayList<Node>();
+
+ nodes.add(arg1Node);
+ nodes.add(arg2Node);
+
+ Functor functor = new Functor("greaterThan", nodes, new BuiltinRegistry());
+
+ clauseEntries.add(functor);
+
+ return (T) new HigherOrderClauseEntry(arg1Node, clauseEntries);
+
+ }
+
+}
Added: incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/IndividualPropertyAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/IndividualPropertyAtom.java?rev=1306351&view=auto
==============================================================================
--- incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/IndividualPropertyAtom.java (added)
+++ incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/IndividualPropertyAtom.java Wed Mar 28 14:09:58 2012
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.rules.adapters.jena.atoms;
+
+import org.apache.stanbol.rules.adapters.AbstractAdaptableAtom;
+import org.apache.stanbol.rules.adapters.jena.NodeClauseEntry;
+import org.apache.stanbol.rules.base.api.RuleAtom;
+import org.apache.stanbol.rules.base.api.RuleAtomCallExeption;
+import org.apache.stanbol.rules.base.api.UnavailableRuleObjectException;
+import org.apache.stanbol.rules.base.api.UnsupportedTypeForExportException;
+import org.apache.stanbol.rules.manager.atoms.IObjectAtom;
+
+import com.hp.hpl.jena.graph.Node;
+import com.hp.hpl.jena.reasoner.TriplePattern;
+import com.hp.hpl.jena.reasoner.rulesys.ClauseEntry;
+import com.hp.hpl.jena.reasoner.rulesys.Rule;
+
+/**
+ *
+ * It adapts a IndividualPropertyAtom to triple pattern of Jena.
+ *
+ * @author anuzzolese
+ *
+ */
+public class IndividualPropertyAtom extends AbstractAdaptableAtom {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption,
+ UnavailableRuleObjectException,
+ UnsupportedTypeForExportException {
+
+ org.apache.stanbol.rules.manager.atoms.IndividualPropertyAtom tmp = (org.apache.stanbol.rules.manager.atoms.IndividualPropertyAtom) ruleAtom;
+
+ IObjectAtom argument1 = tmp.getArgument1();
+ IObjectAtom argument2 = tmp.getArgument2();
+ IObjectAtom objectProperty = tmp.getObjectProperty();
+
+ ClauseEntry argument2ClauseEntry = (ClauseEntry) adapter.adaptTo(argument2, Rule.class);
+ ClauseEntry argument1ClauseEntry = (ClauseEntry) adapter.adaptTo(argument1, Rule.class);
+ ClauseEntry objectPropertyClauseEntry = (ClauseEntry) adapter.adaptTo(objectProperty, Rule.class);
+
+ Node subjectNode;
+ Node predicateNode;
+ Node objectNode;
+
+ if (argument1ClauseEntry instanceof NodeClauseEntry) {
+ subjectNode = ((NodeClauseEntry) argument1ClauseEntry).getNode();
+ } else {
+ throw new RuleAtomCallExeption(getClass());
+ }
+
+ if (objectPropertyClauseEntry instanceof NodeClauseEntry) {
+ predicateNode = ((NodeClauseEntry) objectPropertyClauseEntry).getNode();
+ } else {
+ throw new RuleAtomCallExeption(getClass());
+ }
+
+ if (argument2ClauseEntry instanceof NodeClauseEntry) {
+ objectNode = ((NodeClauseEntry) argument2ClauseEntry).getNode();
+ } else {
+ throw new RuleAtomCallExeption(getClass());
+ }
+
+ return (T) new TriplePattern(subjectNode, predicateNode, objectNode);
+
+ }
+
+}
Added: incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/IsBlankAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/IsBlankAtom.java?rev=1306351&view=auto
==============================================================================
--- incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/IsBlankAtom.java (added)
+++ incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/IsBlankAtom.java Wed Mar 28 14:09:58 2012
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.rules.adapters.jena.atoms;
+
+import java.util.ArrayList;
+
+import org.apache.stanbol.rules.adapters.AbstractAdaptableAtom;
+import org.apache.stanbol.rules.adapters.jena.NodeClauseEntry;
+import org.apache.stanbol.rules.base.api.RuleAtom;
+import org.apache.stanbol.rules.base.api.RuleAtomCallExeption;
+import org.apache.stanbol.rules.base.api.UnavailableRuleObjectException;
+import org.apache.stanbol.rules.base.api.UnsupportedTypeForExportException;
+import org.apache.stanbol.rules.manager.atoms.IObjectAtom;
+
+import com.hp.hpl.jena.graph.Node;
+import com.hp.hpl.jena.reasoner.rulesys.BuiltinRegistry;
+import com.hp.hpl.jena.reasoner.rulesys.ClauseEntry;
+import com.hp.hpl.jena.reasoner.rulesys.Functor;
+import com.hp.hpl.jena.reasoner.rulesys.Rule;
+
+/**
+ *
+ * It adapts a IsBlankAtom to the isBNode functor of Jena.
+ *
+ * @author anuzzolese
+ *
+ */
+public class IsBlankAtom extends AbstractAdaptableAtom {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption,
+ UnavailableRuleObjectException,
+ UnsupportedTypeForExportException {
+
+ org.apache.stanbol.rules.manager.atoms.IsBlankAtom tmp = (org.apache.stanbol.rules.manager.atoms.IsBlankAtom) ruleAtom;
+
+ IObjectAtom uriResource = tmp.getUriResource();
+
+ ClauseEntry argumentClauseEntry = (ClauseEntry) adapter.adaptTo(uriResource, Rule.class);
+
+ Node argNode;
+
+ if (argumentClauseEntry instanceof NodeClauseEntry) {
+ argNode = ((NodeClauseEntry) argumentClauseEntry).getNode();
+ } else {
+ throw new RuleAtomCallExeption(getClass());
+ }
+
+ java.util.List<Node> nodes = new ArrayList<Node>();
+
+ nodes.add(argNode);
+
+ return (T) new Functor("isBNode", nodes, new BuiltinRegistry());
+
+ }
+
+}
Added: incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/LengthAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/LengthAtom.java?rev=1306351&view=auto
==============================================================================
--- incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/LengthAtom.java (added)
+++ incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/LengthAtom.java Wed Mar 28 14:09:58 2012
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.rules.adapters.jena.atoms;
+
+import org.apache.stanbol.rules.adapters.AbstractAdaptableAtom;
+import org.apache.stanbol.rules.base.api.RuleAtom;
+import org.apache.stanbol.rules.base.api.RuleAtomCallExeption;
+
+/**
+ *
+ * TODO
+ *
+ * @author anuzzolese
+ *
+ */
+public class LengthAtom extends AbstractAdaptableAtom {
+
+ @Override
+ public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption {
+ throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
+ }
+
+}
Added: incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/LessEqualThanAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/LessEqualThanAtom.java?rev=1306351&view=auto
==============================================================================
--- incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/LessEqualThanAtom.java (added)
+++ incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/LessEqualThanAtom.java Wed Mar 28 14:09:58 2012
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.stanbol.rules.adapters.jena.atoms;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.stanbol.rules.adapters.AbstractAdaptableAtom;
+import org.apache.stanbol.rules.adapters.jena.HigherOrderClauseEntry;
+import org.apache.stanbol.rules.adapters.jena.NodeClauseEntry;
+import org.apache.stanbol.rules.base.api.RuleAtom;
+import org.apache.stanbol.rules.base.api.RuleAtomCallExeption;
+import org.apache.stanbol.rules.base.api.UnavailableRuleObjectException;
+import org.apache.stanbol.rules.base.api.UnsupportedTypeForExportException;
+import org.apache.stanbol.rules.manager.atoms.ExpressionAtom;
+
+import com.hp.hpl.jena.graph.Node;
+import com.hp.hpl.jena.reasoner.rulesys.BuiltinRegistry;
+import com.hp.hpl.jena.reasoner.rulesys.ClauseEntry;
+import com.hp.hpl.jena.reasoner.rulesys.Functor;
+import com.hp.hpl.jena.reasoner.rulesys.Rule;
+
+/**
+ *
+ * It adapts a LessEqualThanAtom to the le functor of Jena.
+ *
+ * @author anuzzolese
+ *
+ */
+public class LessEqualThanAtom extends AbstractAdaptableAtom {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption,
+ UnavailableRuleObjectException,
+ UnsupportedTypeForExportException {
+
+ Node arg1Node = null;
+ Node arg2Node = null;
+
+ org.apache.stanbol.rules.manager.atoms.LessEqualThanAtom tmp = (org.apache.stanbol.rules.manager.atoms.LessEqualThanAtom) ruleAtom;
+
+ ExpressionAtom argument1 = tmp.getArgument1();
+ ExpressionAtom argument2 = tmp.getArgument2();
+
+ ClauseEntry clauseEntry1 = adapter.adaptTo(argument1, Rule.class);
+ ClauseEntry clauseEntry2 = adapter.adaptTo(argument2, Rule.class);
+
+ List<ClauseEntry> clauseEntries = new ArrayList<ClauseEntry>();
+
+ if (clauseEntry1 instanceof HigherOrderClauseEntry) {
+ arg1Node = ((HigherOrderClauseEntry) clauseEntry1).getBindableNode();
+
+ clauseEntries.addAll(((HigherOrderClauseEntry) clauseEntry1).getClauseEntries());
+ } else if (clauseEntry1 instanceof NodeClauseEntry) {
+ arg1Node = ((NodeClauseEntry) clauseEntry1).getNode();
+ } else {
+ throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
+ }
+
+ if (clauseEntry2 instanceof HigherOrderClauseEntry) {
+ arg2Node = ((HigherOrderClauseEntry) clauseEntry2).getBindableNode();
+
+ clauseEntries.addAll(((HigherOrderClauseEntry) clauseEntry2).getClauseEntries());
+ } else if (clauseEntry2 instanceof NodeClauseEntry) {
+ arg2Node = ((NodeClauseEntry) clauseEntry2).getNode();
+ } else {
+ throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
+ }
+
+ java.util.List<Node> nodes = new ArrayList<Node>();
+
+ nodes.add(arg1Node);
+ nodes.add(arg2Node);
+
+ Functor functor = new Functor("le", nodes, new BuiltinRegistry());
+
+ clauseEntries.add(functor);
+
+ return (T) new HigherOrderClauseEntry(arg1Node, clauseEntries);
+
+ }
+
+}
Added: incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/LessThanAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/LessThanAtom.java?rev=1306351&view=auto
==============================================================================
--- incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/LessThanAtom.java (added)
+++ incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/LessThanAtom.java Wed Mar 28 14:09:58 2012
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.rules.adapters.jena.atoms;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.stanbol.rules.adapters.AbstractAdaptableAtom;
+import org.apache.stanbol.rules.adapters.jena.HigherOrderClauseEntry;
+import org.apache.stanbol.rules.adapters.jena.NodeClauseEntry;
+import org.apache.stanbol.rules.base.api.RuleAtom;
+import org.apache.stanbol.rules.base.api.RuleAtomCallExeption;
+import org.apache.stanbol.rules.base.api.UnavailableRuleObjectException;
+import org.apache.stanbol.rules.base.api.UnsupportedTypeForExportException;
+import org.apache.stanbol.rules.manager.atoms.ExpressionAtom;
+
+import com.hp.hpl.jena.graph.Node;
+import com.hp.hpl.jena.reasoner.rulesys.BuiltinRegistry;
+import com.hp.hpl.jena.reasoner.rulesys.ClauseEntry;
+import com.hp.hpl.jena.reasoner.rulesys.Functor;
+import com.hp.hpl.jena.reasoner.rulesys.Rule;
+
+/**
+ *
+ * It adapts a LessThanAtom to the lessThan functor of Jena.
+ *
+ * @author anuzzolese
+ *
+ */
+public class LessThanAtom extends AbstractAdaptableAtom {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption,
+ UnavailableRuleObjectException,
+ UnsupportedTypeForExportException {
+
+ Node arg1Node = null;
+ Node arg2Node = null;
+
+ org.apache.stanbol.rules.manager.atoms.LessThanAtom tmp = (org.apache.stanbol.rules.manager.atoms.LessThanAtom) ruleAtom;
+
+ ExpressionAtom argument1 = tmp.getArgument1();
+ ExpressionAtom argument2 = tmp.getArgument2();
+
+ ClauseEntry clauseEntry1 = adapter.adaptTo(argument1, Rule.class);
+ ClauseEntry clauseEntry2 = adapter.adaptTo(argument2, Rule.class);
+
+ List<ClauseEntry> clauseEntries = new ArrayList<ClauseEntry>();
+
+ if (clauseEntry1 instanceof HigherOrderClauseEntry) {
+ arg1Node = ((HigherOrderClauseEntry) clauseEntry1).getBindableNode();
+
+ clauseEntries.addAll(((HigherOrderClauseEntry) clauseEntry1).getClauseEntries());
+ } else if (clauseEntry1 instanceof NodeClauseEntry) {
+ arg1Node = ((NodeClauseEntry) clauseEntry1).getNode();
+ } else {
+ throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
+ }
+
+ if (clauseEntry2 instanceof HigherOrderClauseEntry) {
+ arg2Node = ((HigherOrderClauseEntry) clauseEntry2).getBindableNode();
+
+ clauseEntries.addAll(((HigherOrderClauseEntry) clauseEntry2).getClauseEntries());
+ } else if (clauseEntry2 instanceof NodeClauseEntry) {
+ arg2Node = ((NodeClauseEntry) clauseEntry2).getNode();
+ } else {
+ throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
+ }
+
+ java.util.List<Node> nodes = new ArrayList<Node>();
+
+ nodes.add(arg1Node);
+ nodes.add(arg2Node);
+
+ Functor functor = new Functor("lessThan", nodes, new BuiltinRegistry());
+
+ clauseEntries.add(functor);
+
+ return (T) new HigherOrderClauseEntry(arg1Node, clauseEntries);
+
+ }
+
+}
Added: incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/LetAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/LetAtom.java?rev=1306351&view=auto
==============================================================================
--- incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/LetAtom.java (added)
+++ incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/LetAtom.java Wed Mar 28 14:09:58 2012
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.rules.adapters.jena.atoms;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.stanbol.rules.adapters.AbstractAdaptableAtom;
+import org.apache.stanbol.rules.adapters.jena.HigherOrderClauseEntry;
+import org.apache.stanbol.rules.adapters.jena.NodeClauseEntry;
+import org.apache.stanbol.rules.base.api.RuleAtom;
+import org.apache.stanbol.rules.base.api.RuleAtomCallExeption;
+import org.apache.stanbol.rules.base.api.UnavailableRuleObjectException;
+import org.apache.stanbol.rules.base.api.UnsupportedTypeForExportException;
+import org.apache.stanbol.rules.manager.atoms.IObjectAtom;
+import org.apache.stanbol.rules.manager.atoms.StringFunctionAtom;
+
+import com.hp.hpl.jena.graph.Node;
+import com.hp.hpl.jena.reasoner.rulesys.BuiltinRegistry;
+import com.hp.hpl.jena.reasoner.rulesys.ClauseEntry;
+import com.hp.hpl.jena.reasoner.rulesys.Functor;
+import com.hp.hpl.jena.reasoner.rulesys.Rule;
+
+/**
+ *
+ * It adapts a LetAtom to the makeSkolem functor of Jena.
+ *
+ * @author anuzzolese
+ *
+ */
+public class LetAtom extends AbstractAdaptableAtom {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption,
+ UnavailableRuleObjectException,
+ UnsupportedTypeForExportException {
+
+ org.apache.stanbol.rules.manager.atoms.LetAtom tmp = (org.apache.stanbol.rules.manager.atoms.LetAtom) ruleAtom;
+
+ StringFunctionAtom parameterFunctionAtom = tmp.getParameterFunctionAtom();
+ IObjectAtom variableIObjectAtom = tmp.getVariable();
+
+ ClauseEntry parameterClauseEntry = (ClauseEntry) adapter.adaptTo(parameterFunctionAtom, Rule.class);
+ ClauseEntry variableClauseEntry = (ClauseEntry) adapter.adaptTo(variableIObjectAtom, Rule.class);
+
+ List<ClauseEntry> clauseEntries = new ArrayList<ClauseEntry>();
+
+ Node parameterNode;
+ Node variableNode;
+
+ if (parameterClauseEntry instanceof HigherOrderClauseEntry) {
+ parameterNode = ((HigherOrderClauseEntry) parameterClauseEntry).getBindableNode();
+
+ clauseEntries.addAll(((HigherOrderClauseEntry) parameterClauseEntry).getClauseEntries());
+ } else if (parameterClauseEntry instanceof NodeClauseEntry) {
+ parameterNode = ((NodeClauseEntry) parameterClauseEntry).getNode();
+ } else {
+ throw new RuleAtomCallExeption(getClass());
+ }
+
+ if (variableClauseEntry instanceof NodeClauseEntry) {
+ variableNode = ((NodeClauseEntry) variableClauseEntry).getNode();
+ } else {
+ throw new RuleAtomCallExeption(getClass());
+ }
+
+ java.util.List<Node> nodes = new ArrayList<Node>();
+
+ nodes.add(variableNode);
+ nodes.add(parameterNode);
+
+ ClauseEntry clauseEntry = new Functor("makeSkolem", nodes, new BuiltinRegistry());
+
+ clauseEntries.add(clauseEntry);
+
+ return (T) new HigherOrderClauseEntry(variableNode, clauseEntries);
+
+ }
+
+}
Added: incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/LocalNameAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/LocalNameAtom.java?rev=1306351&view=auto
==============================================================================
--- incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/LocalNameAtom.java (added)
+++ incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/LocalNameAtom.java Wed Mar 28 14:09:58 2012
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.rules.adapters.jena.atoms;
+
+import org.apache.stanbol.rules.adapters.AbstractAdaptableAtom;
+import org.apache.stanbol.rules.base.api.RuleAtom;
+import org.apache.stanbol.rules.base.api.RuleAtomCallExeption;
+
+/**
+ *
+ * TODO
+ *
+ * @author anuzzolese
+ *
+ */
+public class LocalNameAtom extends AbstractAdaptableAtom {
+
+ @Override
+ public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption {
+ throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
+ }
+
+}
Added: incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/LowerCaseAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/LowerCaseAtom.java?rev=1306351&view=auto
==============================================================================
--- incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/LowerCaseAtom.java (added)
+++ incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/LowerCaseAtom.java Wed Mar 28 14:09:58 2012
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.rules.adapters.jena.atoms;
+
+import org.apache.stanbol.rules.adapters.AbstractAdaptableAtom;
+import org.apache.stanbol.rules.base.api.RuleAtom;
+import org.apache.stanbol.rules.base.api.RuleAtomCallExeption;
+
+/**
+ *
+ * TODO
+ *
+ * @author anuzzolese
+ *
+ */
+public class LowerCaseAtom extends AbstractAdaptableAtom {
+
+ @Override
+ public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption {
+ throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
+ }
+
+}
Added: incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/MultiplicationAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/MultiplicationAtom.java?rev=1306351&view=auto
==============================================================================
--- incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/MultiplicationAtom.java (added)
+++ incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/MultiplicationAtom.java Wed Mar 28 14:09:58 2012
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.rules.adapters.jena.atoms;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.stanbol.rules.adapters.AbstractAdaptableAtom;
+import org.apache.stanbol.rules.adapters.jena.HigherOrderClauseEntry;
+import org.apache.stanbol.rules.adapters.jena.NodeClauseEntry;
+import org.apache.stanbol.rules.base.api.RuleAtom;
+import org.apache.stanbol.rules.base.api.RuleAtomCallExeption;
+import org.apache.stanbol.rules.base.api.UnavailableRuleObjectException;
+import org.apache.stanbol.rules.base.api.UnsupportedTypeForExportException;
+import org.apache.stanbol.rules.manager.atoms.NumericFunctionAtom;
+
+import com.hp.hpl.jena.graph.Node;
+import com.hp.hpl.jena.reasoner.rulesys.BuiltinRegistry;
+import com.hp.hpl.jena.reasoner.rulesys.ClauseEntry;
+import com.hp.hpl.jena.reasoner.rulesys.Functor;
+import com.hp.hpl.jena.reasoner.rulesys.Node_RuleVariable;
+import com.hp.hpl.jena.reasoner.rulesys.Rule;
+
+/**
+ *
+ * It adapts a MultiplicationAtom to the product functor of Jena.
+ *
+ * @author anuzzolese
+ *
+ */
+public class MultiplicationAtom extends AbstractAdaptableAtom {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption,
+ UnavailableRuleObjectException,
+ UnsupportedTypeForExportException {
+
+ String div_result = "mul_result" + System.currentTimeMillis();
+
+ Node arg1Node = null;
+ Node arg2Node = null;
+ Node arg3Node = Node_RuleVariable.createVariable(div_result);
+
+ org.apache.stanbol.rules.manager.atoms.MultiplicationAtom tmp = (org.apache.stanbol.rules.manager.atoms.MultiplicationAtom) ruleAtom;
+
+ NumericFunctionAtom numericFunctionAtom1 = tmp.getNumericFunctionAtom1();
+ NumericFunctionAtom numericFunctionAtom2 = tmp.getNumericFunctionAtom2();
+
+ ClauseEntry clauseEntry1 = adapter.adaptTo(numericFunctionAtom1, Rule.class);
+ ClauseEntry clauseEntry2 = adapter.adaptTo(numericFunctionAtom2, Rule.class);
+
+ List<ClauseEntry> clauseEntries = new ArrayList<ClauseEntry>();
+
+ if (clauseEntry1 instanceof HigherOrderClauseEntry) {
+ arg1Node = ((HigherOrderClauseEntry) clauseEntry1).getBindableNode();
+
+ clauseEntries.addAll(((HigherOrderClauseEntry) clauseEntry1).getClauseEntries());
+ } else if (clauseEntry1 instanceof NodeClauseEntry) {
+ arg1Node = ((NodeClauseEntry) clauseEntry1).getNode();
+ } else {
+ throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
+ }
+
+ if (clauseEntry2 instanceof HigherOrderClauseEntry) {
+ arg2Node = ((HigherOrderClauseEntry) clauseEntry2).getBindableNode();
+
+ clauseEntries.addAll(((HigherOrderClauseEntry) clauseEntry2).getClauseEntries());
+ } else if (clauseEntry2 instanceof NodeClauseEntry) {
+ arg2Node = ((NodeClauseEntry) clauseEntry2).getNode();
+ } else {
+ throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
+ }
+
+ java.util.List<Node> nodes = new ArrayList<Node>();
+
+ nodes.add(arg1Node);
+ nodes.add(arg2Node);
+ nodes.add(arg3Node);
+
+ ClauseEntry clauseEntry = new Functor("product", nodes, new BuiltinRegistry());
+
+ clauseEntries.add(clauseEntry);
+
+ return (T) new HigherOrderClauseEntry(arg3Node, clauseEntries);
+
+ }
+
+}
Added: incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/NamespaceAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/NamespaceAtom.java?rev=1306351&view=auto
==============================================================================
--- incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/NamespaceAtom.java (added)
+++ incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/NamespaceAtom.java Wed Mar 28 14:09:58 2012
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.rules.adapters.jena.atoms;
+
+import org.apache.stanbol.rules.adapters.AbstractAdaptableAtom;
+import org.apache.stanbol.rules.base.api.RuleAtom;
+import org.apache.stanbol.rules.base.api.RuleAtomCallExeption;
+
+/**
+ *
+ * TODO
+ *
+ * @author anuzzolese
+ *
+ */
+public class NamespaceAtom extends AbstractAdaptableAtom {
+
+ @Override
+ public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption {
+ throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
+ }
+
+}
Added: incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/NewIRIAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/NewIRIAtom.java?rev=1306351&view=auto
==============================================================================
--- incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/NewIRIAtom.java (added)
+++ incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/NewIRIAtom.java Wed Mar 28 14:09:58 2012
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.rules.adapters.jena.atoms;
+
+import org.apache.stanbol.rules.adapters.AbstractAdaptableAtom;
+import org.apache.stanbol.rules.base.api.RuleAtom;
+import org.apache.stanbol.rules.base.api.RuleAtomCallExeption;
+
+/**
+ *
+ * TODO
+ *
+ * @author anuzzolese
+ *
+ */
+public class NewIRIAtom extends AbstractAdaptableAtom {
+
+ @Override
+ public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption {
+ throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
+ }
+
+}
Added: incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/NewLiteralAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/NewLiteralAtom.java?rev=1306351&view=auto
==============================================================================
--- incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/NewLiteralAtom.java (added)
+++ incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/NewLiteralAtom.java Wed Mar 28 14:09:58 2012
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.stanbol.rules.adapters.jena.atoms;
+
+import org.apache.stanbol.rules.adapters.AbstractAdaptableAtom;
+import org.apache.stanbol.rules.base.api.RuleAtom;
+import org.apache.stanbol.rules.base.api.RuleAtomCallExeption;
+
+/**
+ *
+ * TODO
+ *
+ * @author anuzzolese
+ *
+ */
+public class NewLiteralAtom extends AbstractAdaptableAtom {
+
+ @Override
+ public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption {
+ throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
+ }
+
+}
Added: incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/NotAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/NotAtom.java?rev=1306351&view=auto
==============================================================================
--- incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/NotAtom.java (added)
+++ incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/NotAtom.java Wed Mar 28 14:09:58 2012
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.rules.adapters.jena.atoms;
+
+import org.apache.stanbol.rules.adapters.AbstractAdaptableAtom;
+import org.apache.stanbol.rules.base.api.RuleAtom;
+import org.apache.stanbol.rules.base.api.RuleAtomCallExeption;
+
+/**
+ *
+ * TODO
+ *
+ * @author anuzzolese
+ *
+ */
+public class NotAtom extends AbstractAdaptableAtom {
+
+ @Override
+ public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption {
+ throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
+ }
+
+}
Added: incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/NumberAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/NumberAtom.java?rev=1306351&view=auto
==============================================================================
--- incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/NumberAtom.java (added)
+++ incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/NumberAtom.java Wed Mar 28 14:09:58 2012
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.rules.adapters.jena.atoms;
+
+import org.apache.stanbol.rules.adapters.AbstractAdaptableAtom;
+import org.apache.stanbol.rules.adapters.jena.NodeClauseEntry;
+import org.apache.stanbol.rules.adapters.jena.NodeFactory;
+import org.apache.stanbol.rules.base.api.RuleAtom;
+import org.apache.stanbol.rules.base.api.RuleAtomCallExeption;
+
+import com.hp.hpl.jena.graph.Node;
+import com.hp.hpl.jena.reasoner.rulesys.Node_RuleVariable;
+
+/**
+ *
+ * It adapts a NumberAtom to a literal node in Jena.
+ *
+ * @author anuzzolese
+ *
+ */
+public class NumberAtom extends AbstractAdaptableAtom {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption {
+ org.apache.stanbol.rules.manager.atoms.NumberAtom tmp = (org.apache.stanbol.rules.manager.atoms.NumberAtom) ruleAtom;
+
+ String number = tmp.getNumber();
+
+ Node node = null;
+
+ if (number.startsWith("?")) {
+
+ number = number.substring(1);
+
+ node = Node_RuleVariable.createVariable(number);
+ } else {
+
+ Number n = null;
+ if (number.contains("\\.")) {
+ int indexOfPoint = number.indexOf(".");
+
+ if (indexOfPoint == number.length() - 2) {
+ n = Float.parseFloat(number);
+ } else {
+ n = Double.parseDouble(number);
+ }
+ } else {
+ n = Integer.parseInt(number);
+ }
+
+ node = NodeFactory.getTypedLiteral(n);
+ }
+
+ return (T) new NodeClauseEntry(node);
+
+ }
+
+}
Added: incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/NumericVariableAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/NumericVariableAtom.java?rev=1306351&view=auto
==============================================================================
--- incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/NumericVariableAtom.java (added)
+++ incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/NumericVariableAtom.java Wed Mar 28 14:09:58 2012
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.stanbol.rules.adapters.jena.atoms;
+
+import java.net.URI;
+
+import org.apache.stanbol.rules.adapters.AbstractAdaptableAtom;
+import org.apache.stanbol.rules.adapters.jena.NodeClauseEntry;
+import org.apache.stanbol.rules.base.api.RuleAtom;
+import org.apache.stanbol.rules.base.api.RuleAtomCallExeption;
+import org.apache.stanbol.rules.base.api.Symbols;
+
+import com.hp.hpl.jena.reasoner.rulesys.Node_RuleVariable;
+
+/**
+ *
+ * It adapts a NumericVariableAtom to a variable node in Jena.
+ *
+ * @author anuzzolese
+ *
+ */
+public class NumericVariableAtom extends AbstractAdaptableAtom {
+
+ @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);
+ }
+
+ return (T) new NodeClauseEntry(Node_RuleVariable.createVariable(variable));
+ }
+}
Added: incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/PropStringAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/PropStringAtom.java?rev=1306351&view=auto
==============================================================================
--- incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/PropStringAtom.java (added)
+++ incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/PropStringAtom.java Wed Mar 28 14:09:58 2012
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.rules.adapters.jena.atoms;
+
+import org.apache.stanbol.rules.adapters.AbstractAdaptableAtom;
+import org.apache.stanbol.rules.base.api.RuleAtom;
+import org.apache.stanbol.rules.base.api.RuleAtomCallExeption;
+
+/**
+ *
+ * TODO
+ *
+ * @author anuzzolese
+ *
+ */
+public class PropStringAtom extends AbstractAdaptableAtom {
+
+ @Override
+ public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption {
+ throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
+ }
+
+}
Added: incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/ResourceAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/ResourceAtom.java?rev=1306351&view=auto
==============================================================================
--- incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/ResourceAtom.java (added)
+++ incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/ResourceAtom.java Wed Mar 28 14:09:58 2012
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.stanbol.rules.adapters.jena.atoms;
+
+import org.apache.stanbol.rules.adapters.AbstractAdaptableAtom;
+import org.apache.stanbol.rules.adapters.jena.NodeClauseEntry;
+import org.apache.stanbol.rules.base.api.RuleAtom;
+import org.apache.stanbol.rules.base.api.RuleAtomCallExeption;
+
+import com.hp.hpl.jena.graph.Node;
+import com.hp.hpl.jena.reasoner.rulesys.Node_RuleVariable;
+
+/**
+ *
+ * It adapts a ResourceAtom to a node in Jena.
+ *
+ * @author anuzzolese
+ *
+ */
+public class ResourceAtom extends AbstractAdaptableAtom {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption {
+
+ org.apache.stanbol.rules.manager.atoms.ResourceAtom tmp = (org.apache.stanbol.rules.manager.atoms.ResourceAtom) ruleAtom;
+
+ String unquotedURI = tmp.toUnquotedString();
+ Node node = Node_RuleVariable.createURI(unquotedURI);
+
+ return (T) new NodeClauseEntry(node);
+ }
+
+}
Added: incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/SameAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/SameAtom.java?rev=1306351&view=auto
==============================================================================
--- incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/SameAtom.java (added)
+++ incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/SameAtom.java Wed Mar 28 14:09:58 2012
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.rules.adapters.jena.atoms;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.stanbol.rules.adapters.AbstractAdaptableAtom;
+import org.apache.stanbol.rules.adapters.jena.HigherOrderClauseEntry;
+import org.apache.stanbol.rules.adapters.jena.NodeClauseEntry;
+import org.apache.stanbol.rules.base.api.RuleAtom;
+import org.apache.stanbol.rules.base.api.RuleAtomCallExeption;
+import org.apache.stanbol.rules.base.api.UnavailableRuleObjectException;
+import org.apache.stanbol.rules.base.api.UnsupportedTypeForExportException;
+import org.apache.stanbol.rules.manager.atoms.ExpressionAtom;
+
+import com.hp.hpl.jena.graph.Node;
+import com.hp.hpl.jena.reasoner.rulesys.BuiltinRegistry;
+import com.hp.hpl.jena.reasoner.rulesys.ClauseEntry;
+import com.hp.hpl.jena.reasoner.rulesys.Functor;
+import com.hp.hpl.jena.reasoner.rulesys.Rule;
+
+/**
+ *
+ * It adapts a SameAtom to equal functor of Jena.
+ *
+ * @author anuzzolese
+ *
+ */
+public class SameAtom extends AbstractAdaptableAtom {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption,
+ UnavailableRuleObjectException,
+ UnsupportedTypeForExportException {
+
+ Node arg1Node = null;
+ Node arg2Node = null;
+
+ org.apache.stanbol.rules.manager.atoms.SameAtom tmp = (org.apache.stanbol.rules.manager.atoms.SameAtom) ruleAtom;
+
+ ExpressionAtom argument1 = tmp.getStringFunctionAtom1();
+ ExpressionAtom argument2 = tmp.getStringFunctionAtom2();
+
+ ClauseEntry clauseEntry1 = adapter.adaptTo(argument1, Rule.class);
+ ClauseEntry clauseEntry2 = adapter.adaptTo(argument2, Rule.class);
+
+ List<ClauseEntry> clauseEntries = new ArrayList<ClauseEntry>();
+
+ if (clauseEntry1 instanceof HigherOrderClauseEntry) {
+ arg1Node = ((HigherOrderClauseEntry) clauseEntry1).getBindableNode();
+
+ clauseEntries.addAll(((HigherOrderClauseEntry) clauseEntry1).getClauseEntries());
+ } else if (clauseEntry1 instanceof NodeClauseEntry) {
+ arg1Node = ((NodeClauseEntry) clauseEntry1).getNode();
+ } else {
+ throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
+ }
+
+ if (clauseEntry2 instanceof HigherOrderClauseEntry) {
+ arg2Node = ((HigherOrderClauseEntry) clauseEntry2).getBindableNode();
+
+ clauseEntries.addAll(((HigherOrderClauseEntry) clauseEntry2).getClauseEntries());
+ } else if (clauseEntry2 instanceof NodeClauseEntry) {
+ arg2Node = ((NodeClauseEntry) clauseEntry2).getNode();
+ } else {
+ throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
+ }
+
+ java.util.List<Node> nodes = new ArrayList<Node>();
+
+ nodes.add(arg1Node);
+ nodes.add(arg2Node);
+
+ return (T) new Functor("equal", nodes, new BuiltinRegistry());
+
+ }
+
+}
Added: incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/StartsWithAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/StartsWithAtom.java?rev=1306351&view=auto
==============================================================================
--- incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/StartsWithAtom.java (added)
+++ incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/StartsWithAtom.java Wed Mar 28 14:09:58 2012
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.rules.adapters.jena.atoms;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.stanbol.rules.adapters.AbstractAdaptableAtom;
+import org.apache.stanbol.rules.adapters.jena.HigherOrderClauseEntry;
+import org.apache.stanbol.rules.adapters.jena.NodeClauseEntry;
+import org.apache.stanbol.rules.base.api.RuleAtom;
+import org.apache.stanbol.rules.base.api.RuleAtomCallExeption;
+import org.apache.stanbol.rules.base.api.UnavailableRuleObjectException;
+import org.apache.stanbol.rules.base.api.UnsupportedTypeForExportException;
+import org.apache.stanbol.rules.manager.atoms.ExpressionAtom;
+
+import com.hp.hpl.jena.graph.Node;
+import com.hp.hpl.jena.graph.impl.LiteralLabel;
+import com.hp.hpl.jena.reasoner.rulesys.BuiltinRegistry;
+import com.hp.hpl.jena.reasoner.rulesys.ClauseEntry;
+import com.hp.hpl.jena.reasoner.rulesys.Functor;
+import com.hp.hpl.jena.reasoner.rulesys.Node_RuleVariable;
+import com.hp.hpl.jena.reasoner.rulesys.Rule;
+
+/**
+ *
+ * It adapts a StartWithAtom to Jena functor that implements the start-with through a regex.
+ *
+ * @author anuzzolese
+ *
+ */
+public class StartsWithAtom extends AbstractAdaptableAtom {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption,
+ UnavailableRuleObjectException,
+ UnsupportedTypeForExportException {
+
+ Node arg1Node = null;
+ Node arg2Node = null;
+
+ org.apache.stanbol.rules.manager.atoms.EndsWithAtom tmp = (org.apache.stanbol.rules.manager.atoms.EndsWithAtom) ruleAtom;
+
+ ExpressionAtom argument = tmp.getArgument();
+ ExpressionAtom term = tmp.getTerm();
+
+ ClauseEntry clauseEntry1 = adapter.adaptTo(argument, Rule.class);
+ ClauseEntry clauseEntry2 = adapter.adaptTo(term, Rule.class);
+
+ List<ClauseEntry> clauseEntries = new ArrayList<ClauseEntry>();
+
+ if (clauseEntry1 instanceof HigherOrderClauseEntry) {
+ arg1Node = ((HigherOrderClauseEntry) clauseEntry1).getBindableNode();
+
+ clauseEntries.addAll(((HigherOrderClauseEntry) clauseEntry1).getClauseEntries());
+ } else if (clauseEntry1 instanceof NodeClauseEntry) {
+ arg1Node = ((NodeClauseEntry) clauseEntry1).getNode();
+ } else {
+ throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
+ }
+
+ if (clauseEntry2 instanceof HigherOrderClauseEntry) {
+ arg2Node = ((HigherOrderClauseEntry) clauseEntry2).getBindableNode();
+
+ clauseEntries.addAll(((HigherOrderClauseEntry) clauseEntry2).getClauseEntries());
+ } else if (clauseEntry2 instanceof NodeClauseEntry) {
+ Node tmpNode = ((NodeClauseEntry) clauseEntry2).getNode();
+ LiteralLabel literalLabel = tmpNode.getLiteral();
+ String lexicalForm = literalLabel.getLexicalForm();
+
+ StringBuilder sb = new StringBuilder();
+ sb.append("^");
+ sb.append(lexicalForm);
+
+ String regex = sb.toString();
+
+ arg2Node = Node_RuleVariable.createLiteral(regex);
+ } else {
+ throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
+ }
+
+ java.util.List<Node> nodes = new ArrayList<Node>();
+
+ nodes.add(arg1Node);
+ nodes.add(arg2Node);
+
+ return (T) new Functor("regex", nodes, new BuiltinRegistry());
+
+ }
+
+}
Added: incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/StrAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/StrAtom.java?rev=1306351&view=auto
==============================================================================
--- incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/StrAtom.java (added)
+++ incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/StrAtom.java Wed Mar 28 14:09:58 2012
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.rules.adapters.jena.atoms;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.stanbol.rules.adapters.AbstractAdaptableAtom;
+import org.apache.stanbol.rules.adapters.jena.NodeClauseEntry;
+import org.apache.stanbol.rules.base.api.RuleAtom;
+import org.apache.stanbol.rules.base.api.RuleAtomCallExeption;
+import org.apache.stanbol.rules.base.api.UnavailableRuleObjectException;
+import org.apache.stanbol.rules.base.api.UnsupportedTypeForExportException;
+import org.apache.stanbol.rules.manager.atoms.IObjectAtom;
+
+import com.hp.hpl.jena.graph.Node;
+import com.hp.hpl.jena.reasoner.rulesys.ClauseEntry;
+import com.hp.hpl.jena.reasoner.rulesys.Functor;
+import com.hp.hpl.jena.reasoner.rulesys.Node_RuleVariable;
+import com.hp.hpl.jena.reasoner.rulesys.Rule;
+
+/**
+ * It adapts a StrAtom to the Jena strConcat functor.<br/>
+ * In this case the strConcat returns the concatenation of the string representation of the literal with the
+ * empty string.
+ *
+ * @author anuzzolese
+ *
+ */
+public class StrAtom extends AbstractAdaptableAtom {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption,
+ UnavailableRuleObjectException,
+ UnsupportedTypeForExportException {
+ org.apache.stanbol.rules.manager.atoms.StrAtom tmp = (org.apache.stanbol.rules.manager.atoms.StrAtom) ruleAtom;
+
+ IObjectAtom iObjectAtom = tmp.getUriResource();
+
+ ClauseEntry iObjectClauseEntry = (ClauseEntry) adapter.adaptTo(iObjectAtom, Rule.class);
+
+ if (iObjectClauseEntry instanceof NodeClauseEntry) {
+ Node node = ((NodeClauseEntry) iObjectClauseEntry).getNode();
+
+ Node emptyString = Node_RuleVariable.createLiteral("");
+
+ Node bindind = Node_RuleVariable.createVariable("str_reuslt" + System.currentTimeMillis());
+
+ List<Node> args = new ArrayList<Node>();
+ args.add(node);
+ args.add(emptyString);
+ args.add(bindind);
+
+ return (T) new Functor("strConcat", args);
+
+ } else {
+ throw new RuleAtomCallExeption(getClass());
+ }
+ }
+
+}
Added: incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/StringAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/StringAtom.java?rev=1306351&view=auto
==============================================================================
--- incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/StringAtom.java (added)
+++ incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/StringAtom.java Wed Mar 28 14:09:58 2012
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.rules.adapters.jena.atoms;
+
+import org.apache.stanbol.rules.adapters.AbstractAdaptableAtom;
+import org.apache.stanbol.rules.adapters.jena.NodeClauseEntry;
+import org.apache.stanbol.rules.adapters.jena.NodeFactory;
+import org.apache.stanbol.rules.base.api.RuleAtom;
+import org.apache.stanbol.rules.base.api.RuleAtomCallExeption;
+import org.apache.stanbol.rules.base.api.Symbols;
+
+import com.hp.hpl.jena.graph.Node;
+import com.hp.hpl.jena.reasoner.rulesys.Node_RuleVariable;
+
+/**
+ * It adapts a StringAtom to a litaral node in Jena.
+ *
+ * @author anuzzolese
+ *
+ */
+public class StringAtom extends AbstractAdaptableAtom {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption {
+ org.apache.stanbol.rules.manager.atoms.StringAtom tmp = (org.apache.stanbol.rules.manager.atoms.StringAtom) ruleAtom;
+
+ String string = tmp.getString();
+
+ Node node = null;
+
+ if (string.startsWith(Symbols.variablesPrefix)) {
+ string = string.replace(Symbols.variablesPrefix, "");
+
+ if (string.startsWith("?")) {
+ string = string.substring(1);
+ }
+
+ node = Node_RuleVariable.createVariable(string);
+ } else {
+
+ node = NodeFactory.getTypedLiteral(string);
+ }
+
+ return (T) new NodeClauseEntry(node);
+
+ }
+
+}
Added: incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/StringVariableAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/StringVariableAtom.java?rev=1306351&view=auto
==============================================================================
--- incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/StringVariableAtom.java (added)
+++ incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/StringVariableAtom.java Wed Mar 28 14:09:58 2012
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.stanbol.rules.adapters.jena.atoms;
+
+import java.net.URI;
+
+import org.apache.stanbol.rules.adapters.AbstractAdaptableAtom;
+import org.apache.stanbol.rules.adapters.jena.NodeClauseEntry;
+import org.apache.stanbol.rules.base.api.RuleAtom;
+import org.apache.stanbol.rules.base.api.RuleAtomCallExeption;
+import org.apache.stanbol.rules.base.api.Symbols;
+
+import com.hp.hpl.jena.reasoner.rulesys.Node_RuleVariable;
+
+/**
+ * It adapts a StringVariableAtom to a node variable in Jena.
+ *
+ * @author anuzzolese
+ *
+ */
+public class StringVariableAtom extends AbstractAdaptableAtom {
+
+ @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);
+ }
+
+ return (T) new NodeClauseEntry(Node_RuleVariable.createVariable(variable));
+ }
+}
Added: incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/SubstringAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/SubstringAtom.java?rev=1306351&view=auto
==============================================================================
--- incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/SubstringAtom.java (added)
+++ incubator/stanbol/trunk/rules/adapters/jena/src/main/java/org/apache/stanbol/rules/adapters/jena/atoms/SubstringAtom.java Wed Mar 28 14:09:58 2012
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.rules.adapters.jena.atoms;
+
+import org.apache.stanbol.rules.adapters.AbstractAdaptableAtom;
+import org.apache.stanbol.rules.base.api.RuleAtom;
+import org.apache.stanbol.rules.base.api.RuleAtomCallExeption;
+
+/**
+ * TODO
+ *
+ * @author anuzzolese
+ *
+ */
+public class SubstringAtom extends AbstractAdaptableAtom {
+
+ @Override
+ public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption {
+ throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
+ }
+
+}