function element used in a SPARQL query must implement the Jena Function interface. This function will be created by the factory by the FunctionFactory.create(String) method.Function interface. It is rather better to extend one of the following abstract classes:exec(...) method for each class:NodeValue class has many static methods allowing to:NodeValue to the associated Object underlying this nodeNodeValue from an Objectpublic class oppositeFunction extends FunctionBase2 { public oppositeFunction() { super(); } public NodeValue exec(NodeValue hypothenusenv, NodeValue anglenv) { float hypothenuse = hypothenusenv.getFloat(); float angle = anglenv.getFloat(); float opposite = (float)(hypothenuse * Math.sin(angle)); return NodeValue.makeFloat(opposite); } }
Copyright 2017-2020 Dassault Aviation. All Rights Reserved. Documentation and source under the LGPL v3 licence