From 5f9d9e440b969efefc0023f6b990bcdcfebade73 Mon Sep 17 00:00:00 2001 From: richie Date: Fri, 19 Oct 2018 16:48:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin-function/build.xml | 126 ++++++++++++++++++ plugin-function/plugin.xml | 17 +++ plugin-function/pom.xml | 14 ++ .../src/main/java/com/fr/plugin/MyAbs.java | 30 +++++ 4 files changed, 187 insertions(+) create mode 100644 plugin-function/build.xml create mode 100644 plugin-function/plugin.xml create mode 100644 plugin-function/pom.xml create mode 100644 plugin-function/src/main/java/com/fr/plugin/MyAbs.java diff --git a/plugin-function/build.xml b/plugin-function/build.xml new file mode 100644 index 0000000..59ae0c1 --- /dev/null +++ b/plugin-function/build.xml @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugin-function/plugin.xml b/plugin-function/plugin.xml new file mode 100644 index 0000000..4816b1a --- /dev/null +++ b/plugin-function/plugin.xml @@ -0,0 +1,17 @@ + + com.fr.plugin.function.test + + yes + 1.0 + 10.0 + 2018-07-31 + author + + + [2018-07-31]初始化插件。
+ ]]>
+ + + +
\ No newline at end of file diff --git a/plugin-function/pom.xml b/plugin-function/pom.xml new file mode 100644 index 0000000..ada9db6 --- /dev/null +++ b/plugin-function/pom.xml @@ -0,0 +1,14 @@ + + + 4.0.0 + + + com.fr.plugin + plugins + 1.0 + + jar + plugin-function + \ 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 new file mode 100644 index 0000000..78dab4c --- /dev/null +++ b/plugin-function/src/main/java/com/fr/plugin/MyAbs.java @@ -0,0 +1,30 @@ +package com.fr.plugin; + +import com.fr.general.FArray; +import com.fr.general.GeneralUtils; +import com.fr.intelli.record.Focus; +import com.fr.intelli.record.Original; +import com.fr.record.analyzer.EnableMetrics; +import com.fr.script.AbstractFunction; +import com.fr.stable.ArrayUtils; +import com.fr.stable.Primitive; + +@EnableMetrics +public class MyAbs extends AbstractFunction { + + @Focus(id = "com.fr.plugin.function.test", text = "Function description", source = Original.PLUGIN) + public Object run(Object[] args) { + int len = ArrayUtils.getLength(args); + if (len == 0) { + return Primitive.ERROR_VALUE; + } else if (len == 1) { + return Math.abs(GeneralUtils.objectToNumber(args[0]).doubleValue()); + } else { + FArray result = new FArray(); + for (Object arg : args) { + result.add(GeneralUtils.objectToNumber(arg).doubleValue()); + } + } + return Primitive.ERROR_VALUE; + } +}