![Stefano Mazzocchi](/assets/img/avatar_default.png)
git-svn-id: http://google-refine.googlecode.com/svn/branches/split-refactor@905 7d457c2a-affb-35e4-300a-418c747d4874
31 lines
1001 B
Java
31 lines
1001 B
Java
package com.metaweb.gridworks.expr.functions.math;
|
|
|
|
import java.util.Properties;
|
|
|
|
import org.json.JSONException;
|
|
import org.json.JSONWriter;
|
|
|
|
import com.metaweb.gridworks.expr.EvalError;
|
|
import com.metaweb.gridworks.gel.ControlFunctionRegistry;
|
|
import com.metaweb.gridworks.gel.Function;
|
|
|
|
public class Log implements Function {
|
|
|
|
public Object call(Properties bindings, Object[] args) {
|
|
if (args.length == 1 && args[0] != null && args[0] instanceof Number) {
|
|
return Math.log10(((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 base 10 log of n");
|
|
writer.key("params"); writer.value("number n");
|
|
writer.key("returns"); writer.value("number");
|
|
writer.endObject();
|
|
}
|
|
}
|