3
0
RandomSec/main/src/com/google/refine/expr/functions/math/Ln.java
David Huynh 1de5e7c00e Renamed package gel to grel.
Replaced gel with grel in other places in the code base while maintaining backward compatibility.
Changed layout in expression preview dialog to accommodate long GREL name.

git-svn-id: http://google-refine.googlecode.com/svn/trunk@1442 7d457c2a-affb-35e4-300a-418c747d4874
2010-10-07 05:19:35 +00:00

31 lines
984 B
Java

package com.google.refine.expr.functions.math;
import java.util.Properties;
import org.json.JSONException;
import org.json.JSONWriter;
import com.google.refine.expr.EvalError;
import com.google.refine.grel.ControlFunctionRegistry;
import com.google.refine.grel.Function;
public class Ln implements Function {
public Object call(Properties bindings, Object[] args) {
if (args.length == 1 && args[0] != null && args[0] instanceof Number) {
return Math.log(((Number) args[0]).doubleValue());
}
return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects a number");
}
public void write(JSONWriter writer, Properties options)
throws JSONException {
writer.object();
writer.key("description"); writer.value("Returns the natural log of n");
writer.key("params"); writer.value("number n");
writer.key("returns"); writer.value("number");
writer.endObject();
}
}