From 55ce7b22afea6a58fbd7cd7fd45791f4edf8c771 Mon Sep 17 00:00:00 2001 From: richie Date: Mon, 22 Oct 2018 14:57:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8E=88=E6=9D=83=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E7=9A=84=E7=BC=96=E5=86=99=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin-function/build.xml | 2 +- plugin-function/lib/report/.gitkeep | 0 plugin-function/plugin.xml | 1 + .../src/main/java/com/fr/plugin/MyAbs.java | 17 ++++++++++++++--- 4 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 plugin-function/lib/report/.gitkeep diff --git a/plugin-function/build.xml b/plugin-function/build.xml index e807443..7fe1db7 100644 --- a/plugin-function/build.xml +++ b/plugin-function/build.xml @@ -5,7 +5,7 @@ - + diff --git a/plugin-function/lib/report/.gitkeep b/plugin-function/lib/report/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/plugin-function/plugin.xml b/plugin-function/plugin.xml index 9c96a7f..a45d02f 100644 --- a/plugin-function/plugin.xml +++ b/plugin-function/plugin.xml @@ -15,4 +15,5 @@ + \ No newline at end of file diff --git a/plugin-function/src/main/java/com/fr/plugin/MyAbs.java b/plugin-function/src/main/java/com/fr/plugin/MyAbs.java index c5ed012..ffddecc 100644 --- a/plugin-function/src/main/java/com/fr/plugin/MyAbs.java +++ b/plugin-function/src/main/java/com/fr/plugin/MyAbs.java @@ -24,13 +24,24 @@ public class MyAbs extends AbstractFunction { if (len == 0) { return Primitive.ERROR_VALUE; } else if (len == 1) { - return Math.abs(GeneralUtils.objectToNumber(args[0]).doubleValue()); + Object one = args[0]; + if (one instanceof FArray) { + FArray data = (FArray)one; + FArray result = new FArray(); + for (Object el : data) { + result.add(Math.abs(GeneralUtils.objectToNumber(el).doubleValue())); + } + return result; + } else { + return Math.abs(GeneralUtils.objectToNumber(one).doubleValue()); + } } else { FArray result = new FArray(); for (Object arg : args) { - result.add(GeneralUtils.objectToNumber(arg).doubleValue()); + result.add(Math.abs(GeneralUtils.objectToNumber(arg).doubleValue())); } + return result; } - return Primitive.ERROR_VALUE; + } }