You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hop.apache.org by ha...@apache.org on 2025/10/14 14:08:31 UTC
(hop) branch main updated: Clean up Calculator code (#5752)
This is an automated email from the ASF dual-hosted git repository.
hansva pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hop.git
The following commit(s) were added to refs/heads/main by this push:
new ad5454e481 Clean up Calculator code (#5752)
ad5454e481 is described below
commit ad5454e48154c5a411ccef5ad66cd17b98a135df
Author: Alex Mueller <te...@ambiac.de>
AuthorDate: Tue Oct 14 16:08:24 2025 +0200
Clean up Calculator code (#5752)
* chore: refactored calculation types into separate classes. #5582
fix: altered Nvl not to override resultType with NONE when an fieldA type is available
fix: "registered" YearOfDateISO8601 calculation
[DOCS] add/rename calculation types to comply with implementation
* Add missing unit test for calculator
---------
Co-authored-by: Alex Mueller <al...@ambiac.de>
Co-authored-by: Hans Van Akelyen <ha...@gmail.com>
---
.../ROOT/pages/pipeline/transforms/calculator.adoc | 35 +-
.../transforms/main-0011-calculator.hwf | 13 +-
.../transforms/calculator/CalculationInput.java | 53 ++
...orValueDataUtil.java => CalculationOutput.java} | 21 +-
.../transforms/calculator/CalculationType.java | 235 ++++++
.../pipeline/transforms/calculator/Calculator.java | 492 +----------
.../transforms/calculator/CalculatorDialog.java | 6 +-
.../transforms/calculator/CalculatorMeta.java | 2 +-
.../calculator/CalculatorMetaFunction.java | 400 ---------
.../transforms/calculator/ICalculation.java | 49 ++
.../calculator/calculations/Constant.java | 49 ++
.../calculator/calculations/CopyField.java | 49 ++
.../transforms/calculator/calculations/None.java | 45 ++
.../transforms/calculator/calculations/Nvl.java | 53 ++
.../calculations/conversion/Base64Decode.java | 64 ++
.../calculations/conversion/Base64Encode.java | 62 ++
.../conversion/Base64EncodePadded.java | 62 ++
.../calculations/conversion/ByteToHexEncode.java | 52 ++
.../calculations/conversion/CharToHexEncode.java | 52 ++
.../calculations/conversion/EscapeHTML.java | 51 ++
.../calculations/conversion/EscapeSQL.java | 51 ++
.../calculations/conversion/HexToByteDecode.java | 52 ++
.../calculations/conversion/HexToCharDecode.java | 52 ++
.../calculations/conversion/MaskXML.java | 52 ++
.../calculations/conversion/UnescapeHTML.java | 51 ++
.../calculations/conversion/UnescapeXML.java | 51 ++
.../calculations/conversion/UseCDATA.java | 51 ++
.../calculator/calculations/date/AddDays.java | 52 ++
.../calculator/calculations/date/AddHours.java | 52 ++
.../calculator/calculations/date/AddMinutes.java | 52 ++
.../calculator/calculations/date/AddMonths.java | 52 ++
.../calculator/calculations/date/AddSeconds.java | 52 ++
.../calculations/date/AddTimeToDate.java | 53 ++
.../calculator/calculations/date/DateDiff.java | 74 ++
.../calculations/date/DateWorkingDiff.java | 53 ++
.../calculator/calculations/date/DayOfMonth.java | 52 ++
.../calculator/calculations/date/DayOfWeek.java | 52 ++
.../calculator/calculations/date/DayOfYear.java | 52 ++
.../calculations/date/FirstDayOfMonth.java | 65 ++
.../calculator/calculations/date/HourOfDay.java | 52 ++
.../calculations/date/LastDayOfMonth.java | 65 ++
.../calculator/calculations/date/MinuteOfHour.java | 52 ++
.../calculator/calculations/date/MonthOfDate.java | 52 ++
.../calculations/date/QuarterOfDate.java | 52 ++
.../calculations/date/RemoveTimeFromDate.java | 52 ++
.../calculations/date/SecondOfMinute.java | 52 ++
.../calculator/calculations/date/WeekOfYear.java | 52 ++
.../calculations/date/WeekOfYearISO8601.java | 52 ++
.../calculator/calculations/date/YearOfDate.java | 52 ++
.../calculations/date/YearOfDateISO8601.java | 52 ++
.../calculator/calculations/file/ADLER32.java | 53 ++
.../calculator/calculations/file/CRC32.java | 52 ++
.../calculations/file/CheckXMLFileWellFormed.java | 55 ++
.../calculations/file/GetFileEncoding.java | 55 ++
.../calculations/file/LoadFileContentBinary.java | 56 ++
.../calculations/file/MessageDigest.java | 74 ++
.../calculator/calculations/math/Abs.java | 52 ++
.../calculator/calculations/math/Add.java | 53 ++
.../calculator/calculations/math/Add3.java | 53 ++
.../calculator/calculations/math/Ceil.java | 52 ++
.../calculator/calculations/math/Combination1.java | 49 ++
.../calculator/calculations/math/Combination2.java | 53 ++
.../calculator/calculations/math/Divide.java | 49 ++
.../calculator/calculations/math/Floor.java | 52 ++
.../calculations/math/GetOnlyDigits.java | 52 ++
.../calculator/calculations/math/Multiply.java | 53 ++
.../calculator/calculations/math/Percent1.java | 49 ++
.../calculator/calculations/math/Percent2.java | 49 ++
.../calculator/calculations/math/Percent3.java | 49 ++
.../calculator/calculations/math/Remainder.java | 64 ++
.../calculator/calculations/math/RemoveDigits.java | 52 ++
.../calculator/calculations/math/Round1.java | 52 ++
.../calculator/calculations/math/Round2.java | 53 ++
.../calculator/calculations/math/RoundCustom1.java | 53 ++
.../calculator/calculations/math/RoundCustom2.java | 54 ++
.../calculator/calculations/math/RoundStd1.java | 53 ++
.../calculator/calculations/math/RoundStd2.java | 54 ++
.../calculator/calculations/math/Square.java | 49 ++
.../calculator/calculations/math/SquareRoot.java | 52 ++
.../calculator/calculations/math/Subtract.java | 51 ++
.../statistics/DamerauLevenshtein.java | 52 ++
.../calculations/statistics/DoubleMetaphone.java | 51 ++
.../calculator/calculations/statistics/Jaro.java | 52 ++
.../calculations/statistics/JaroWinkler.java | 52 ++
.../statistics/LevenshteinDistance.java | 52 ++
.../calculations/statistics/Metaphone.java | 51 ++
.../calculations/statistics/NeedlemanWunsch.java | 63 ++
.../calculations/statistics/RefinedSoundex.java | 51 ++
.../calculations/statistics/Soundex.java | 51 ++
.../calculations/text/CheckXmlWellFormed.java | 51 ++
.../calculator/calculations/text/InitCap.java | 50 ++
.../calculator/calculations/text/LowerCase.java | 51 ++
.../calculator/calculations/text/RemoveCR.java | 51 ++
.../calculator/calculations/text/RemoveCRLF.java | 51 ++
.../calculator/calculations/text/RemoveLF.java | 51 ++
.../calculator/calculations/text/RemoveTab.java | 51 ++
.../calculator/calculations/text/StringLen.java | 51 ++
.../calculations/text/SubstituteVariable.java | 49 ++
.../calculator/calculations/text/UpperCase.java | 51 ++
.../calculator/CalculatorMetaFunctionTest.java | 4 +-
.../transforms/calculator/CalculatorMetaTest.java | 4 +-
.../transforms/calculator/CalculatorUnitTest.java | 22 +-
.../calculator/CalculatorValueDataUtilTest.java | 896 +++++----------------
103 files changed, 5335 insertions(+), 1621 deletions(-)
diff --git a/docs/hop-user-manual/modules/ROOT/pages/pipeline/transforms/calculator.adoc b/docs/hop-user-manual/modules/ROOT/pages/pipeline/transforms/calculator.adoc
index 373e09e09b..382d0d6479 100644
--- a/docs/hop-user-manual/modules/ROOT/pages/pipeline/transforms/calculator.adoc
+++ b/docs/hop-user-manual/modules/ROOT/pages/pipeline/transforms/calculator.adoc
@@ -20,35 +20,36 @@ under the License.
= image:transforms/icons/calculator.svg[Calculator transform Icon, role="image-doc-icon"] Calculator
-[%noheader,cols="3a,1a", role="table-no-borders" ]
+[%noheader,cols="3a,1a",role="table-no-borders" ]
|===
|
+
== Description
The Calculator transform provides you with predefined functions that can be executed on input field values.
In addition to the arguments (Field A, Field B and Field C) you must also specify the return type of the function.
-You can choose to remove fields (with the `Remove` option) from the result (output) after all values are calculated. This is useful in cases where you use temporary values that don't need to end up in your pipeline fields.
+You can choose to remove fields (with the `Remove` option) from the result (output) after all values are calculated.
+This is useful in cases where you use temporary values that don't need to end up in your pipeline fields.
TIP: The execution speed of the Calculator is far better than the speed provided by custom scripts (JavaScript).
+| == Supported Engines
-|
-== Supported Engines
-[%noheader,cols="2,1a",frame=none, role="table-supported-engines"]
+[%noheader,cols="2,1a",frame=none,role="table-supported-engines"]
!===
-!Hop Engine! image:check_mark.svg[Supported, 24]
-!Spark! image:check_mark.svg[Supported, 24]
-!Flink! image:check_mark.svg[Supported, 24]
-!Dataflow! image:check_mark.svg[Supported, 24]
+!Hop Engine! image:check_mark.svg[Supported,24]
+!Spark! image:check_mark.svg[Supported,24]
+!Flink! image:check_mark.svg[Supported,24]
+!Dataflow! image:check_mark.svg[Supported,24]
!===
-|===
+|===
== Options
-[%header, width="90%", cols="1,3"]
+[%header,width="90%",cols="1,3"]
|===
|Column|Description
|New field|The output field for the calculation result. Set `Remove` to `Y` for temporary fields that are required to calculate later fields, but are not needed in the final result.
@@ -68,7 +69,7 @@ TIP: The execution speed of the Calculator is far better than the speed provided
The table below lists the supported calculations in the `Calculator` transform:
-[options=header, width="90%', cols="2,3,1"]
+[options=header,width="90%', cols="2,3,1"]
|===
|Function (Hop GUI view)|Function (Metadata Injection view)|Description
|Set field to constant A|CONSTANT|
@@ -118,6 +119,9 @@ If you need non-integer calculations, please add a second calculation with hours
|Checksum of a file A using Adler-32|ADLER32|Calculate the checksum of a file using Adler-32.
|Checksum of a file A using MD5|MD5|Calculate the checksum of a file using MD5.
|Checksum of a file A using SHA-1|SHA1|Calculate the checksum of a file using SHA-1.
+|Checksum of a file A using SHA-256|SHA256|Calculate the checksum of a file using SHA-256.
+|Checksum of a file A using SHA-384|SHA384|Calculate the checksum of a file using SHA-384.
+|Checksum of a file A using SHA-512|SHA512|Calculate the checksum of a file using SHA-512.
|Levenshtein Distance (Source A and Target B)|LEVENSHTEIN_DISTANCE|Calculates the Levenshtein Distance: http://en.wikipedia.org/wiki/Levenshtein_distance
|Metaphone of A (Phonetics)|METAPHONE|Calculates the metaphone of A: http://en.wikipedia.org/wiki/Metaphone
|Double metaphone of A|DOUBLE_METAPHONE|Calculates the double metaphone of A: http://en.wikipedia.org/wiki/Double_Metaphone
@@ -127,7 +131,7 @@ So, there is one date in one year in these regions where this function will fail
It is not an issue for Europe, the US and other regions where the time changes at 1:00 or 2:00 or 3:00 am.
|Date A - Date B (in days)|DATE_DIFF|Calculates difference, in days, between A date field and B date field.
|A + B + C|ADD3|A plus B plus C.
-|First letter of each word of a string A in capital|INITCAP|Transforms the first letter of each word within a string.
+|First letter of each word of a string A in capital|INIT_CAP|Transforms the first letter of each word within a string.
|UpperCase of a string A|UPPER_CASE|Transforms a string to uppercase.
|LowerCase of a string A|LOWER_CASE|Transforms a string to lowercase.
|Mask XML content from string A|MASK_XML|Escape XML content; replace characters with &values.
@@ -189,11 +193,14 @@ TIP: Only integer values for B are supported. If you need non-integer calculatio
|Base64 Encode|BASE64_ENCODE|Encode a string in Base64 encoding without padding at the end
|Base64 Encode (padded)|BASE64_ENCODE_PADDED|Encode a string in Base64 encoding with padding at the end, cf. https://doi.org/10.17487/RFC4648[section 3.2 of RFC 4648]
|Base64 Decode|BASE64_DECODE|Decode a Base64 encoded string. Supports both padded or non-padded input.
+|First day of month (A) date|FIRST_DAY_OF_MONTH|Set the day of field (A) to 1.
+|Last day of month (A) date|LAST_DAY_OF_MONTH|Set the day of field (A) to the last day of the given month.
|===
== Metadata Injection support
-All fields of this transform support metadata injection. You can use this transform with ETL Metadata Injection to pass metadata to your pipeline at runtime.
+All fields of this transform support metadata injection.
+You can use this transform with ETL Metadata Injection to pass metadata to your pipeline at runtime.
Use the values in the column "Function (Metadata Injection view)" from the table above to specify the operation (Calculation type) applied to the fields.
diff --git a/integration-tests/transforms/main-0011-calculator.hwf b/integration-tests/transforms/main-0011-calculator.hwf
index 621e5305ce..f48a67f054 100644
--- a/integration-tests/transforms/main-0011-calculator.hwf
+++ b/integration-tests/transforms/main-0011-calculator.hwf
@@ -36,14 +36,15 @@ limitations under the License.
<description/>
<type>SPECIAL</type>
<attributes/>
- <repeat>N</repeat>
- <schedulerType>0</schedulerType>
- <intervalSeconds>0</intervalSeconds>
- <intervalMinutes>60</intervalMinutes>
+ <DayOfMonth>1</DayOfMonth>
+ <doNotWaitOnFirstExecution>N</doNotWaitOnFirstExecution>
<hour>12</hour>
+ <intervalMinutes>60</intervalMinutes>
+ <intervalSeconds>0</intervalSeconds>
<minutes>0</minutes>
+ <repeat>N</repeat>
+ <schedulerType>0</schedulerType>
<weekDay>1</weekDay>
- <DayOfMonth>1</DayOfMonth>
<parallel>N</parallel>
<xloc>128</xloc>
<yloc>112</yloc>
@@ -62,7 +63,7 @@ limitations under the License.
<name>0011-calculator-basics UNIT</name>
</test_name>
<test_name>
- <name>0011-calculator-basics UNIT</name>
+ <name>0011-calculator-dates UNIT</name>
</test_name>
</test_names>
<parallel>N</parallel>
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/CalculationInput.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/CalculationInput.java
new file mode 100644
index 0000000000..2078a66c66
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/CalculationInput.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator;
+
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.variables.IVariables;
+
+public class CalculationInput {
+ public final IValueMeta metaA, metaB, metaC;
+ public final Object dataA, dataB, dataC;
+ public final CalculatorMetaFunction calcMetaFn;
+ public final IValueMeta targetMeta;
+ public final IVariables variables;
+ public final boolean isFailIfNoFile;
+
+ public CalculationInput(
+ IValueMeta metaA,
+ IValueMeta metaB,
+ IValueMeta metaC,
+ Object dataA,
+ Object dataB,
+ Object dataC,
+ CalculatorMetaFunction calcMetaFn,
+ IValueMeta targetMeta,
+ IVariables variables,
+ boolean isFailIfNoFile) {
+ this.metaA = metaA;
+ this.metaB = metaB;
+ this.metaC = metaC;
+ this.dataA = dataA;
+ this.dataB = dataB;
+ this.dataC = dataC;
+ this.calcMetaFn = calcMetaFn;
+ this.targetMeta = targetMeta;
+ this.variables = variables;
+ this.isFailIfNoFile = isFailIfNoFile;
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/CalculatorValueDataUtil.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/CalculationOutput.java
similarity index 58%
rename from plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/CalculatorValueDataUtil.java
rename to plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/CalculationOutput.java
index 90563ed7c4..98310de87b 100644
--- a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/CalculatorValueDataUtil.java
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/CalculationOutput.java
@@ -17,21 +17,12 @@
package org.apache.hop.pipeline.transforms.calculator;
-import com.wcohen.ss.NeedlemanWunsch;
+public class CalculationOutput {
+ public final int resultType;
+ public final Object value;
-class CalculatorValueDataUtil {
-
- private CalculatorValueDataUtil() {}
-
- /**
- * NeedlemanWunsch distance is a measure of the similarity between two strings, which we will
- * refer to as the source string (s) and the target string (t). The distance is the number of
- * deletions, insertions, or substitutions required to transform s into t.
- */
- public static Long getNeedlemanWunschDistance(Object dataA, Object dataB) {
- if (dataA == null || dataB == null) {
- return null;
- }
- return (long) new NeedlemanWunsch().score(dataA.toString(), dataB.toString());
+ public CalculationOutput(int resultType, Object value) {
+ this.resultType = resultType;
+ this.value = value;
}
}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/CalculationType.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/CalculationType.java
new file mode 100644
index 0000000000..debae69ac1
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/CalculationType.java
@@ -0,0 +1,235 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator;
+
+import java.util.stream.Stream;
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.hop.metadata.api.IEnumHasCodeAndDescription;
+import org.apache.hop.pipeline.transforms.calculator.calculations.Constant;
+import org.apache.hop.pipeline.transforms.calculator.calculations.CopyField;
+import org.apache.hop.pipeline.transforms.calculator.calculations.None;
+import org.apache.hop.pipeline.transforms.calculator.calculations.Nvl;
+import org.apache.hop.pipeline.transforms.calculator.calculations.conversion.Base64Decode;
+import org.apache.hop.pipeline.transforms.calculator.calculations.conversion.Base64Encode;
+import org.apache.hop.pipeline.transforms.calculator.calculations.conversion.Base64EncodePadded;
+import org.apache.hop.pipeline.transforms.calculator.calculations.conversion.ByteToHexEncode;
+import org.apache.hop.pipeline.transforms.calculator.calculations.conversion.CharToHexEncode;
+import org.apache.hop.pipeline.transforms.calculator.calculations.conversion.EscapeHTML;
+import org.apache.hop.pipeline.transforms.calculator.calculations.conversion.EscapeSQL;
+import org.apache.hop.pipeline.transforms.calculator.calculations.conversion.HexToByteDecode;
+import org.apache.hop.pipeline.transforms.calculator.calculations.conversion.HexToCharDecode;
+import org.apache.hop.pipeline.transforms.calculator.calculations.conversion.MaskXML;
+import org.apache.hop.pipeline.transforms.calculator.calculations.conversion.UnescapeHTML;
+import org.apache.hop.pipeline.transforms.calculator.calculations.conversion.UnescapeXML;
+import org.apache.hop.pipeline.transforms.calculator.calculations.conversion.UseCDATA;
+import org.apache.hop.pipeline.transforms.calculator.calculations.date.AddDays;
+import org.apache.hop.pipeline.transforms.calculator.calculations.date.AddHours;
+import org.apache.hop.pipeline.transforms.calculator.calculations.date.AddMinutes;
+import org.apache.hop.pipeline.transforms.calculator.calculations.date.AddMonths;
+import org.apache.hop.pipeline.transforms.calculator.calculations.date.AddSeconds;
+import org.apache.hop.pipeline.transforms.calculator.calculations.date.AddTimeToDate;
+import org.apache.hop.pipeline.transforms.calculator.calculations.date.DateDiff;
+import org.apache.hop.pipeline.transforms.calculator.calculations.date.DateWorkingDiff;
+import org.apache.hop.pipeline.transforms.calculator.calculations.date.DayOfMonth;
+import org.apache.hop.pipeline.transforms.calculator.calculations.date.DayOfWeek;
+import org.apache.hop.pipeline.transforms.calculator.calculations.date.DayOfYear;
+import org.apache.hop.pipeline.transforms.calculator.calculations.date.FirstDayOfMonth;
+import org.apache.hop.pipeline.transforms.calculator.calculations.date.HourOfDay;
+import org.apache.hop.pipeline.transforms.calculator.calculations.date.LastDayOfMonth;
+import org.apache.hop.pipeline.transforms.calculator.calculations.date.MinuteOfHour;
+import org.apache.hop.pipeline.transforms.calculator.calculations.date.MonthOfDate;
+import org.apache.hop.pipeline.transforms.calculator.calculations.date.QuarterOfDate;
+import org.apache.hop.pipeline.transforms.calculator.calculations.date.RemoveTimeFromDate;
+import org.apache.hop.pipeline.transforms.calculator.calculations.date.SecondOfMinute;
+import org.apache.hop.pipeline.transforms.calculator.calculations.date.WeekOfYear;
+import org.apache.hop.pipeline.transforms.calculator.calculations.date.WeekOfYearISO8601;
+import org.apache.hop.pipeline.transforms.calculator.calculations.date.YearOfDate;
+import org.apache.hop.pipeline.transforms.calculator.calculations.date.YearOfDateISO8601;
+import org.apache.hop.pipeline.transforms.calculator.calculations.file.ADLER32;
+import org.apache.hop.pipeline.transforms.calculator.calculations.file.CRC32;
+import org.apache.hop.pipeline.transforms.calculator.calculations.file.CheckXMLFileWellFormed;
+import org.apache.hop.pipeline.transforms.calculator.calculations.file.GetFileEncoding;
+import org.apache.hop.pipeline.transforms.calculator.calculations.file.LoadFileContentBinary;
+import org.apache.hop.pipeline.transforms.calculator.calculations.file.MessageDigest;
+import org.apache.hop.pipeline.transforms.calculator.calculations.math.Abs;
+import org.apache.hop.pipeline.transforms.calculator.calculations.math.Add;
+import org.apache.hop.pipeline.transforms.calculator.calculations.math.Add3;
+import org.apache.hop.pipeline.transforms.calculator.calculations.math.Ceil;
+import org.apache.hop.pipeline.transforms.calculator.calculations.math.Combination1;
+import org.apache.hop.pipeline.transforms.calculator.calculations.math.Combination2;
+import org.apache.hop.pipeline.transforms.calculator.calculations.math.Divide;
+import org.apache.hop.pipeline.transforms.calculator.calculations.math.Floor;
+import org.apache.hop.pipeline.transforms.calculator.calculations.math.GetOnlyDigits;
+import org.apache.hop.pipeline.transforms.calculator.calculations.math.Multiply;
+import org.apache.hop.pipeline.transforms.calculator.calculations.math.Percent1;
+import org.apache.hop.pipeline.transforms.calculator.calculations.math.Percent2;
+import org.apache.hop.pipeline.transforms.calculator.calculations.math.Percent3;
+import org.apache.hop.pipeline.transforms.calculator.calculations.math.Remainder;
+import org.apache.hop.pipeline.transforms.calculator.calculations.math.RemoveDigits;
+import org.apache.hop.pipeline.transforms.calculator.calculations.math.Round1;
+import org.apache.hop.pipeline.transforms.calculator.calculations.math.Round2;
+import org.apache.hop.pipeline.transforms.calculator.calculations.math.RoundCustom1;
+import org.apache.hop.pipeline.transforms.calculator.calculations.math.RoundCustom2;
+import org.apache.hop.pipeline.transforms.calculator.calculations.math.RoundStd1;
+import org.apache.hop.pipeline.transforms.calculator.calculations.math.RoundStd2;
+import org.apache.hop.pipeline.transforms.calculator.calculations.math.Square;
+import org.apache.hop.pipeline.transforms.calculator.calculations.math.SquareRoot;
+import org.apache.hop.pipeline.transforms.calculator.calculations.math.Subtract;
+import org.apache.hop.pipeline.transforms.calculator.calculations.statistics.DamerauLevenshtein;
+import org.apache.hop.pipeline.transforms.calculator.calculations.statistics.DoubleMetaphone;
+import org.apache.hop.pipeline.transforms.calculator.calculations.statistics.Jaro;
+import org.apache.hop.pipeline.transforms.calculator.calculations.statistics.JaroWinkler;
+import org.apache.hop.pipeline.transforms.calculator.calculations.statistics.LevenshteinDistance;
+import org.apache.hop.pipeline.transforms.calculator.calculations.statistics.Metaphone;
+import org.apache.hop.pipeline.transforms.calculator.calculations.statistics.NeedlemanWunsch;
+import org.apache.hop.pipeline.transforms.calculator.calculations.statistics.RefinedSoundex;
+import org.apache.hop.pipeline.transforms.calculator.calculations.statistics.Soundex;
+import org.apache.hop.pipeline.transforms.calculator.calculations.text.CheckXmlWellFormed;
+import org.apache.hop.pipeline.transforms.calculator.calculations.text.InitCap;
+import org.apache.hop.pipeline.transforms.calculator.calculations.text.LowerCase;
+import org.apache.hop.pipeline.transforms.calculator.calculations.text.RemoveCR;
+import org.apache.hop.pipeline.transforms.calculator.calculations.text.RemoveCRLF;
+import org.apache.hop.pipeline.transforms.calculator.calculations.text.RemoveLF;
+import org.apache.hop.pipeline.transforms.calculator.calculations.text.RemoveTab;
+import org.apache.hop.pipeline.transforms.calculator.calculations.text.StringLen;
+import org.apache.hop.pipeline.transforms.calculator.calculations.text.SubstituteVariable;
+import org.apache.hop.pipeline.transforms.calculator.calculations.text.UpperCase;
+
+public enum CalculationType implements IEnumHasCodeAndDescription {
+ NONE(new None()),
+ CONSTANT(new Constant()),
+ COPY_OF_FIELD(new CopyField()),
+ ADD(new Add()),
+ SUBTRACT(new Subtract()),
+ MULTIPLY(new Multiply()),
+ DIVIDE(new Divide()),
+ SQUARE(new Square()),
+ SQUARE_ROOT(new SquareRoot()),
+ PERCENT_1(new Percent1()),
+ PERCENT_2(new Percent2()),
+ PERCENT_3(new Percent3()),
+ COMBINATION_1(new Combination1()),
+ COMBINATION_2(new Combination2()),
+ ROUND_1(new Round1()),
+ ROUND_2(new Round2()),
+ ROUND_STD_1(new RoundStd1()),
+ ROUND_STD_2(new RoundStd2()),
+ CEIL(new Ceil()),
+ FLOOR(new Floor()),
+ NVL(new Nvl()),
+ ADD_DAYS(new AddDays()),
+ YEAR_OF_DATE(new YearOfDate()),
+ MONTH_OF_DATE(new MonthOfDate()),
+ DAY_OF_YEAR(new DayOfYear()),
+ DAY_OF_MONTH(new DayOfMonth()),
+ DAY_OF_WEEK(new DayOfWeek()),
+ WEEK_OF_YEAR(new WeekOfYear()),
+ WEEK_OF_YEAR_ISO8601(new WeekOfYearISO8601()),
+ YEAR_OF_DATE_ISO8601(new YearOfDateISO8601()),
+ BYTE_TO_HEX_ENCODE(new ByteToHexEncode()),
+ HEX_TO_BYTE_DECODE(new HexToByteDecode()),
+ CHAR_TO_HEX_ENCODE(new CharToHexEncode()),
+ HEX_TO_CHAR_DECODE(new HexToCharDecode()),
+ CRC32(new CRC32()),
+ ADLER32(new ADLER32()),
+ MD5(new MessageDigest(MessageDigest.ALGORITHM.MD5)),
+ SHA1(new MessageDigest(MessageDigest.ALGORITHM.SHA1)),
+ SHA256(new MessageDigest(MessageDigest.ALGORITHM.SHA256)),
+ SHA384(new MessageDigest(MessageDigest.ALGORITHM.SHA384)),
+ SHA512(new MessageDigest(MessageDigest.ALGORITHM.SHA512)),
+ LEVENSHTEIN_DISTANCE(new LevenshteinDistance()),
+ METAPHONE(new Metaphone()),
+ DOUBLE_METAPHONE(new DoubleMetaphone()),
+ ABS(new Abs()),
+ REMOVE_TIME_FROM_DATE(new RemoveTimeFromDate()),
+ DATE_DIFF(new DateDiff(DateDiff.INTERVAL.DATE_DIFF)),
+ ADD3(new Add3()),
+ INIT_CAP(new InitCap()),
+ UPPER_CASE(new UpperCase()),
+ LOWER_CASE(new LowerCase()),
+ MASK_XML(new MaskXML()),
+ USE_CDATA(new UseCDATA()),
+ REMOVE_CR(new RemoveCR()),
+ REMOVE_LF(new RemoveLF()),
+ REMOVE_CRLF(new RemoveCRLF()),
+ REMOVE_TAB(new RemoveTab()),
+ GET_ONLY_DIGITS(new GetOnlyDigits()),
+ REMOVE_DIGITS(new RemoveDigits()),
+ STRING_LEN(new StringLen()),
+ LOAD_FILE_CONTENT_BINARY(new LoadFileContentBinary()),
+ ADD_TIME_TO_DATE(new AddTimeToDate()),
+ QUARTER_OF_DATE(new QuarterOfDate()),
+ SUBSTITUTE_VARIABLE(new SubstituteVariable()),
+ UNESCAPE_XML(new UnescapeXML()),
+ ESCAPE_HTML(new EscapeHTML()),
+ UNESCAPE_HTML(new UnescapeHTML()),
+ ESCAPE_SQL(new EscapeSQL()),
+ DATE_WORKING_DIFF(new DateWorkingDiff()),
+ ADD_MONTHS(new AddMonths()),
+ CHECK_XML_FILE_WELL_FORMED(new CheckXMLFileWellFormed()),
+ CHECK_XML_WELL_FORMED(new CheckXmlWellFormed()),
+ GET_FILE_ENCODING(new GetFileEncoding()),
+ DAMERAU_LEVENSHTEIN(new DamerauLevenshtein()),
+ NEEDLEMAN_WUNSCH(new NeedlemanWunsch()),
+ JARO(new Jaro()),
+ JARO_WINKLER(new JaroWinkler()),
+ SOUNDEX(new Soundex()),
+ REFINED_SOUNDEX(new RefinedSoundex()),
+ ADD_HOURS(new AddHours()),
+ ADD_MINUTES(new AddMinutes()),
+ DATE_DIFF_MSEC(new DateDiff(DateDiff.INTERVAL.DATE_DIFF_MSEC)),
+ DATE_DIFF_SEC(new DateDiff(DateDiff.INTERVAL.DATE_DIFF_SEC)),
+ DATE_DIFF_MN(new DateDiff(DateDiff.INTERVAL.DATE_DIFF_MN)),
+ DATE_DIFF_HR(new DateDiff(DateDiff.INTERVAL.DATE_DIFF_HR)),
+ HOUR_OF_DAY(new HourOfDay()),
+ MINUTE_OF_HOUR(new MinuteOfHour()),
+ SECOND_OF_MINUTE(new SecondOfMinute()),
+ ROUND_CUSTOM_1(new RoundCustom1()),
+ ROUND_CUSTOM_2(new RoundCustom2()),
+ ADD_SECONDS(new AddSeconds()),
+ REMAINDER(new Remainder()),
+ BASE64_ENCODE(new Base64Encode()),
+ BASE64_ENCODE_PADDED(new Base64EncodePadded()),
+ BASE64_DECODE(new Base64Decode()),
+ FIRST_DAY_OF_MONTH(new FirstDayOfMonth()),
+ LAST_DAY_OF_MONTH(new LastDayOfMonth());
+
+ public static final String[] descriptions =
+ Stream.of(values()).map(e -> e.calculation.getDescription()).toArray(String[]::new);
+
+ public final ICalculation calculation;
+
+ CalculationType(ICalculation calculation) {
+ this.calculation = calculation;
+ }
+
+ public static CalculationType findByDescription(String description) {
+ int index = ArrayUtils.indexOf(descriptions, description);
+ return index == -1 ? NONE : values()[index];
+ }
+
+ @Override
+ public String getCode() {
+ return calculation.getCode();
+ }
+
+ @Override
+ public String getDescription() {
+ return calculation.getDescription();
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/Calculator.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/Calculator.java
index 78d21b38b8..34f94e5fcc 100644
--- a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/Calculator.java
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/Calculator.java
@@ -18,7 +18,6 @@
package org.apache.hop.pipeline.transforms.calculator;
import java.util.ArrayList;
-import java.util.Base64;
import java.util.List;
import org.apache.hop.core.exception.HopException;
import org.apache.hop.core.exception.HopFileNotFoundException;
@@ -27,14 +26,12 @@ import org.apache.hop.core.exception.HopValueException;
import org.apache.hop.core.row.IRowMeta;
import org.apache.hop.core.row.IValueMeta;
import org.apache.hop.core.row.RowDataUtil;
-import org.apache.hop.core.row.ValueDataUtil;
import org.apache.hop.core.util.Utils;
import org.apache.hop.i18n.BaseMessages;
import org.apache.hop.pipeline.Pipeline;
import org.apache.hop.pipeline.PipelineMeta;
import org.apache.hop.pipeline.transform.BaseTransform;
import org.apache.hop.pipeline.transform.TransformMeta;
-import org.apache.hop.pipeline.transforms.calculator.CalculatorMetaFunction.CalculationType;
/** Calculate new field values using pre-defined functions. */
@SuppressWarnings("java:S1104")
@@ -240,479 +237,22 @@ public class Calculator extends BaseTransform<CalculatorMeta, CalculatorData> {
CalculationType calcType = fn.getCalcType();
- // The data types are those of the first argument field, convert to the target field.
- // Exceptions:
- // - multiply can be string
- // - constant is string
- // - all date functions except add days/months
- // - hex encode / decodes
-
- int resultType;
- if (metaA != null) {
- resultType = metaA.getType();
- } else {
- resultType = IValueMeta.TYPE_NONE;
- }
-
- switch (calcType) {
- case NONE:
- break;
- case COPY_OF_FIELD: // Create a copy of field A
- calcData[index] = dataA;
-
- break;
- case ADD: // A + B
- calcData[index] = ValueDataUtil.plus(metaA, dataA, metaB, dataB);
- if (metaA.isString() || metaB.isString()) {
- resultType = IValueMeta.TYPE_STRING;
- }
- break;
- case SUBTRACT: // A - B
- calcData[index] = ValueDataUtil.minus(metaA, dataA, metaB, dataB);
- if (metaA.isDate()) {
- resultType = IValueMeta.TYPE_INTEGER;
- }
- break;
- case MULTIPLY: // A * B
- calcData[index] = ValueDataUtil.multiply(metaA, dataA, metaB, dataB);
- if (metaA.isString() || metaB.isString()) {
- resultType = IValueMeta.TYPE_STRING;
- }
- break;
- case DIVIDE: // A / B
- calcData[index] = ValueDataUtil.divide(metaA, dataA, metaB, dataB);
- break;
- case SQUARE: // A * A
- calcData[index] = ValueDataUtil.multiply(metaA, dataA, metaA, dataA);
- break;
- case SQUARE_ROOT: // SQRT( A )
- calcData[index] = ValueDataUtil.sqrt(metaA, dataA);
- break;
- case PERCENT_1: // 100 * A / B
- calcData[index] = ValueDataUtil.percent1(metaA, dataA, metaB, dataB);
- break;
- case PERCENT_2: // A - ( A * B / 100 )
- calcData[index] = ValueDataUtil.percent2(metaA, dataA, metaB, dataB);
- break;
- case PERCENT_3: // A + ( A * B / 100 )
- calcData[index] = ValueDataUtil.percent3(metaA, dataA, metaB, dataB);
- break;
- case COMBINATION_1: // A + B * C
- calcData[index] = ValueDataUtil.combination1(metaA, dataA, metaB, dataB, metaC, dataC);
- break;
- case COMBINATION_2: // SQRT( A*A + B*B )
- calcData[index] = ValueDataUtil.combination2(metaA, dataA, metaB, dataB);
- break;
- case ROUND_1: // ROUND( A )
- calcData[index] = ValueDataUtil.round(metaA, dataA);
- break;
- case ROUND_2: // ROUND( A , B )
- calcData[index] = ValueDataUtil.round(metaA, dataA, metaB, dataB);
- break;
- case ROUND_CUSTOM_1: // ROUND( A , B )
- calcData[index] = ValueDataUtil.round(metaA, dataA, metaB.getNumber(dataB).intValue());
- break;
- case ROUND_CUSTOM_2: // ROUND( A , B, C )
- calcData[index] =
- ValueDataUtil.round(metaA, dataA, metaB, dataB, metaC.getNumber(dataC).intValue());
- break;
- case ROUND_STD_1: // ROUND( A )
- calcData[index] = ValueDataUtil.round(metaA, dataA, java.math.BigDecimal.ROUND_HALF_UP);
- break;
- case ROUND_STD_2: // ROUND( A , B )
- calcData[index] =
- ValueDataUtil.round(metaA, dataA, metaB, dataB, java.math.BigDecimal.ROUND_HALF_UP);
- break;
- case CEIL: // CEIL( A )
- calcData[index] = ValueDataUtil.ceil(metaA, dataA);
- break;
- case FLOOR: // FLOOR( A )
- calcData[index] = ValueDataUtil.floor(metaA, dataA);
- break;
- case CONSTANT: // Set field to constant value...
- calcData[index] = fn.getFieldA(); // A string
- resultType = calcType.getDefaultResultType();
- break;
- case NVL: // Replace null values with another value
- calcData[index] = ValueDataUtil.nvl(metaA, dataA, metaB, dataB);
- break;
- case ADD_DAYS: // Add B days to date field A
- calcData[index] = ValueDataUtil.addDays(metaA, dataA, metaB, dataB);
- resultType = calcType.getDefaultResultType();
- break;
- case ADD_HOURS: // Add B hours to date field A
- calcData[index] = ValueDataUtil.addHours(metaA, dataA, metaB, dataB);
- resultType = calcType.getDefaultResultType();
- break;
- case ADD_MINUTES: // Add B minutes to date field A
- calcData[index] = ValueDataUtil.addMinutes(metaA, dataA, metaB, dataB);
- resultType = calcType.getDefaultResultType();
- break;
- case YEAR_OF_DATE: // What is the year (Integer) of a date?
- calcData[index] = ValueDataUtil.yearOfDate(metaA, dataA);
- resultType = calcType.getDefaultResultType();
- break;
- case MONTH_OF_DATE: // What is the month (Integer) of a date?
- calcData[index] = ValueDataUtil.monthOfDate(metaA, dataA);
- resultType = calcType.getDefaultResultType();
- break;
- case DAY_OF_YEAR: // What is the day of year (Integer) of a date?
- calcData[index] = ValueDataUtil.dayOfYear(metaA, dataA);
- resultType = calcType.getDefaultResultType();
- break;
- case DAY_OF_MONTH: // What is the day of month (Integer) of a date?
- calcData[index] = ValueDataUtil.dayOfMonth(metaA, dataA);
- resultType = calcType.getDefaultResultType();
- break;
- case DAY_OF_WEEK: // What is the day of week (Integer) of a date?
- calcData[index] = ValueDataUtil.dayOfWeek(metaA, dataA);
- resultType = calcType.getDefaultResultType();
- break;
- case WEEK_OF_YEAR: // What is the week of year (Integer) of a date?
- calcData[index] = ValueDataUtil.weekOfYear(metaA, dataA);
- resultType = calcType.getDefaultResultType();
- break;
- case WEEK_OF_YEAR_ISO8601: // What is the week of year (Integer) of a date ISO8601
- // style?
- calcData[index] = ValueDataUtil.weekOfYearISO8601(metaA, dataA);
- resultType = calcType.getDefaultResultType();
- break;
- case YEAR_OF_DATE_ISO8601: // What is the year (Integer) of a date ISO8601 style?
- calcData[index] = ValueDataUtil.yearOfDateISO8601(metaA, dataA);
- resultType = calcType.getDefaultResultType();
- break;
- case BYTE_TO_HEX_ENCODE: // Byte to Hex encode string field A
- calcData[index] = ValueDataUtil.byteToHexEncode(metaA, dataA);
- resultType = calcType.getDefaultResultType();
- break;
- case HEX_TO_BYTE_DECODE: // Hex to Byte decode string field A
- calcData[index] = ValueDataUtil.hexToByteDecode(metaA, dataA);
- resultType = calcType.getDefaultResultType();
- break;
-
- case CHAR_TO_HEX_ENCODE: // Char to Hex encode string field A
- calcData[index] = ValueDataUtil.charToHexEncode(metaA, dataA);
- resultType = calcType.getDefaultResultType();
- break;
- case HEX_TO_CHAR_DECODE: // Hex to Char decode string field A
- calcData[index] = ValueDataUtil.hexToCharDecode(metaA, dataA);
- resultType = calcType.getDefaultResultType();
- break;
- case CRC32: // CRC32
- calcData[index] = ValueDataUtil.checksumCRC32(metaA, dataA, meta.isFailIfNoFile());
- resultType = calcType.getDefaultResultType();
- break;
- case ADLER32: // ADLER32
- calcData[index] = ValueDataUtil.checksumAdler32(metaA, dataA, meta.isFailIfNoFile());
- resultType = calcType.getDefaultResultType();
- break;
- case MD5: // MD5
- calcData[index] =
- ValueDataUtil.createChecksum(metaA, dataA, "MD5", meta.isFailIfNoFile());
- resultType = calcType.getDefaultResultType();
- break;
- case SHA1: // SHA-1
- calcData[index] =
- ValueDataUtil.createChecksum(metaA, dataA, "SHA-1", meta.isFailIfNoFile());
- resultType = calcType.getDefaultResultType();
- break;
- case SHA256: // SHA-256
- calcData[index] =
- ValueDataUtil.createChecksum(metaA, dataA, "SHA-256", meta.isFailIfNoFile());
- resultType = calcType.getDefaultResultType();
- break;
- case SHA384: // SHA-384
- calcData[index] =
- ValueDataUtil.createChecksum(metaA, dataA, "SHA-384", meta.isFailIfNoFile());
- resultType = calcType.getDefaultResultType();
- break;
- case SHA512: // SHA-512
- calcData[index] =
- ValueDataUtil.createChecksum(metaA, dataA, "SHA-512", meta.isFailIfNoFile());
- resultType = calcType.getDefaultResultType();
- break;
- case LEVENSHTEIN_DISTANCE: // LEVENSHTEIN DISTANCE
- calcData[index] = ValueDataUtil.getLevenshtein_Distance(metaA, dataA, metaB, dataB);
- resultType = calcType.getDefaultResultType();
- break;
- case METAPHONE: // METAPHONE
- calcData[index] = ValueDataUtil.get_Metaphone(metaA, dataA);
- resultType = calcType.getDefaultResultType();
- break;
- case DOUBLE_METAPHONE: // Double METAPHONE
- calcData[index] = ValueDataUtil.get_Double_Metaphone(metaA, dataA);
- resultType = calcType.getDefaultResultType();
- break;
- case ABS: // ABS( A )
- calcData[index] = ValueDataUtil.abs(metaA, dataA);
- break;
- case REMOVE_TIME_FROM_DATE: // Remove Time from field A
- calcData[index] = ValueDataUtil.removeTimeFromDate(metaA, dataA);
- break;
- case DATE_DIFF: // DateA - DateB
- calcData[index] = ValueDataUtil.DateDiff(metaA, dataA, metaB, dataB, "d");
- resultType = calcType.getDefaultResultType();
- break;
- case ADD3: // A + B + C
- calcData[index] = ValueDataUtil.plus3(metaA, dataA, metaB, dataB, metaC, dataC);
- if (metaA.isString() || metaB.isString() || metaC.isString()) {
- resultType = IValueMeta.TYPE_STRING;
- }
- break;
- case INITCAP: // InitCap( A )
- calcData[index] = ValueDataUtil.initCap(metaA, dataA);
- resultType = calcType.getDefaultResultType();
- break;
- case UPPER_CASE: // UpperCase( A )
- calcData[index] = ValueDataUtil.upperCase(metaA, dataA);
- resultType = calcType.getDefaultResultType();
- break;
- case LOWER_CASE: // UpperCase( A )
- calcData[index] = ValueDataUtil.lowerCase(metaA, dataA);
- resultType = calcType.getDefaultResultType();
- break;
- case MASK_XML: // escapeXML( A )
- calcData[index] = ValueDataUtil.escapeXml(metaA, dataA);
- resultType = calcType.getDefaultResultType();
- break;
- case USE_CDATA: // CDATA( A )
- calcData[index] = ValueDataUtil.useCDATA(metaA, dataA);
- resultType = calcType.getDefaultResultType();
- break;
- case REMOVE_CR: // REMOVE CR FROM A
- calcData[index] = ValueDataUtil.removeCR(metaA, dataA);
- resultType = calcType.getDefaultResultType();
- break;
- case REMOVE_LF: // REMOVE LF FROM A
- calcData[index] = ValueDataUtil.removeLF(metaA, dataA);
- resultType = calcType.getDefaultResultType();
- break;
- case REMOVE_CRLF: // REMOVE CRLF FROM A
- calcData[index] = ValueDataUtil.removeCRLF(metaA, dataA);
- resultType = calcType.getDefaultResultType();
- break;
- case REMOVE_TAB: // REMOVE TAB FROM A
- calcData[index] = ValueDataUtil.removeTAB(metaA, dataA);
- resultType = calcType.getDefaultResultType();
- break;
- case GET_ONLY_DIGITS: // GET ONLY DIGITS FROM A
- calcData[index] = ValueDataUtil.getDigits(metaA, dataA);
- resultType = calcType.getDefaultResultType();
- break;
- case REMOVE_DIGITS: // REMOVE DIGITS FROM A
- calcData[index] = ValueDataUtil.removeDigits(metaA, dataA);
- resultType = calcType.getDefaultResultType();
- break;
- case STRING_LEN: // RETURN THE LENGTH OF A
- calcData[index] = ValueDataUtil.stringLen(metaA, dataA);
- resultType = calcType.getDefaultResultType();
- break;
- case LOAD_FILE_CONTENT_BINARY: // LOAD CONTENT OF A FILE A IN A BLOB
- calcData[index] =
- ValueDataUtil.loadFileContentInBinary(metaA, dataA, meta.isFailIfNoFile());
- resultType = calcType.getDefaultResultType();
- break;
- case ADD_TIME_TO_DATE: // Add time B to a date A
- calcData[index] = ValueDataUtil.addTimeToDate(metaA, dataA, metaB, dataB, metaC, dataC);
- resultType = calcType.getDefaultResultType();
- break;
- case QUARTER_OF_DATE: // What is the quarter (Integer) of a date?
- calcData[index] = ValueDataUtil.quarterOfDate(metaA, dataA);
- resultType = calcType.getDefaultResultType();
- break;
- case SUBSTITUTE_VARIABLE: // variable substitution in string
- calcData[index] = resolve(dataA.toString());
- resultType = calcType.getDefaultResultType();
- break;
- case UNESCAPE_XML: // UnescapeXML( A )
- calcData[index] = ValueDataUtil.unEscapeXml(metaA, dataA);
- resultType = calcType.getDefaultResultType();
- break;
- case ESCAPE_HTML: // EscapeHTML( A )
- calcData[index] = ValueDataUtil.escapeHtml(metaA, dataA);
- resultType = calcType.getDefaultResultType();
- break;
- case UNESCAPE_HTML: // UnescapeHTML( A )
- calcData[index] = ValueDataUtil.unEscapeHtml(metaA, dataA);
- resultType = calcType.getDefaultResultType();
- break;
- case ESCAPE_SQL: // EscapeSQL( A )
- calcData[index] = ValueDataUtil.escapeSql(metaA, dataA);
- resultType = calcType.getDefaultResultType();
- break;
- case DATE_WORKING_DIFF: // DateWorkingDiff( A , B)
- calcData[index] = ValueDataUtil.DateWorkingDiff(metaA, dataA, metaB, dataB);
- resultType = calcType.getDefaultResultType();
- break;
- case ADD_MONTHS: // Add B months to date field A
- calcData[index] = ValueDataUtil.addMonths(metaA, dataA, metaB, dataB);
- resultType = calcType.getDefaultResultType();
- break;
- case CHECK_XML_FILE_WELL_FORMED: // Check if file A is well formed
- calcData[index] =
- ValueDataUtil.isXmlFileWellFormed(metaA, dataA, meta.isFailIfNoFile());
- resultType = calcType.getDefaultResultType();
- break;
- case CHECK_XML_WELL_FORMED: // Check if xml A is well formed
- calcData[index] = ValueDataUtil.isXmlWellFormed(metaA, dataA);
- resultType = calcType.getDefaultResultType();
- break;
- case GET_FILE_ENCODING: // Get file encoding from a file A
- calcData[index] = ValueDataUtil.getFileEncoding(metaA, dataA, meta.isFailIfNoFile());
- resultType = calcType.getDefaultResultType();
- break;
- case DAMERAU_LEVENSHTEIN: // DAMERAULEVENSHTEIN DISTANCE
- calcData[index] =
- ValueDataUtil.getDamerauLevenshtein_Distance(metaA, dataA, metaB, dataB);
- resultType = calcType.getDefaultResultType();
- break;
- case NEEDLEMAN_WUNSH: // NEEDLEMANWUNSH DISTANCE
- calcData[index] = CalculatorValueDataUtil.getNeedlemanWunschDistance(dataA, dataB);
- resultType = calcType.getDefaultResultType();
- break;
- case JARO: // Jaro DISTANCE
- calcData[index] = ValueDataUtil.getJaro_Similitude(metaA, dataA, metaB, dataB);
- resultType = calcType.getDefaultResultType();
- break;
- case JARO_WINKLER: // Jaro DISTANCE
- calcData[index] = ValueDataUtil.getJaroWinkler_Similitude(metaA, dataA, metaB, dataB);
- resultType = calcType.getDefaultResultType();
- break;
- case SOUNDEX: // SOUNDEX
- calcData[index] = ValueDataUtil.get_SoundEx(metaA, dataA);
- resultType = calcType.getDefaultResultType();
- break;
- case REFINED_SOUNDEX: // REFINEDSOUNDEX
- calcData[index] = ValueDataUtil.get_RefinedSoundEx(metaA, dataA);
- resultType = calcType.getDefaultResultType();
- break;
- case DATE_DIFF_MSEC: // DateA - DateB (ms)
- calcData[index] = ValueDataUtil.DateDiff(metaA, dataA, metaB, dataB, "ms");
- resultType = calcType.getDefaultResultType();
- break;
- case DATE_DIFF_SEC: // DateA - DateB (s)
- calcData[index] = ValueDataUtil.DateDiff(metaA, dataA, metaB, dataB, "s");
- resultType = calcType.getDefaultResultType();
- break;
- case DATE_DIFF_MN: // DateA - DateB (mn)
- calcData[index] = ValueDataUtil.DateDiff(metaA, dataA, metaB, dataB, "mn");
- resultType = calcType.getDefaultResultType();
- break;
- case DATE_DIFF_HR: // DateA - DateB (h)
- calcData[index] = ValueDataUtil.DateDiff(metaA, dataA, metaB, dataB, "h");
- resultType = calcType.getDefaultResultType();
- break;
- case HOUR_OF_DAY:
- calcData[index] = ValueDataUtil.hourOfDay(metaA, dataA);
- resultType = calcType.getDefaultResultType();
- break;
- case MINUTE_OF_HOUR:
- calcData[index] = ValueDataUtil.minuteOfHour(metaA, dataA);
- resultType = calcType.getDefaultResultType();
- break;
- case SECOND_OF_MINUTE:
- calcData[index] = ValueDataUtil.secondOfMinute(metaA, dataA);
- resultType = calcType.getDefaultResultType();
- break;
- case ADD_SECONDS: // Add B seconds to date field A
- calcData[index] = ValueDataUtil.addSeconds(metaA, dataA, metaB, dataB);
- resultType = calcType.getDefaultResultType();
- break;
- case REMAINDER:
- if (targetMeta.getType() != metaA.getType()
- || targetMeta.getType() != metaB.getType()) {
- dataA = targetMeta.convertData(metaA, dataA);
- metaA = targetMeta.clone();
- dataB = targetMeta.convertData(metaB, dataB);
- metaB = targetMeta.clone();
- }
- calcData[index] = ValueDataUtil.remainder(metaA, dataA, metaB, dataB);
- resultType = targetMeta.getType();
- break;
- case BASE64_ENCODE:
- if (dataA != null) {
- if (metaA.getType() == IValueMeta.TYPE_BINARY) {
- calcData[index] =
- Base64.getEncoder().withoutPadding().encodeToString(metaA.getBinary(dataA));
- } else {
- calcData[index] =
- Base64.getEncoder()
- .withoutPadding()
- .encodeToString(metaA.getString(dataA).getBytes());
- }
- } else {
- calcData[index] = null;
- }
- resultType = IValueMeta.TYPE_STRING;
- break;
- case BASE64_ENCODE_PADDED:
- if (dataA != null) {
- if (metaA.getType() == IValueMeta.TYPE_BINARY) {
- calcData[index] = Base64.getEncoder().encodeToString(metaA.getBinary(dataA));
- } else {
- calcData[index] =
- Base64.getEncoder().encodeToString(metaA.getString(dataA).getBytes());
- }
- } else {
- calcData[index] = null;
- }
- resultType = IValueMeta.TYPE_STRING;
- break;
- case BASE64_DECODE:
- if (dataA != null) {
- byte[] tmpDecoded = Base64.getDecoder().decode(metaA.getString(dataA));
- if (targetMeta.getType() == IValueMeta.TYPE_BINARY) {
- calcData[index] = tmpDecoded;
- } else {
- String tmpDecodedString = new String(tmpDecoded);
- calcData[index] = targetMeta.convertData(metaA, tmpDecodedString);
- }
- } else {
- calcData[index] = null;
- }
- resultType = targetMeta.getType();
- break;
- case FIRST_DAY_OF_MONTH: // First day of month from date A
- // Create a custom implementation similar to other date functions
- if (metaA.isNull(dataA)) {
- calcData[index] = null;
- } else {
- java.util.Date dateValue = metaA.getDate(dataA);
- if (dateValue != null) {
- java.util.Calendar cal = java.util.Calendar.getInstance();
- cal.setTime(dateValue);
- cal.set(java.util.Calendar.DAY_OF_MONTH, 1);
- calcData[index] = cal.getTime();
- } else {
- calcData[index] = null;
- }
- }
- resultType = calcType.getDefaultResultType();
- break;
- case LAST_DAY_OF_MONTH: // Last day of month from date A
- if (metaA.isNull(dataA)) {
- calcData[index] = null;
- } else {
- java.util.Date dateValue = metaA.getDate(dataA);
- if (dateValue != null) {
- java.util.Calendar cal = java.util.Calendar.getInstance();
- cal.setTime(dateValue);
- // Get last day of month
- cal.set(
- java.util.Calendar.DAY_OF_MONTH,
- cal.getActualMaximum(java.util.Calendar.DAY_OF_MONTH));
- calcData[index] = cal.getTime();
- } else {
- calcData[index] = null;
- }
- }
- resultType = calcType.getDefaultResultType();
- break;
- default:
- throw new HopValueException(
- BaseMessages.getString(PKG, "Calculator.Log.UnknownCalculationType")
- + fn.getCalcType());
- }
+ CalculationInput calcIn =
+ new CalculationInput(
+ metaA,
+ metaB,
+ metaC,
+ dataA,
+ dataB,
+ dataC,
+ fn,
+ targetMeta,
+ this,
+ meta.isFailIfNoFile());
+
+ CalculationOutput calcOut = calcType.calculation.calculate(calcIn);
+ calcData[index] = calcOut.value;
+ int resultType = calcOut.resultType;
// If we don't have a target data type, throw an error.
// Otherwise the result is non-deterministic.
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/CalculatorDialog.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/CalculatorDialog.java
index 1bcd290aeb..64d009a2fa 100644
--- a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/CalculatorDialog.java
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/CalculatorDialog.java
@@ -28,7 +28,6 @@ import org.apache.hop.core.variables.IVariables;
import org.apache.hop.i18n.BaseMessages;
import org.apache.hop.pipeline.PipelineMeta;
import org.apache.hop.pipeline.transform.TransformMeta;
-import org.apache.hop.pipeline.transforms.calculator.CalculatorMetaFunction.CalculationType;
import org.apache.hop.ui.core.ConstUi;
import org.apache.hop.ui.core.PropsUi;
import org.apache.hop.ui.core.dialog.BaseDialog;
@@ -236,7 +235,7 @@ public class CalculatorDialog extends BaseTransformDialog {
EnterSelectionDialog esd =
new EnterSelectionDialog(
shell,
- CalculationType.getDescriptions(),
+ CalculationType.descriptions,
BaseMessages.getString(PKG, "CalculatorDialog.SelectCalculationType.Title"),
BaseMessages.getString(PKG, "CalculatorDialog.SelectCalculationType.Message"));
String string = esd.open();
@@ -392,7 +391,8 @@ public class CalculatorDialog extends BaseTransformDialog {
for (TableItem item : wFields.getNonEmptyItems()) {
String fieldName = item.getText(1);
- CalculationType calcType = CalculationType.getTypeWithDescription(item.getText(2));
+ CalculationType calcType = CalculationType.findByDescription(item.getText(2));
+
String fieldA = item.getText(3);
String fieldB = item.getText(4);
String fieldC = item.getText(5);
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/CalculatorMeta.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/CalculatorMeta.java
index f74b4a4b9e..de993ed619 100644
--- a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/CalculatorMeta.java
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/CalculatorMeta.java
@@ -104,7 +104,7 @@ public class CalculatorMeta extends BaseTransformMeta<Calculator, CalculatorData
//
int defaultResultType = ValueMetaFactory.getIdForValueMeta(fn.getValueType());
if (defaultResultType == IValueMeta.TYPE_NONE) {
- defaultResultType = fn.getCalcType().getDefaultResultType();
+ defaultResultType = fn.getCalcType().calculation.getDefaultResultType();
}
try {
v = ValueMetaFactory.createValueMeta(fn.getFieldName(), defaultResultType);
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/CalculatorMetaFunction.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/CalculatorMetaFunction.java
index 90d9613c6c..f54c1a1d87 100644
--- a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/CalculatorMetaFunction.java
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/CalculatorMetaFunction.java
@@ -20,411 +20,11 @@ package org.apache.hop.pipeline.transforms.calculator;
import java.util.Objects;
import lombok.Getter;
import lombok.Setter;
-import org.apache.hop.core.row.IValueMeta;
-import org.apache.hop.i18n.BaseMessages;
import org.apache.hop.metadata.api.HopMetadataProperty;
-import org.apache.hop.metadata.api.IEnumHasCode;
@Getter
@Setter
public class CalculatorMetaFunction implements Cloneable {
- private static final Class<?> PKG = CalculatorMeta.class;
-
- @Getter
- public enum CalculationType implements IEnumHasCode {
- NONE("-", "-", IValueMeta.TYPE_NONE),
- CONSTANT(
- "CONSTANT",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.SetFieldToConstant"),
- IValueMeta.TYPE_STRING),
- COPY_OF_FIELD(
- "COPY_FIELD",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.CreateCopyOfField"),
- IValueMeta.TYPE_NONE),
- ADD("ADD", "A + B", IValueMeta.TYPE_NUMBER),
- SUBTRACT("SUBTRACT", "A - B", IValueMeta.TYPE_NUMBER),
- MULTIPLY("MULTIPLY", "A * B", IValueMeta.TYPE_NUMBER),
- DIVIDE("DIVIDE", "A / B", IValueMeta.TYPE_NUMBER),
- SQUARE("SQUARE", "A * A", IValueMeta.TYPE_NUMBER),
- SQUARE_ROOT(
- "SQUARE_ROOT",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.SQRT"),
- IValueMeta.TYPE_NUMBER),
- PERCENT_1("PERCENT_1", "100 * A / B", IValueMeta.TYPE_NUMBER),
- PERCENT_2("PERCENT_2", "A - ( A * B / 100 )", IValueMeta.TYPE_NUMBER),
- PERCENT_3("PERCENT_3", "A + ( A * B / 100 )", IValueMeta.TYPE_NUMBER),
- COMBINATION_1("COMBINATION_1", "A + B * C", IValueMeta.TYPE_NUMBER),
- COMBINATION_2(
- "COMBINATION_2",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.Hypotenuse"),
- IValueMeta.TYPE_NUMBER),
- ROUND_1(
- "ROUND_1",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.Round"),
- IValueMeta.TYPE_INTEGER),
- ROUND_2(
- "ROUND_2",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.Round2"),
- IValueMeta.TYPE_NUMBER),
- ROUND_STD_1(
- "ROUND_STD_1",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.RoundStd"),
- IValueMeta.TYPE_INTEGER),
- ROUND_STD_2(
- "ROUND_STD_2",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.RoundStd2"),
- IValueMeta.TYPE_NUMBER),
- CEIL(
- "CEIL",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.Ceil"),
- IValueMeta.TYPE_INTEGER),
- FLOOR(
- "FLOOR",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.Floor"),
- IValueMeta.TYPE_INTEGER),
- NVL(
- "NVL",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.NVL"),
- IValueMeta.TYPE_NONE),
- ADD_DAYS(
- "ADD_DAYS",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.DatePlusDays"),
- IValueMeta.TYPE_DATE),
- YEAR_OF_DATE(
- "YEAR_OF_DATE",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.YearOfDate"),
- IValueMeta.TYPE_INTEGER),
- MONTH_OF_DATE(
- "MONTH_OF_DATE",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.MonthOfDate"),
- IValueMeta.TYPE_INTEGER),
- DAY_OF_YEAR(
- "DAY_OF_YEAR",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.DayOfYear"),
- IValueMeta.TYPE_INTEGER),
- DAY_OF_MONTH(
- "DAY_OF_MONTH",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.DayOfMonth"),
- IValueMeta.TYPE_INTEGER),
- DAY_OF_WEEK(
- "DAY_OF_WEEK",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.DayOfWeek"),
- IValueMeta.TYPE_INTEGER),
- WEEK_OF_YEAR(
- "WEEK_OF_YEAR",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.WeekOfYear"),
- IValueMeta.TYPE_INTEGER),
- WEEK_OF_YEAR_ISO8601(
- "WEEK_OF_YEAR_ISO8601",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.WeekOfYearISO8601"),
- IValueMeta.TYPE_INTEGER),
- YEAR_OF_DATE_ISO8601(
- "YEAR_OF_DATE_ISO8601",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.YearOfDateISO8601"),
- IValueMeta.TYPE_INTEGER),
- BYTE_TO_HEX_ENCODE(
- "BYTE_TO_HEX_ENCODE",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.ByteToHexEncode"),
- IValueMeta.TYPE_STRING),
- HEX_TO_BYTE_DECODE(
- "HEX_TO_BYTE_DECODE",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.HexToByteDecode"),
- IValueMeta.TYPE_STRING),
- CHAR_TO_HEX_ENCODE(
- "CHAR_TO_HEX_ENCODE",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.CharToHexEncode"),
- IValueMeta.TYPE_STRING),
- HEX_TO_CHAR_DECODE(
- "HEX_TO_CHAR_DECODE",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.HexToCharDecode"),
- IValueMeta.TYPE_STRING),
- CRC32(
- "CRC32",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.CRC32"),
- IValueMeta.TYPE_INTEGER),
- ADLER32(
- "ADLER32",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.Adler32"),
- IValueMeta.TYPE_INTEGER),
- MD5(
- "MD5",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.MD5"),
- IValueMeta.TYPE_STRING),
- SHA1(
- "SHA1",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.SHA1"),
- IValueMeta.TYPE_STRING),
- SHA256(
- "SHA256",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.SHA256"),
- IValueMeta.TYPE_STRING),
- SHA384(
- "SHA384",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.SHA384"),
- IValueMeta.TYPE_STRING),
- SHA512(
- "SHA512",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.SHA512"),
- IValueMeta.TYPE_STRING),
- LEVENSHTEIN_DISTANCE(
- "LEVENSHTEIN_DISTANCE",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.LevenshteinDistance"),
- IValueMeta.TYPE_INTEGER),
- METAPHONE(
- "METAPHONE",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.Metaphone"),
- IValueMeta.TYPE_STRING),
- DOUBLE_METAPHONE(
- "DOUBLE_METAPHONE",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.DoubleMetaphone"),
- IValueMeta.TYPE_STRING),
- ABS(
- "ABS",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.Abs"),
- IValueMeta.TYPE_INTEGER),
- REMOVE_TIME_FROM_DATE(
- "REMOVE_TIME_FROM_DATE",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.RemoveTimeFromDate"),
- IValueMeta.TYPE_DATE),
- DATE_DIFF(
- "DATE_DIFF",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.DateDiff"),
- IValueMeta.TYPE_INTEGER),
- ADD3("ADD3", "A + B + C", IValueMeta.TYPE_NUMBER),
- INITCAP(
- "INIT_CAP",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.InitCap"),
- IValueMeta.TYPE_STRING),
- UPPER_CASE(
- "UPPER_CASE",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.UpperCase"),
- IValueMeta.TYPE_STRING),
- LOWER_CASE(
- "LOWER_CASE",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.LowerCase"),
- IValueMeta.TYPE_STRING),
- MASK_XML(
- "MASK_XML",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.MaskXML"),
- IValueMeta.TYPE_STRING),
- USE_CDATA(
- "USE_CDATA",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.UseCDATA"),
- IValueMeta.TYPE_STRING),
- REMOVE_CR(
- "REMOVE_CR",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.RemoveCR"),
- IValueMeta.TYPE_STRING),
- REMOVE_LF(
- "REMOVE_LF",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.RemoveLF"),
- IValueMeta.TYPE_STRING),
- REMOVE_CRLF(
- "REMOVE_CRLF",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.RemoveCRLF"),
- IValueMeta.TYPE_STRING),
- REMOVE_TAB(
- "REMOVE_TAB",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.RemoveTAB"),
- IValueMeta.TYPE_STRING),
- GET_ONLY_DIGITS(
- "GET_ONLY_DIGITS",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.GetOnlyDigits"),
- IValueMeta.TYPE_STRING),
- REMOVE_DIGITS(
- "REMOVE_DIGITS",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.RemoveDigits"),
- IValueMeta.TYPE_STRING),
- STRING_LEN(
- "STRING_LEN",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.StringLen"),
- IValueMeta.TYPE_INTEGER),
- LOAD_FILE_CONTENT_BINARY(
- "LOAD_FILE_CONTENT_BINARY",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.LoadFileContentInBinary"),
- IValueMeta.TYPE_BINARY),
- ADD_TIME_TO_DATE(
- "ADD_TIME_TO_DATE",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.AddTimeToDate"),
- IValueMeta.TYPE_DATE),
- QUARTER_OF_DATE(
- "QUARTER_OF_DATE",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.QuarterOfDate"),
- IValueMeta.TYPE_INTEGER),
- SUBSTITUTE_VARIABLE(
- "SUBSTITUTE_VARIABLE",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.SubstituteVariable"),
- IValueMeta.TYPE_STRING),
- UNESCAPE_XML(
- "UNESCAPE_XML",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.UnescapeXML"),
- IValueMeta.TYPE_STRING),
- ESCAPE_HTML(
- "ESCAPE_HTML",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.EscapeHTML"),
- IValueMeta.TYPE_STRING),
- UNESCAPE_HTML(
- "UNESCAPE_HTML",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.UnescapeHTML"),
- IValueMeta.TYPE_STRING),
- ESCAPE_SQL(
- "ESCAPE_SQL",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.EscapeSQL"),
- IValueMeta.TYPE_STRING),
- DATE_WORKING_DIFF(
- "DATE_WORKING_DIFF",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.DateDiffWorking"),
- IValueMeta.TYPE_INTEGER),
- ADD_MONTHS(
- "ADD_MONTHS",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.DatePlusMonths"),
- IValueMeta.TYPE_DATE),
- CHECK_XML_FILE_WELL_FORMED(
- "CHECK_XML_FILE_WELL_FORMED",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.CheckXmlFileWellFormed"),
- IValueMeta.TYPE_BOOLEAN),
- CHECK_XML_WELL_FORMED(
- "CHECK_XML_WELL_FORMED",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.CheckXmlWellFormed"),
- IValueMeta.TYPE_BOOLEAN),
- GET_FILE_ENCODING(
- "GET_FILE_ENCODING",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.GetFileEncoding"),
- IValueMeta.TYPE_STRING),
- DAMERAU_LEVENSHTEIN(
- "DAMERAU_LEVENSHTEIN",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.DamerauLevenshtein"),
- IValueMeta.TYPE_INTEGER),
- NEEDLEMAN_WUNSH(
- "NEEDLEMAN_WUNSH",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.NeedlemanWunsch"),
- IValueMeta.TYPE_INTEGER),
- JARO(
- "JARO",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.Jaro"),
- IValueMeta.TYPE_NUMBER),
- JARO_WINKLER(
- "JARO_WINKLER",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.JaroWinkler"),
- IValueMeta.TYPE_NUMBER),
- SOUNDEX(
- "SOUNDEX",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.SoundEx"),
- IValueMeta.TYPE_STRING),
- REFINED_SOUNDEX(
- "REFINED_SOUNDEX",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.RefinedSoundEx"),
- IValueMeta.TYPE_STRING),
- ADD_HOURS(
- "ADD_HOURS",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.DatePlusHours"),
- IValueMeta.TYPE_DATE),
- ADD_MINUTES(
- "ADD_MINUTES",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.DatePlusMinutes"),
- IValueMeta.TYPE_DATE),
- DATE_DIFF_MSEC(
- "DATE_DIFF_MSEC",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.DateDiffMsec"),
- IValueMeta.TYPE_INTEGER),
- DATE_DIFF_SEC(
- "DATE_DIFF_SEC",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.DateDiffSec"),
- IValueMeta.TYPE_INTEGER),
- DATE_DIFF_MN(
- "DATE_DIFF_MN",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.DateDiffMn"),
- IValueMeta.TYPE_INTEGER),
- DATE_DIFF_HR(
- "DATE_DIFF_HR",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.DateDiffHr"),
- IValueMeta.TYPE_INTEGER),
- HOUR_OF_DAY(
- "HOUR_OF_DAY",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.HourOfDay"),
- IValueMeta.TYPE_INTEGER),
- MINUTE_OF_HOUR(
- "MINUTE_OF_HOUR",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.MinuteOfHour"),
- IValueMeta.TYPE_INTEGER),
- SECOND_OF_MINUTE(
- "SECOND_OF_MINUTE",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.SecondOfMinute"),
- IValueMeta.TYPE_INTEGER),
- ROUND_CUSTOM_1(
- "ROUND_CUSTOM_1",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.RoundCustom"),
- IValueMeta.TYPE_NUMBER),
- ROUND_CUSTOM_2(
- "ROUND_CUSTOM_2",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.RoundCustom2"),
- IValueMeta.TYPE_NUMBER),
- ADD_SECONDS(
- "ADD_SECONDS",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.AddSeconds"),
- IValueMeta.TYPE_DATE),
- REMAINDER(
- "REMAINDER",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.Remainder"),
- IValueMeta.TYPE_NUMBER),
- BASE64_ENCODE(
- "BASE64_ENCODE",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.Base64Encode"),
- IValueMeta.TYPE_STRING),
- BASE64_ENCODE_PADDED(
- "BASE64_ENCODE_PADDED",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.Base64EncodePadded"),
- IValueMeta.TYPE_STRING),
- BASE64_DECODE(
- "BASE64_DECODE",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.Base64Decode"),
- IValueMeta.TYPE_STRING),
- FIRST_DAY_OF_MONTH(
- "FIRST_DAY_OF_MONTH",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.FirstDayOfMonthDate"),
- IValueMeta.TYPE_DATE),
- // ADD THIS NEW CALCULATION:
- LAST_DAY_OF_MONTH(
- "LAST_DAY_OF_MONTH",
- BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.LastDayOfMonthDate"),
- IValueMeta.TYPE_DATE);
-
- private String code;
- private String description;
- private int defaultResultType;
-
- CalculationType(String code, String description, int defaultResultType) {
- this.code = code;
- this.description = description;
- this.defaultResultType = defaultResultType;
- }
-
- public static String[] getDescriptions() {
- String[] descriptions = new String[values().length];
- for (int i = 0; i < descriptions.length; i++) {
- descriptions[i] = values()[i].getDescription();
- }
- return descriptions;
- }
-
- public static CalculationType getTypeWithCode(String code) {
- for (CalculationType value : values()) {
- if (value.getCode().equals(code)) {
- return value;
- }
- }
- return NONE;
- }
-
- public static CalculationType getTypeWithDescription(String description) {
- for (CalculationType value : values()) {
- if (value.getDescription().equals(description)) {
- return value;
- }
- }
- return NONE;
- }
- }
@HopMetadataProperty(
key = "field_name",
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/ICalculation.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/ICalculation.java
new file mode 100644
index 0000000000..071e121a92
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/ICalculation.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator;
+
+import org.apache.hop.core.exception.HopFileNotFoundException;
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+
+public interface ICalculation {
+ Class<?> PKG = ICalculation.class;
+
+ /**
+ * @return A unique code for lookup. This code is referenced from pipeline/workflow files.
+ */
+ String getCode();
+
+ /**
+ * @return An i18n description that is shown in the UI.
+ */
+ String getDescription();
+
+ /**
+ * @return the default {@link org.apache.hop.core.row.IValueMeta} value type, if it cannot or
+ * should not be derived from the calculation input
+ */
+ int getDefaultResultType();
+
+ CalculationOutput calculate(CalculationInput i)
+ throws HopValueException, HopFileNotFoundException;
+
+ static int getResultType(IValueMeta valueMeta) {
+ return valueMeta == null ? IValueMeta.TYPE_NONE : valueMeta.getType();
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/Constant.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/Constant.java
new file mode 100644
index 0000000000..10b4d8e52b
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/Constant.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations;
+
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class Constant implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.SetFieldToConstant");
+
+ @Override
+ public String getCode() {
+ return "CONSTANT";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_STRING;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) {
+ return new CalculationOutput(getDefaultResultType(), in.calcMetaFn.getFieldA());
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/CopyField.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/CopyField.java
new file mode 100644
index 0000000000..c748266474
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/CopyField.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations;
+
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class CopyField implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.CreateCopyOfField");
+
+ @Override
+ public String getCode() {
+ return "COPY_FIELD";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_NONE;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) {
+ return new CalculationOutput(ICalculation.getResultType(in.metaA), in.dataA);
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/None.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/None.java
new file mode 100644
index 0000000000..9eef68c6fa
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/None.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations;
+
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class None implements ICalculation {
+ @Override
+ public String getCode() {
+ return "-";
+ }
+
+ @Override
+ public String getDescription() {
+ return "-";
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_NONE;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) {
+ return new CalculationOutput(ICalculation.getResultType(in.metaA), null);
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/Nvl.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/Nvl.java
new file mode 100644
index 0000000000..c842158920
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/Nvl.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class Nvl implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.NVL");
+
+ @Override
+ public String getCode() {
+ return "NVL";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_NONE;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ ICalculation.getResultType(in.metaA),
+ ValueDataUtil.nvl(in.metaA, in.dataA, in.metaB, in.dataB));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/conversion/Base64Decode.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/conversion/Base64Decode.java
new file mode 100644
index 0000000000..52fcfeb9d4
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/conversion/Base64Decode.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.conversion;
+
+import java.util.Base64;
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class Base64Decode implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.Base64Decode");
+
+ @Override
+ public String getCode() {
+ return "BASE64_DECODE";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_STRING;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ Object value = null;
+
+ if (in.dataA != null) {
+ byte[] tmpDecoded = Base64.getDecoder().decode(in.metaA.getString(in.dataA));
+
+ if (in.targetMeta.getType() == IValueMeta.TYPE_BINARY) {
+ value = tmpDecoded;
+ } else {
+ String tmpDecodedString = new String(tmpDecoded);
+ value = in.targetMeta.convertData(in.metaA, tmpDecodedString);
+ }
+ }
+
+ return new CalculationOutput(in.targetMeta.getType(), value);
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/conversion/Base64Encode.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/conversion/Base64Encode.java
new file mode 100644
index 0000000000..d46d581d14
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/conversion/Base64Encode.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.conversion;
+
+import java.util.Base64;
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class Base64Encode implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.Base64Encode");
+
+ @Override
+ public String getCode() {
+ return "BASE64_ENCODE";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_STRING;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ Object value = null;
+
+ if (in.dataA != null) {
+ byte[] bytes =
+ (in.metaA.getType() == IValueMeta.TYPE_BINARY)
+ ? in.metaA.getBinary(in.dataA)
+ : in.metaA.getString(in.dataA).getBytes();
+
+ value = Base64.getEncoder().withoutPadding().encodeToString(bytes);
+ }
+
+ return new CalculationOutput(getDefaultResultType(), value);
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/conversion/Base64EncodePadded.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/conversion/Base64EncodePadded.java
new file mode 100644
index 0000000000..dc1c6684c6
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/conversion/Base64EncodePadded.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.conversion;
+
+import java.util.Base64;
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class Base64EncodePadded implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.Base64EncodePadded");
+
+ @Override
+ public String getCode() {
+ return "BASE64_ENCODE_PADDED";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_STRING;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ Object value = null;
+
+ if (in.dataA != null) {
+ byte[] bytes =
+ (in.metaA.getType() == IValueMeta.TYPE_BINARY)
+ ? in.metaA.getBinary(in.dataA)
+ : in.metaA.getString(in.dataA).getBytes();
+
+ value = Base64.getEncoder().encodeToString(bytes);
+ }
+
+ return new CalculationOutput(getDefaultResultType(), value);
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/conversion/ByteToHexEncode.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/conversion/ByteToHexEncode.java
new file mode 100644
index 0000000000..8947c4e1df
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/conversion/ByteToHexEncode.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.conversion;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class ByteToHexEncode implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.ByteToHexEncode");
+
+ @Override
+ public String getCode() {
+ return "BYTE_TO_HEX_ENCODE";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_STRING;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.byteToHexEncode(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/conversion/CharToHexEncode.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/conversion/CharToHexEncode.java
new file mode 100644
index 0000000000..01c9d32ed3
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/conversion/CharToHexEncode.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.conversion;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class CharToHexEncode implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.CharToHexEncode");
+
+ @Override
+ public String getCode() {
+ return "CHAR_TO_HEX_ENCODE";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_STRING;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.charToHexEncode(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/conversion/EscapeHTML.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/conversion/EscapeHTML.java
new file mode 100644
index 0000000000..44f6da2970
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/conversion/EscapeHTML.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.conversion;
+
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class EscapeHTML implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.EscapeHTML");
+
+ @Override
+ public String getCode() {
+ return "ESCAPE_HTML";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_STRING;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.escapeHtml(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/conversion/EscapeSQL.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/conversion/EscapeSQL.java
new file mode 100644
index 0000000000..4cf1831ef3
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/conversion/EscapeSQL.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.conversion;
+
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class EscapeSQL implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.EscapeSQL");
+
+ @Override
+ public String getCode() {
+ return "ESCAPE_SQL";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_STRING;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.escapeSql(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/conversion/HexToByteDecode.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/conversion/HexToByteDecode.java
new file mode 100644
index 0000000000..6216932c3b
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/conversion/HexToByteDecode.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.conversion;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class HexToByteDecode implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.HexToByteDecode");
+
+ @Override
+ public String getCode() {
+ return "HEX_TO_BYTE_DECODE";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_STRING;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.hexToByteDecode(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/conversion/HexToCharDecode.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/conversion/HexToCharDecode.java
new file mode 100644
index 0000000000..62653b48f8
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/conversion/HexToCharDecode.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.conversion;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class HexToCharDecode implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.HexToCharDecode");
+
+ @Override
+ public String getCode() {
+ return "HEX_TO_CHAR_DECODE";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_STRING;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.hexToCharDecode(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/conversion/MaskXML.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/conversion/MaskXML.java
new file mode 100644
index 0000000000..f223ded434
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/conversion/MaskXML.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.conversion;
+
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+/** Escapes an XML string */
+public class MaskXML implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.MaskXML");
+
+ @Override
+ public String getCode() {
+ return "MASK_XML";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_STRING;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.escapeXml(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/conversion/UnescapeHTML.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/conversion/UnescapeHTML.java
new file mode 100644
index 0000000000..ea0b5d8723
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/conversion/UnescapeHTML.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.conversion;
+
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class UnescapeHTML implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.UnescapeHTML");
+
+ @Override
+ public String getCode() {
+ return "UNESCAPE_HTML";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_STRING;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.unEscapeHtml(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/conversion/UnescapeXML.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/conversion/UnescapeXML.java
new file mode 100644
index 0000000000..7661da8a57
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/conversion/UnescapeXML.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.conversion;
+
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class UnescapeXML implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.UnescapeXML");
+
+ @Override
+ public String getCode() {
+ return "UNESCAPE_XML";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_STRING;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.unEscapeXml(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/conversion/UseCDATA.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/conversion/UseCDATA.java
new file mode 100644
index 0000000000..6ec042c793
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/conversion/UseCDATA.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.conversion;
+
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class UseCDATA implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.UseCDATA");
+
+ @Override
+ public String getCode() {
+ return "USE_CDATA";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_STRING;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.useCDATA(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/AddDays.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/AddDays.java
new file mode 100644
index 0000000000..7fe43d191a
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/AddDays.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.date;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class AddDays implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.DatePlusDays");
+
+ @Override
+ public String getCode() {
+ return "ADD_DAYS";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_DATE;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.addDays(in.metaA, in.dataA, in.metaB, in.dataB));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/AddHours.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/AddHours.java
new file mode 100644
index 0000000000..bbbd5ebfad
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/AddHours.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.date;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class AddHours implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.DatePlusHours");
+
+ @Override
+ public String getCode() {
+ return "ADD_HOURS";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_DATE;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.addHours(in.metaA, in.dataA, in.metaB, in.dataB));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/AddMinutes.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/AddMinutes.java
new file mode 100644
index 0000000000..f36dad727c
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/AddMinutes.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.date;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class AddMinutes implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.DatePlusMinutes");
+
+ @Override
+ public String getCode() {
+ return "ADD_MINUTES";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_DATE;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.addMinutes(in.metaA, in.dataA, in.metaB, in.dataB));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/AddMonths.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/AddMonths.java
new file mode 100644
index 0000000000..43bd46fc5f
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/AddMonths.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.date;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class AddMonths implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.DatePlusMonths");
+
+ @Override
+ public String getCode() {
+ return "ADD_MONTHS";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_DATE;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.addMonths(in.metaA, in.dataA, in.metaB, in.dataB));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/AddSeconds.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/AddSeconds.java
new file mode 100644
index 0000000000..f646afe16c
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/AddSeconds.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.date;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class AddSeconds implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.AddSeconds");
+
+ @Override
+ public String getCode() {
+ return "ADD_SECONDS";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_DATE;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.addSeconds(in.metaA, in.dataA, in.metaB, in.dataB));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/AddTimeToDate.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/AddTimeToDate.java
new file mode 100644
index 0000000000..6d45af89ba
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/AddTimeToDate.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.date;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class AddTimeToDate implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.AddTimeToDate");
+
+ @Override
+ public String getCode() {
+ return "ADD_TIME_TO_DATE";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_DATE;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ getDefaultResultType(),
+ ValueDataUtil.addTimeToDate(in.metaA, in.dataA, in.metaB, in.dataB, in.metaC, in.dataC));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/DateDiff.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/DateDiff.java
new file mode 100644
index 0000000000..657232b7fe
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/DateDiff.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.date;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class DateDiff implements ICalculation {
+ private final String code;
+ private final String resultType;
+ private final String description;
+
+ public DateDiff(INTERVAL interval) {
+ this.code = interval.name();
+ this.resultType = interval.resultType;
+ this.description = BaseMessages.getString(PKG, interval.messageKey);
+ }
+
+ @Override
+ public String getCode() {
+ return code;
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_INTEGER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ getDefaultResultType(),
+ ValueDataUtil.DateDiff(in.metaA, in.dataA, in.metaB, in.dataB, resultType));
+ }
+
+ public enum INTERVAL {
+ DATE_DIFF("d", "CalculatorMetaFunction.CalcFunctions.DateDiff"),
+ DATE_DIFF_HR("h", "CalculatorMetaFunction.CalcFunctions.DateDiffHr"),
+ DATE_DIFF_MN("mn", "CalculatorMetaFunction.CalcFunctions.DateDiffMn"),
+ DATE_DIFF_SEC("s", "CalculatorMetaFunction.CalcFunctions.DateDiffSec"),
+ DATE_DIFF_MSEC("ms", "CalculatorMetaFunction.CalcFunctions.DateDiffMsec");
+ final String resultType, messageKey;
+
+ INTERVAL(String resultType, String messageKey) {
+ this.resultType = resultType;
+ this.messageKey = messageKey;
+ }
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/DateWorkingDiff.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/DateWorkingDiff.java
new file mode 100644
index 0000000000..0546f3a2f6
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/DateWorkingDiff.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.date;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class DateWorkingDiff implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.DateDiffWorking");
+
+ @Override
+ public String getCode() {
+ return "DATE_WORKING_DIFF";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_INTEGER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ getDefaultResultType(),
+ ValueDataUtil.DateWorkingDiff(in.metaA, in.dataA, in.metaB, in.dataB));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/DayOfMonth.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/DayOfMonth.java
new file mode 100644
index 0000000000..473e5dfdd8
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/DayOfMonth.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.date;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class DayOfMonth implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.DayOfMonth");
+
+ @Override
+ public String getCode() {
+ return "DAY_OF_MONTH";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_INTEGER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.dayOfMonth(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/DayOfWeek.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/DayOfWeek.java
new file mode 100644
index 0000000000..1fbc45d636
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/DayOfWeek.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.date;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class DayOfWeek implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.DayOfWeek");
+
+ @Override
+ public String getCode() {
+ return "DAY_OF_WEEK";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_INTEGER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.dayOfWeek(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/DayOfYear.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/DayOfYear.java
new file mode 100644
index 0000000000..c1388d0a3b
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/DayOfYear.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.date;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class DayOfYear implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.DayOfYear");
+
+ @Override
+ public String getCode() {
+ return "DAY_OF_YEAR";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_INTEGER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.dayOfYear(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/FirstDayOfMonth.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/FirstDayOfMonth.java
new file mode 100644
index 0000000000..3b57ee9e0d
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/FirstDayOfMonth.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.date;
+
+import java.util.Calendar;
+import java.util.Date;
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class FirstDayOfMonth implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.FirstDayOfMonthDate");
+
+ @Override
+ public String getCode() {
+ return "FIRST_DAY_OF_MONTH";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_DATE;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ Object value = null;
+
+ if (!in.metaA.isNull(in.dataA)) {
+ Date dateValue = in.metaA.getDate(in.dataA);
+
+ if (dateValue != null) {
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(dateValue);
+ cal.set(Calendar.DAY_OF_MONTH, 1);
+ value = cal.getTime();
+ }
+ }
+
+ return new CalculationOutput(getDefaultResultType(), value);
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/HourOfDay.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/HourOfDay.java
new file mode 100644
index 0000000000..782821de43
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/HourOfDay.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.date;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class HourOfDay implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.HourOfDay");
+
+ @Override
+ public String getCode() {
+ return "HOUR_OF_DAY";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_INTEGER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.hourOfDay(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/LastDayOfMonth.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/LastDayOfMonth.java
new file mode 100644
index 0000000000..8bca239dca
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/LastDayOfMonth.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.date;
+
+import java.util.Calendar;
+import java.util.Date;
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class LastDayOfMonth implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.LastDayOfMonthDate");
+
+ @Override
+ public String getCode() {
+ return "LAST_DAY_OF_MONTH";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_DATE;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ Object value = null;
+
+ if (!in.metaA.isNull(in.dataA)) {
+ Date dateValue = in.metaA.getDate(in.dataA);
+
+ if (dateValue != null) {
+ Calendar cal = java.util.Calendar.getInstance();
+ cal.setTime(dateValue);
+ cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
+ value = cal.getTime();
+ }
+ }
+
+ return new CalculationOutput(getDefaultResultType(), value);
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/MinuteOfHour.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/MinuteOfHour.java
new file mode 100644
index 0000000000..397776edb7
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/MinuteOfHour.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.date;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class MinuteOfHour implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.MinuteOfHour");
+
+ @Override
+ public String getCode() {
+ return "MINUTE_OF_HOUR";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_INTEGER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.minuteOfHour(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/MonthOfDate.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/MonthOfDate.java
new file mode 100644
index 0000000000..cdaa98028d
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/MonthOfDate.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.date;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class MonthOfDate implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.MonthOfDate");
+
+ @Override
+ public String getCode() {
+ return "MONTH_OF_DATE";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_INTEGER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.monthOfDate(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/QuarterOfDate.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/QuarterOfDate.java
new file mode 100644
index 0000000000..bfc1fd5887
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/QuarterOfDate.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.date;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class QuarterOfDate implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.QuarterOfDate");
+
+ @Override
+ public String getCode() {
+ return "QUARTER_OF_DATE";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_INTEGER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.quarterOfDate(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/RemoveTimeFromDate.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/RemoveTimeFromDate.java
new file mode 100644
index 0000000000..da42f0d438
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/RemoveTimeFromDate.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.date;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class RemoveTimeFromDate implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.RemoveTimeFromDate");
+
+ @Override
+ public String getCode() {
+ return "REMOVE_TIME_FROM_DATE";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_DATE;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ ICalculation.getResultType(in.metaA), ValueDataUtil.removeTimeFromDate(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/SecondOfMinute.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/SecondOfMinute.java
new file mode 100644
index 0000000000..d250e6a9ee
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/SecondOfMinute.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.date;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class SecondOfMinute implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.SecondOfMinute");
+
+ @Override
+ public String getCode() {
+ return "SECOND_OF_MINUTE";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_INTEGER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.secondOfMinute(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/WeekOfYear.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/WeekOfYear.java
new file mode 100644
index 0000000000..d49b487697
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/WeekOfYear.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.date;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class WeekOfYear implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.WeekOfYear");
+
+ @Override
+ public String getCode() {
+ return "WEEK_OF_YEAR";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_INTEGER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.weekOfYear(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/WeekOfYearISO8601.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/WeekOfYearISO8601.java
new file mode 100644
index 0000000000..1f7b12950c
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/WeekOfYearISO8601.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.date;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class WeekOfYearISO8601 implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.WeekOfYearISO8601");
+
+ @Override
+ public String getCode() {
+ return "WEEK_OF_YEAR_ISO8601";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_INTEGER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.weekOfYearISO8601(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/YearOfDate.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/YearOfDate.java
new file mode 100644
index 0000000000..2769ee3e50
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/YearOfDate.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.date;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class YearOfDate implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.YearOfDate");
+
+ @Override
+ public String getCode() {
+ return "YEAR_OF_DATE";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_INTEGER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.yearOfDate(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/YearOfDateISO8601.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/YearOfDateISO8601.java
new file mode 100644
index 0000000000..85cad1e49f
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/date/YearOfDateISO8601.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.date;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class YearOfDateISO8601 implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.YearOfDateISO8601");
+
+ @Override
+ public String getCode() {
+ return "YEAR_OF_DATE_ISO8601";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_INTEGER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.yearOfDateISO8601(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/file/ADLER32.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/file/ADLER32.java
new file mode 100644
index 0000000000..f5f798dfb6
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/file/ADLER32.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.file;
+
+import org.apache.hop.core.exception.HopFileNotFoundException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class ADLER32 implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.Adler32");
+
+ @Override
+ public String getCode() {
+ return "ADLER32";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_INTEGER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopFileNotFoundException {
+ return new CalculationOutput(
+ getDefaultResultType(),
+ ValueDataUtil.checksumAdler32(in.metaA, in.dataA, in.isFailIfNoFile));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/file/CRC32.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/file/CRC32.java
new file mode 100644
index 0000000000..ee1de758bc
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/file/CRC32.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.file;
+
+import org.apache.hop.core.exception.HopFileNotFoundException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class CRC32 implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.CRC32");
+
+ @Override
+ public String getCode() {
+ return "CRC32";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_INTEGER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopFileNotFoundException {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.checksumCRC32(in.metaA, in.dataA, in.isFailIfNoFile));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/file/CheckXMLFileWellFormed.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/file/CheckXMLFileWellFormed.java
new file mode 100644
index 0000000000..fa2e10f90e
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/file/CheckXMLFileWellFormed.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.file;
+
+import org.apache.hop.core.exception.HopFileNotFoundException;
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class CheckXMLFileWellFormed implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.CheckXmlFileWellFormed");
+
+ @Override
+ public String getCode() {
+ return "CHECK_XML_FILE_WELL_FORMED";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_BOOLEAN;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in)
+ throws HopValueException, HopFileNotFoundException {
+ return new CalculationOutput(
+ getDefaultResultType(),
+ ValueDataUtil.isXmlFileWellFormed(in.metaA, in.dataA, in.isFailIfNoFile));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/file/GetFileEncoding.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/file/GetFileEncoding.java
new file mode 100644
index 0000000000..1c0113124c
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/file/GetFileEncoding.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.file;
+
+import org.apache.hop.core.exception.HopFileNotFoundException;
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class GetFileEncoding implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.GetFileEncoding");
+
+ @Override
+ public String getCode() {
+ return "GET_FILE_ENCODING";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_STRING;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in)
+ throws HopValueException, HopFileNotFoundException {
+ return new CalculationOutput(
+ getDefaultResultType(),
+ ValueDataUtil.getFileEncoding(in.metaA, in.dataA, in.isFailIfNoFile));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/file/LoadFileContentBinary.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/file/LoadFileContentBinary.java
new file mode 100644
index 0000000000..f0584a35d0
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/file/LoadFileContentBinary.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.file;
+
+import org.apache.hop.core.exception.HopFileNotFoundException;
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+/** Load content of a file into a BLOB */
+public class LoadFileContentBinary implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.LoadFileContentInBinary");
+
+ @Override
+ public String getCode() {
+ return "LOAD_FILE_CONTENT_BINARY";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_BINARY;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in)
+ throws HopValueException, HopFileNotFoundException {
+ return new CalculationOutput(
+ getDefaultResultType(),
+ ValueDataUtil.loadFileContentInBinary(in.metaA, in.dataA, in.isFailIfNoFile));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/file/MessageDigest.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/file/MessageDigest.java
new file mode 100644
index 0000000000..638e81315a
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/file/MessageDigest.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.file;
+
+import org.apache.hop.core.exception.HopFileNotFoundException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class MessageDigest implements ICalculation {
+ private final String code;
+ private final String algorithmType;
+ private final String description;
+
+ public MessageDigest(ALGORITHM algorithm) {
+ this.code = algorithm.name();
+ this.algorithmType = algorithm.type;
+ this.description = BaseMessages.getString(PKG, algorithm.messageKey);
+ }
+
+ @Override
+ public String getCode() {
+ return this.code;
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_STRING;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopFileNotFoundException {
+ return new CalculationOutput(
+ getDefaultResultType(),
+ ValueDataUtil.createChecksum(in.metaA, in.dataA, algorithmType, in.isFailIfNoFile));
+ }
+
+ public enum ALGORITHM {
+ MD5("MD5", "CalculatorMetaFunction.CalcFunctions.MD5"),
+ SHA1("SHA-1", "CalculatorMetaFunction.CalcFunctions.SHA1"),
+ SHA256("SHA-256", "CalculatorMetaFunction.CalcFunctions.SHA256"),
+ SHA384("SHA-384", "CalculatorMetaFunction.CalcFunctions.SHA384"),
+ SHA512("SHA-512", "CalculatorMetaFunction.CalcFunctions.SHA512");
+ final String type, messageKey;
+
+ ALGORITHM(String type, String messageKey) {
+ this.type = type;
+ this.messageKey = messageKey;
+ }
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Abs.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Abs.java
new file mode 100644
index 0000000000..0e0f65c9c7
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Abs.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.math;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class Abs implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.Abs");
+
+ @Override
+ public String getCode() {
+ return "ABS";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_INTEGER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ ICalculation.getResultType(in.metaA), ValueDataUtil.abs(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Add.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Add.java
new file mode 100644
index 0000000000..470aa224ae
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Add.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.math;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class Add implements ICalculation {
+ @Override
+ public String getCode() {
+ return "ADD";
+ }
+
+ @Override
+ public String getDescription() {
+ return "A + B";
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_NUMBER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ Object value = ValueDataUtil.plus(in.metaA, in.dataA, in.metaB, in.dataB);
+ int resultType =
+ (in.metaA.isString() || in.metaB.isString())
+ ? IValueMeta.TYPE_STRING
+ : ICalculation.getResultType(in.metaA);
+
+ return new CalculationOutput(resultType, value);
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Add3.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Add3.java
new file mode 100644
index 0000000000..0cbaa3e6aa
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Add3.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.math;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class Add3 implements ICalculation {
+ @Override
+ public String getCode() {
+ return "ADD3";
+ }
+
+ @Override
+ public String getDescription() {
+ return "A + B + C";
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_NUMBER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ Object value = ValueDataUtil.plus3(in.metaA, in.dataA, in.metaB, in.dataB, in.metaC, in.dataC);
+ int resultType =
+ (in.metaA.isString() || in.metaB.isString() || in.metaC.isString())
+ ? IValueMeta.TYPE_STRING
+ : ICalculation.getResultType(in.metaA);
+
+ return new CalculationOutput(resultType, value);
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Ceil.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Ceil.java
new file mode 100644
index 0000000000..7b42a32da9
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Ceil.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.math;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class Ceil implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.Ceil");
+
+ @Override
+ public String getCode() {
+ return "CEIL";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_INTEGER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ ICalculation.getResultType(in.metaA), ValueDataUtil.ceil(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Combination1.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Combination1.java
new file mode 100644
index 0000000000..b56444d579
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Combination1.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.math;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class Combination1 implements ICalculation {
+ @Override
+ public String getCode() {
+ return "COMBINATION_1";
+ }
+
+ @Override
+ public String getDescription() {
+ return "A + B * C";
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_NUMBER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ ICalculation.getResultType(in.metaA),
+ ValueDataUtil.combination1(in.metaA, in.dataA, in.metaB, in.dataB, in.metaC, in.dataC));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Combination2.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Combination2.java
new file mode 100644
index 0000000000..02fb0c227b
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Combination2.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.math;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class Combination2 implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.Hypotenuse");
+
+ @Override
+ public String getCode() {
+ return "COMBINATION_2";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_NUMBER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ ICalculation.getResultType(in.metaA),
+ ValueDataUtil.combination2(in.metaA, in.dataA, in.metaB, in.dataB));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Divide.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Divide.java
new file mode 100644
index 0000000000..b620a239aa
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Divide.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.math;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class Divide implements ICalculation {
+ @Override
+ public String getCode() {
+ return "DIVIDE";
+ }
+
+ @Override
+ public String getDescription() {
+ return "A / B";
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_NUMBER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ ICalculation.getResultType(in.metaA),
+ ValueDataUtil.divide(in.metaA, in.dataA, in.metaB, in.dataB));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Floor.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Floor.java
new file mode 100644
index 0000000000..3e38b1af7b
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Floor.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.math;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class Floor implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.Floor");
+
+ @Override
+ public String getCode() {
+ return "FLOOR";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_INTEGER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ ICalculation.getResultType(in.metaA), ValueDataUtil.floor(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/GetOnlyDigits.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/GetOnlyDigits.java
new file mode 100644
index 0000000000..5392fa1137
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/GetOnlyDigits.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.math;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class GetOnlyDigits implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.GetOnlyDigits");
+
+ @Override
+ public String getCode() {
+ return "GET_ONLY_DIGITS";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_STRING;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.getDigits(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Multiply.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Multiply.java
new file mode 100644
index 0000000000..0783e6df27
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Multiply.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.math;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class Multiply implements ICalculation {
+ @Override
+ public String getCode() {
+ return "MULTIPLY";
+ }
+
+ @Override
+ public String getDescription() {
+ return "A * B";
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_NUMBER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ Object value = ValueDataUtil.multiply(in.metaA, in.dataA, in.metaB, in.dataB);
+ int resultType =
+ (in.metaA.isString() || in.metaB.isString())
+ ? IValueMeta.TYPE_STRING
+ : ICalculation.getResultType(in.metaA);
+
+ return new CalculationOutput(resultType, value);
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Percent1.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Percent1.java
new file mode 100644
index 0000000000..547bccd33e
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Percent1.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.math;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class Percent1 implements ICalculation {
+ @Override
+ public String getCode() {
+ return "PERCENT_1";
+ }
+
+ @Override
+ public String getDescription() {
+ return "100 * A / B";
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_NUMBER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ ICalculation.getResultType(in.metaA),
+ ValueDataUtil.percent1(in.metaA, in.dataA, in.metaB, in.dataB));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Percent2.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Percent2.java
new file mode 100644
index 0000000000..b20d3ef208
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Percent2.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.math;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class Percent2 implements ICalculation {
+ @Override
+ public String getCode() {
+ return "PERCENT_2";
+ }
+
+ @Override
+ public String getDescription() {
+ return "A - ( A * B / 100 )";
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_NUMBER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ ICalculation.getResultType(in.metaA),
+ ValueDataUtil.percent2(in.metaA, in.dataA, in.metaB, in.dataB));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Percent3.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Percent3.java
new file mode 100644
index 0000000000..1ca59f5eeb
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Percent3.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.math;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class Percent3 implements ICalculation {
+ @Override
+ public String getCode() {
+ return "PERCENT_3";
+ }
+
+ @Override
+ public String getDescription() {
+ return "A + ( A * B / 100 )";
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_NUMBER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ ICalculation.getResultType(in.metaA),
+ ValueDataUtil.percent3(in.metaA, in.dataA, in.metaB, in.dataB));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Remainder.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Remainder.java
new file mode 100644
index 0000000000..a03a0d4268
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Remainder.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.math;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class Remainder implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.Remainder");
+
+ @Override
+ public String getCode() {
+ return "REMAINDER";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_NUMBER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ if (in.targetMeta.getType() != in.metaA.getType()
+ || in.targetMeta.getType() != in.metaB.getType()) {
+
+ Object dataA = in.targetMeta.convertData(in.metaA, in.dataA);
+ IValueMeta metaA = in.targetMeta.clone();
+ Object dataB = in.targetMeta.convertData(in.metaB, in.dataB);
+ IValueMeta metaB = in.targetMeta.clone();
+
+ return new CalculationOutput(
+ in.targetMeta.getType(), ValueDataUtil.remainder(metaA, dataA, metaB, dataB));
+ }
+
+ return new CalculationOutput(
+ in.targetMeta.getType(), ValueDataUtil.remainder(in.metaA, in.dataA, in.metaB, in.dataB));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/RemoveDigits.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/RemoveDigits.java
new file mode 100644
index 0000000000..5e56762f23
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/RemoveDigits.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.math;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class RemoveDigits implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.RemoveDigits");
+
+ @Override
+ public String getCode() {
+ return "REMOVE_DIGITS";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_STRING;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.removeDigits(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Round1.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Round1.java
new file mode 100644
index 0000000000..69aa48270e
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Round1.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.math;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class Round1 implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.Round");
+
+ @Override
+ public String getCode() {
+ return "ROUND_1";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_INTEGER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ ICalculation.getResultType(in.metaA), ValueDataUtil.round(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Round2.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Round2.java
new file mode 100644
index 0000000000..8c5c55ee9a
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Round2.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.math;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class Round2 implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.Round2");
+
+ @Override
+ public String getCode() {
+ return "ROUND_1";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_NUMBER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ ICalculation.getResultType(in.metaA),
+ ValueDataUtil.round(in.metaA, in.dataA, in.metaB, in.dataB));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/RoundCustom1.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/RoundCustom1.java
new file mode 100644
index 0000000000..737092a3be
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/RoundCustom1.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.math;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class RoundCustom1 implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.RoundCustom");
+
+ @Override
+ public String getCode() {
+ return "ROUND_CUSTOM_1";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_NUMBER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ ICalculation.getResultType(in.metaA),
+ ValueDataUtil.round(in.metaA, in.dataA, in.metaB.getNumber(in.dataB).intValue()));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/RoundCustom2.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/RoundCustom2.java
new file mode 100644
index 0000000000..fb10722de3
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/RoundCustom2.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.math;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class RoundCustom2 implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.RoundCustom2");
+
+ @Override
+ public String getCode() {
+ return "ROUND_CUSTOM_2";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_NUMBER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ ICalculation.getResultType(in.metaA),
+ ValueDataUtil.round(
+ in.metaA, in.dataA, in.metaB, in.dataB, in.metaC.getNumber(in.dataC).intValue()));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/RoundStd1.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/RoundStd1.java
new file mode 100644
index 0000000000..a861b98955
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/RoundStd1.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.math;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class RoundStd1 implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.RoundStd");
+
+ @Override
+ public String getCode() {
+ return "ROUND_STD_1";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_INTEGER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ ICalculation.getResultType(in.metaA),
+ ValueDataUtil.round(in.metaA, in.dataA, java.math.BigDecimal.ROUND_HALF_UP));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/RoundStd2.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/RoundStd2.java
new file mode 100644
index 0000000000..f1d1246075
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/RoundStd2.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.math;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class RoundStd2 implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.RoundStd2");
+
+ @Override
+ public String getCode() {
+ return "ROUND_STD_2";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_NUMBER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ ICalculation.getResultType(in.metaA),
+ ValueDataUtil.round(
+ in.metaA, in.dataA, in.metaB, in.dataB, java.math.BigDecimal.ROUND_HALF_UP));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Square.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Square.java
new file mode 100644
index 0000000000..66519eda2a
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Square.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.math;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class Square implements ICalculation {
+ @Override
+ public String getCode() {
+ return "SQUARE";
+ }
+
+ @Override
+ public String getDescription() {
+ return "A * A";
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_NUMBER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ ICalculation.getResultType(in.metaA),
+ ValueDataUtil.multiply(in.metaA, in.dataA, in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/SquareRoot.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/SquareRoot.java
new file mode 100644
index 0000000000..8bfcaccb11
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/SquareRoot.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.math;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class SquareRoot implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.SQRT");
+
+ @Override
+ public String getCode() {
+ return "SQUARE_ROOT";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_NUMBER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ return new CalculationOutput(
+ ICalculation.getResultType(in.metaA), ValueDataUtil.sqrt(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Subtract.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Subtract.java
new file mode 100644
index 0000000000..ba24584424
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/math/Subtract.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.math;
+
+import org.apache.hop.core.exception.HopValueException;
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class Subtract implements ICalculation {
+ @Override
+ public String getCode() {
+ return "SUBTRACT";
+ }
+
+ @Override
+ public String getDescription() {
+ return "A - B";
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_NUMBER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) throws HopValueException {
+ Object value = ValueDataUtil.minus(in.metaA, in.dataA, in.metaB, in.dataB);
+ int resultType =
+ (in.metaA.isDate()) ? IValueMeta.TYPE_INTEGER : ICalculation.getResultType(in.metaA);
+
+ return new CalculationOutput(resultType, value);
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/statistics/DamerauLevenshtein.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/statistics/DamerauLevenshtein.java
new file mode 100644
index 0000000000..7b2cf59467
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/statistics/DamerauLevenshtein.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.statistics;
+
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class DamerauLevenshtein implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.DamerauLevenshtein");
+
+ @Override
+ public String getCode() {
+ return "DAMERAU_LEVENSHTEIN";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_INTEGER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) {
+ return new CalculationOutput(
+ getDefaultResultType(),
+ ValueDataUtil.getDamerauLevenshtein_Distance(in.metaA, in.dataA, in.metaB, in.dataB));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/statistics/DoubleMetaphone.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/statistics/DoubleMetaphone.java
new file mode 100644
index 0000000000..095f5aa757
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/statistics/DoubleMetaphone.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.statistics;
+
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class DoubleMetaphone implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.DoubleMetaphone");
+
+ @Override
+ public String getCode() {
+ return "DOUBLE_METAPHONE";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_STRING;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.get_Double_Metaphone(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/statistics/Jaro.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/statistics/Jaro.java
new file mode 100644
index 0000000000..c9ff910af2
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/statistics/Jaro.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.statistics;
+
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class Jaro implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.Jaro");
+
+ @Override
+ public String getCode() {
+ return "JARO";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_NUMBER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) {
+ return new CalculationOutput(
+ getDefaultResultType(),
+ ValueDataUtil.getJaro_Similitude(in.metaA, in.dataA, in.metaB, in.dataB));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/statistics/JaroWinkler.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/statistics/JaroWinkler.java
new file mode 100644
index 0000000000..18540f8d27
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/statistics/JaroWinkler.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.statistics;
+
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class JaroWinkler implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.JaroWinkler");
+
+ @Override
+ public String getCode() {
+ return "JARO_WINKLER";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_NUMBER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) {
+ return new CalculationOutput(
+ getDefaultResultType(),
+ ValueDataUtil.getJaroWinkler_Similitude(in.metaA, in.dataA, in.metaB, in.dataB));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/statistics/LevenshteinDistance.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/statistics/LevenshteinDistance.java
new file mode 100644
index 0000000000..6e64a7a63f
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/statistics/LevenshteinDistance.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.statistics;
+
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class LevenshteinDistance implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.LevenshteinDistance");
+
+ @Override
+ public String getCode() {
+ return "LEVENSHTEIN_DISTANCE";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_INTEGER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) {
+ return new CalculationOutput(
+ getDefaultResultType(),
+ ValueDataUtil.getLevenshtein_Distance(in.metaA, in.dataA, in.metaB, in.dataB));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/statistics/Metaphone.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/statistics/Metaphone.java
new file mode 100644
index 0000000000..c4fbc10ab7
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/statistics/Metaphone.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.statistics;
+
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class Metaphone implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.Metaphone");
+
+ @Override
+ public String getCode() {
+ return "METAPHONE";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_STRING;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.get_Metaphone(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/statistics/NeedlemanWunsch.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/statistics/NeedlemanWunsch.java
new file mode 100644
index 0000000000..370818af63
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/statistics/NeedlemanWunsch.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.statistics;
+
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+/**
+ * The NeedlemanWunsch distance is a measure of the similarity between two strings. The distance is
+ * the number of deletions, insertions, or substitutions required to transform a source string (s)
+ * into a target string (t).
+ */
+public class NeedlemanWunsch implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.NeedlemanWunsch");
+
+ @Override
+ public String getCode() {
+ // Name left unchanged for backward-compatibility
+ return "NEEDLEMAN_WUNSH";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_INTEGER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) {
+ Object value = null;
+
+ if (in.dataA != null && in.dataB != null) {
+ value =
+ (long)
+ new com.wcohen.ss.NeedlemanWunsch().score(in.dataA.toString(), in.dataB.toString());
+ }
+
+ return new CalculationOutput(getDefaultResultType(), value);
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/statistics/RefinedSoundex.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/statistics/RefinedSoundex.java
new file mode 100644
index 0000000000..b0d40b309e
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/statistics/RefinedSoundex.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.statistics;
+
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class RefinedSoundex implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.RefinedSoundEx");
+
+ @Override
+ public String getCode() {
+ return "REFINED_SOUNDEX";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_STRING;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.get_RefinedSoundEx(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/statistics/Soundex.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/statistics/Soundex.java
new file mode 100644
index 0000000000..65219f06d4
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/statistics/Soundex.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.statistics;
+
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class Soundex implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.SoundEx");
+
+ @Override
+ public String getCode() {
+ return "SOUNDEX";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_STRING;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.get_SoundEx(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/text/CheckXmlWellFormed.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/text/CheckXmlWellFormed.java
new file mode 100644
index 0000000000..7c5e112d62
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/text/CheckXmlWellFormed.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.text;
+
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class CheckXmlWellFormed implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.CheckXmlWellFormed");
+
+ @Override
+ public String getCode() {
+ return "CHECK_XML_WELL_FORMED";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_BOOLEAN;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.isXmlWellFormed(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/text/InitCap.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/text/InitCap.java
new file mode 100644
index 0000000000..c1e3cd9d4e
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/text/InitCap.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.text;
+
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class InitCap implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.InitCap");
+
+ @Override
+ public String getCode() {
+ return "INIT_CAP";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_STRING;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) {
+ return new CalculationOutput(getDefaultResultType(), ValueDataUtil.initCap(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/text/LowerCase.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/text/LowerCase.java
new file mode 100644
index 0000000000..c902d24550
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/text/LowerCase.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.text;
+
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class LowerCase implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.LowerCase");
+
+ @Override
+ public String getCode() {
+ return "LOWER_CASE";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_STRING;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.lowerCase(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/text/RemoveCR.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/text/RemoveCR.java
new file mode 100644
index 0000000000..bb9dbbf16e
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/text/RemoveCR.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.text;
+
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class RemoveCR implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.RemoveCR");
+
+ @Override
+ public String getCode() {
+ return "REMOVE_CR";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_STRING;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.removeCR(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/text/RemoveCRLF.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/text/RemoveCRLF.java
new file mode 100644
index 0000000000..7efac4472e
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/text/RemoveCRLF.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.text;
+
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class RemoveCRLF implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.RemoveCRLF");
+
+ @Override
+ public String getCode() {
+ return "REMOVE_CRLF";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_STRING;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.removeCRLF(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/text/RemoveLF.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/text/RemoveLF.java
new file mode 100644
index 0000000000..e62b1d0f7c
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/text/RemoveLF.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.text;
+
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class RemoveLF implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.RemoveLF");
+
+ @Override
+ public String getCode() {
+ return "REMOVE_LF";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_STRING;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.removeLF(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/text/RemoveTab.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/text/RemoveTab.java
new file mode 100644
index 0000000000..4f24a60e78
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/text/RemoveTab.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.text;
+
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class RemoveTab implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.RemoveTAB");
+
+ @Override
+ public String getCode() {
+ return "REMOVE_TAB";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_STRING;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.removeTAB(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/text/StringLen.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/text/StringLen.java
new file mode 100644
index 0000000000..b2565638c1
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/text/StringLen.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.text;
+
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class StringLen implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.StringLen");
+
+ @Override
+ public String getCode() {
+ return "STRING_LEN";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_INTEGER;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.stringLen(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/text/SubstituteVariable.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/text/SubstituteVariable.java
new file mode 100644
index 0000000000..7a5c9b8f96
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/text/SubstituteVariable.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.text;
+
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class SubstituteVariable implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.SubstituteVariable");
+
+ @Override
+ public String getCode() {
+ return "SUBSTITUTE_VARIABLE";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_STRING;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) {
+ return new CalculationOutput(getDefaultResultType(), in.variables.resolve(in.dataA.toString()));
+ }
+}
diff --git a/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/text/UpperCase.java b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/text/UpperCase.java
new file mode 100644
index 0000000000..92f74d1107
--- /dev/null
+++ b/plugins/transforms/calculator/src/main/java/org/apache/hop/pipeline/transforms/calculator/calculations/text/UpperCase.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.pipeline.transforms.calculator.calculations.text;
+
+import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.ValueDataUtil;
+import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.pipeline.transforms.calculator.CalculationInput;
+import org.apache.hop.pipeline.transforms.calculator.CalculationOutput;
+import org.apache.hop.pipeline.transforms.calculator.ICalculation;
+
+public class UpperCase implements ICalculation {
+ private static final String description =
+ BaseMessages.getString(PKG, "CalculatorMetaFunction.CalcFunctions.UpperCase");
+
+ @Override
+ public String getCode() {
+ return "UPPER_CASE";
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int getDefaultResultType() {
+ return IValueMeta.TYPE_STRING;
+ }
+
+ @Override
+ public CalculationOutput calculate(CalculationInput in) {
+ return new CalculationOutput(
+ getDefaultResultType(), ValueDataUtil.upperCase(in.metaA, in.dataA));
+ }
+}
diff --git a/plugins/transforms/calculator/src/test/java/org/apache/hop/pipeline/transforms/calculator/CalculatorMetaFunctionTest.java b/plugins/transforms/calculator/src/test/java/org/apache/hop/pipeline/transforms/calculator/CalculatorMetaFunctionTest.java
index f186a579b1..12e3401cb8 100644
--- a/plugins/transforms/calculator/src/test/java/org/apache/hop/pipeline/transforms/calculator/CalculatorMetaFunctionTest.java
+++ b/plugins/transforms/calculator/src/test/java/org/apache/hop/pipeline/transforms/calculator/CalculatorMetaFunctionTest.java
@@ -36,7 +36,7 @@ class CalculatorMetaFunctionTest {
assertNotEquals(new Object(), meta1);
assertEquals(meta1, meta2);
- meta2.setCalcType(CalculatorMetaFunction.CalculationType.ADD_DAYS);
+ meta2.setCalcType(CalculationType.ADD_DAYS);
assertNotEquals(meta1, meta2);
}
@@ -45,7 +45,7 @@ class CalculatorMetaFunctionTest {
CalculatorMetaFunction function =
new CalculatorMetaFunction(
"copyA",
- CalculatorMetaFunction.CalculationType.COPY_OF_FIELD,
+ CalculationType.COPY_OF_FIELD,
"A",
null,
null,
diff --git a/plugins/transforms/calculator/src/test/java/org/apache/hop/pipeline/transforms/calculator/CalculatorMetaTest.java b/plugins/transforms/calculator/src/test/java/org/apache/hop/pipeline/transforms/calculator/CalculatorMetaTest.java
index be29d84906..d6192ed05d 100644
--- a/plugins/transforms/calculator/src/test/java/org/apache/hop/pipeline/transforms/calculator/CalculatorMetaTest.java
+++ b/plugins/transforms/calculator/src/test/java/org/apache/hop/pipeline/transforms/calculator/CalculatorMetaTest.java
@@ -60,8 +60,8 @@ class CalculatorMetaTest {
private static final Random rand = new Random();
private static CalculatorMetaFunction generateTestFunction() {
- CalculatorMetaFunction.CalculationType[] types =
- CalculatorMetaFunction.CalculationType.values();
+ CalculationType[] types = CalculationType.values();
+
String[] valueTypes = {"String", "Number", "Date", "Integer", "Boolean"};
CalculatorMetaFunction rtn = new CalculatorMetaFunction();
diff --git a/plugins/transforms/calculator/src/test/java/org/apache/hop/pipeline/transforms/calculator/CalculatorUnitTest.java b/plugins/transforms/calculator/src/test/java/org/apache/hop/pipeline/transforms/calculator/CalculatorUnitTest.java
index 6f89afd783..99d8957d50 100644
--- a/plugins/transforms/calculator/src/test/java/org/apache/hop/pipeline/transforms/calculator/CalculatorUnitTest.java
+++ b/plugins/transforms/calculator/src/test/java/org/apache/hop/pipeline/transforms/calculator/CalculatorUnitTest.java
@@ -50,7 +50,6 @@ import org.apache.hop.core.row.value.ValueMetaNumber;
import org.apache.hop.core.row.value.ValueMetaString;
import org.apache.hop.junit.rules.RestoreHopEngineEnvironmentExtension;
import org.apache.hop.pipeline.transform.RowAdapter;
-import org.apache.hop.pipeline.transforms.calculator.CalculatorMetaFunction.CalculationType;
import org.apache.hop.pipeline.transforms.mock.TransformMockHelper;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
@@ -863,30 +862,23 @@ class CalculatorUnitTest {
public void assertRound2(final Number expectedResult, final Number value, final long precision)
throws HopException {
- assertRoundEveryDataType(
- expectedResult, CalculatorMetaFunction.CalculationType.ROUND_2, value, precision, null);
+ assertRoundEveryDataType(expectedResult, CalculationType.ROUND_2, value, precision, null);
}
public void assertRoundStd1(final Number expectedResult, final Number value) throws HopException {
- assertRoundEveryDataType(
- expectedResult, CalculatorMetaFunction.CalculationType.ROUND_STD_1, value, null, null);
+ assertRoundEveryDataType(expectedResult, CalculationType.ROUND_STD_1, value, null, null);
}
public void assertRoundStd2(final Number expectedResult, final Number value, final long precision)
throws HopException {
- assertRoundEveryDataType(
- expectedResult, CalculatorMetaFunction.CalculationType.ROUND_STD_2, value, precision, null);
+ assertRoundEveryDataType(expectedResult, CalculationType.ROUND_STD_2, value, precision, null);
}
public void assertRoundCustom1(
final Number expectedResult, final Number value, final long roundingMode)
throws HopException {
assertRoundEveryDataType(
- expectedResult,
- CalculatorMetaFunction.CalculationType.ROUND_CUSTOM_1,
- value,
- null,
- roundingMode);
+ expectedResult, CalculationType.ROUND_CUSTOM_1, value, null, roundingMode);
}
public void assertRoundCustom2(
@@ -896,11 +888,7 @@ class CalculatorUnitTest {
final long roundingMode)
throws HopException {
assertRoundEveryDataType(
- expectedResult,
- CalculatorMetaFunction.CalculationType.ROUND_CUSTOM_2,
- value,
- precision,
- roundingMode);
+ expectedResult, CalculationType.ROUND_CUSTOM_2, value, precision, roundingMode);
}
/**
diff --git a/plugins/transforms/calculator/src/test/java/org/apache/hop/pipeline/transforms/calculator/CalculatorValueDataUtilTest.java b/plugins/transforms/calculator/src/test/java/org/apache/hop/pipeline/transforms/calculator/CalculatorValueDataUtilTest.java
index 11cf3feda3..4f72a0f643 100644
--- a/plugins/transforms/calculator/src/test/java/org/apache/hop/pipeline/transforms/calculator/CalculatorValueDataUtilTest.java
+++ b/plugins/transforms/calculator/src/test/java/org/apache/hop/pipeline/transforms/calculator/CalculatorValueDataUtilTest.java
@@ -47,18 +47,17 @@ import org.apache.hop.core.row.value.ValueMetaInteger;
import org.apache.hop.core.row.value.ValueMetaString;
import org.apache.hop.core.util.Utils;
import org.apache.hop.junit.rules.RestoreHopEngineEnvironmentExtension;
-import org.apache.hop.pipeline.transforms.calculator.CalculatorMetaFunction.CalculationType;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.mockito.stubbing.Answer;
class CalculatorValueDataUtilTest {
+ private static final String YYYY_MM_DD = "yyyy-MM-dd";
+
@RegisterExtension
static RestoreHopEngineEnvironmentExtension env = new RestoreHopEngineEnvironmentExtension();
- private static final String YYYY_MM_DD = "yyyy-MM-dd";
-
@BeforeAll
static void setUpBeforeClass() throws HopException {
HopEnvironment.init();
@@ -74,11 +73,7 @@ class CalculatorValueDataUtilTest {
@Test
void testDateDiff_A_LT_B() {
Object daysDiff =
- calculate(
- "2010-12-31",
- "2011-02-10",
- IValueMeta.TYPE_DATE,
- CalculatorMetaFunction.CalculationType.DATE_DIFF);
+ calculate("2010-12-31", "2011-02-10", IValueMeta.TYPE_DATE, CalculationType.DATE_DIFF);
assertEquals((long) -41, daysDiff);
}
@@ -86,10 +81,7 @@ class CalculatorValueDataUtilTest {
void testWorkingDaysDays_A_GT_B() {
Object daysDiff =
calculate(
- "2010-05-12",
- "2010-01-01",
- IValueMeta.TYPE_DATE,
- CalculatorMetaFunction.CalculationType.DATE_WORKING_DIFF);
+ "2010-05-12", "2010-01-01", IValueMeta.TYPE_DATE, CalculationType.DATE_WORKING_DIFF);
assertEquals(94L, daysDiff);
}
@@ -97,10 +89,7 @@ class CalculatorValueDataUtilTest {
void testWorkingDaysDays_A_LT_B() {
Object daysDiff =
calculate(
- "2010-12-31",
- "2011-02-10",
- IValueMeta.TYPE_DATE,
- CalculatorMetaFunction.CalculationType.DATE_WORKING_DIFF);
+ "2010-12-31", "2011-02-10", IValueMeta.TYPE_DATE, CalculationType.DATE_WORKING_DIFF);
assertEquals((long) -30, daysDiff);
}
@@ -431,75 +420,48 @@ class CalculatorValueDataUtilTest {
// Test Hop number types
assertEquals(
- Double.valueOf("3.0"),
- calculate("1", "2", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.ADD));
+ Double.valueOf("3.0"), calculate("1", "2", IValueMeta.TYPE_NUMBER, CalculationType.ADD));
assertEquals(
- Double.valueOf("0.0"),
- calculate("2", "-2", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.ADD));
+ Double.valueOf("0.0"), calculate("2", "-2", IValueMeta.TYPE_NUMBER, CalculationType.ADD));
assertEquals(
- Double.valueOf("30.0"),
- calculate("10", "20", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.ADD));
+ Double.valueOf("30.0"), calculate("10", "20", IValueMeta.TYPE_NUMBER, CalculationType.ADD));
assertEquals(
Double.valueOf("-50.0"),
- calculate(
- "-100", "50", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.ADD));
+ calculate("-100", "50", IValueMeta.TYPE_NUMBER, CalculationType.ADD));
// Test Hop Integer (Java Long) types
assertEquals(
- Long.valueOf("3"),
- calculate("1", "2", IValueMeta.TYPE_INTEGER, CalculatorMetaFunction.CalculationType.ADD));
+ Long.valueOf("3"), calculate("1", "2", IValueMeta.TYPE_INTEGER, CalculationType.ADD));
assertEquals(
- Long.valueOf("0"),
- calculate("2", "-2", IValueMeta.TYPE_INTEGER, CalculatorMetaFunction.CalculationType.ADD));
+ Long.valueOf("0"), calculate("2", "-2", IValueMeta.TYPE_INTEGER, CalculationType.ADD));
assertEquals(
- Long.valueOf("30"),
- calculate("10", "20", IValueMeta.TYPE_INTEGER, CalculatorMetaFunction.CalculationType.ADD));
+ Long.valueOf("30"), calculate("10", "20", IValueMeta.TYPE_INTEGER, CalculationType.ADD));
assertEquals(
- Long.valueOf("-50"),
- calculate(
- "-100", "50", IValueMeta.TYPE_INTEGER, CalculatorMetaFunction.CalculationType.ADD));
+ Long.valueOf("-50"), calculate("-100", "50", IValueMeta.TYPE_INTEGER, CalculationType.ADD));
// Test Hop big Number types
assertEquals(
0,
new BigDecimal("2.0")
.compareTo(
- (BigDecimal)
- calculate(
- "1",
- "1",
- IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.ADD)));
+ (BigDecimal) calculate("1", "1", IValueMeta.TYPE_BIGNUMBER, CalculationType.ADD)));
assertEquals(
0,
new BigDecimal("0.0")
.compareTo(
- (BigDecimal)
- calculate(
- "2",
- "-2",
- IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.ADD)));
+ (BigDecimal) calculate("2", "-2", IValueMeta.TYPE_BIGNUMBER, CalculationType.ADD)));
assertEquals(
0,
new BigDecimal("30.0")
.compareTo(
(BigDecimal)
- calculate(
- "10",
- "20",
- IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.ADD)));
+ calculate("10", "20", IValueMeta.TYPE_BIGNUMBER, CalculationType.ADD)));
assertEquals(
0,
new BigDecimal("-50.0")
.compareTo(
(BigDecimal)
- calculate(
- "-100",
- "50",
- IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.ADD)));
+ calculate("-100", "50", IValueMeta.TYPE_BIGNUMBER, CalculationType.ADD)));
}
@Test
@@ -508,50 +470,29 @@ class CalculatorValueDataUtilTest {
// Test Hop number types
assertEquals(
Double.valueOf("6.0"),
- calculate(
- "1", "2", "3", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.ADD3));
+ calculate("1", "2", "3", IValueMeta.TYPE_NUMBER, CalculationType.ADD3));
assertEquals(
Double.valueOf("10.0"),
- calculate(
- "2", "-2", "10", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.ADD3));
+ calculate("2", "-2", "10", IValueMeta.TYPE_NUMBER, CalculationType.ADD3));
assertEquals(
Double.valueOf("27.0"),
- calculate(
- "10", "20", "-3", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.ADD3));
+ calculate("10", "20", "-3", IValueMeta.TYPE_NUMBER, CalculationType.ADD3));
assertEquals(
Double.valueOf("-55.0"),
- calculate(
- "-100",
- "50",
- "-5",
- IValueMeta.TYPE_NUMBER,
- CalculatorMetaFunction.CalculationType.ADD3));
+ calculate("-100", "50", "-5", IValueMeta.TYPE_NUMBER, CalculationType.ADD3));
// Test Hop Integer (Java Long) types
assertEquals(
- Long.valueOf("3"),
- calculate(
- "1", "1", "1", IValueMeta.TYPE_INTEGER, CalculatorMetaFunction.CalculationType.ADD3));
+ Long.valueOf("3"), calculate("1", "1", "1", IValueMeta.TYPE_INTEGER, CalculationType.ADD3));
assertEquals(
Long.valueOf("10"),
- calculate(
- "2", "-2", "10", IValueMeta.TYPE_INTEGER, CalculatorMetaFunction.CalculationType.ADD3));
+ calculate("2", "-2", "10", IValueMeta.TYPE_INTEGER, CalculationType.ADD3));
assertEquals(
Long.valueOf("27"),
- calculate(
- "10",
- "20",
- "-3",
- IValueMeta.TYPE_INTEGER,
- CalculatorMetaFunction.CalculationType.ADD3));
+ calculate("10", "20", "-3", IValueMeta.TYPE_INTEGER, CalculationType.ADD3));
assertEquals(
Long.valueOf("-55"),
- calculate(
- "-100",
- "50",
- "-5",
- IValueMeta.TYPE_INTEGER,
- CalculatorMetaFunction.CalculationType.ADD3));
+ calculate("-100", "50", "-5", IValueMeta.TYPE_INTEGER, CalculationType.ADD3));
// Test Hop big Number types
assertEquals(
@@ -559,45 +500,26 @@ class CalculatorValueDataUtilTest {
new BigDecimal("6.0")
.compareTo(
(BigDecimal)
- calculate(
- "1",
- "2",
- "3",
- IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.ADD3)));
+ calculate("1", "2", "3", IValueMeta.TYPE_BIGNUMBER, CalculationType.ADD3)));
assertEquals(
0,
new BigDecimal("10.0")
.compareTo(
(BigDecimal)
- calculate(
- "2",
- "-2",
- "10",
- IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.ADD3)));
+ calculate("2", "-2", "10", IValueMeta.TYPE_BIGNUMBER, CalculationType.ADD3)));
assertEquals(
0,
new BigDecimal("27.0")
.compareTo(
(BigDecimal)
- calculate(
- "10",
- "20",
- "-3",
- IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.ADD3)));
+ calculate("10", "20", "-3", IValueMeta.TYPE_BIGNUMBER, CalculationType.ADD3)));
assertEquals(
0,
new BigDecimal("-55.0")
.compareTo(
(BigDecimal)
calculate(
- "-100",
- "50",
- "-5",
- IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.ADD3)));
+ "-100", "50", "-5", IValueMeta.TYPE_BIGNUMBER, CalculationType.ADD3)));
}
@Test
@@ -606,22 +528,18 @@ class CalculatorValueDataUtilTest {
// Test Hop number types
assertEquals(
Double.valueOf("10.0"),
- calculate(
- "20", "10", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.SUBTRACT));
+ calculate("20", "10", IValueMeta.TYPE_NUMBER, CalculationType.SUBTRACT));
assertEquals(
Double.valueOf("-10.0"),
- calculate(
- "10", "20", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.SUBTRACT));
+ calculate("10", "20", IValueMeta.TYPE_NUMBER, CalculationType.SUBTRACT));
// Test Hop Integer (Java Long) types
assertEquals(
Long.valueOf("10"),
- calculate(
- "20", "10", IValueMeta.TYPE_INTEGER, CalculatorMetaFunction.CalculationType.SUBTRACT));
+ calculate("20", "10", IValueMeta.TYPE_INTEGER, CalculationType.SUBTRACT));
assertEquals(
Long.valueOf("-10"),
- calculate(
- "10", "20", IValueMeta.TYPE_INTEGER, CalculatorMetaFunction.CalculationType.SUBTRACT));
+ calculate("10", "20", IValueMeta.TYPE_INTEGER, CalculationType.SUBTRACT));
// Test Hop big Number types
assertEquals(
@@ -629,21 +547,13 @@ class CalculatorValueDataUtilTest {
new BigDecimal("10")
.compareTo(
(BigDecimal)
- calculate(
- "20",
- "10",
- IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.SUBTRACT)));
+ calculate("20", "10", IValueMeta.TYPE_BIGNUMBER, CalculationType.SUBTRACT)));
assertEquals(
0,
new BigDecimal("-10")
.compareTo(
(BigDecimal)
- calculate(
- "10",
- "20",
- IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.SUBTRACT)));
+ calculate("10", "20", IValueMeta.TYPE_BIGNUMBER, CalculationType.SUBTRACT)));
}
@Test
@@ -651,55 +561,39 @@ class CalculatorValueDataUtilTest {
// Test Hop number types
assertEquals(
- Double.valueOf("2.0"),
- calculate("2", "1", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.DIVIDE));
+ Double.valueOf("2.0"), calculate("2", "1", IValueMeta.TYPE_NUMBER, CalculationType.DIVIDE));
assertEquals(
- Double.valueOf("2.0"),
- calculate("4", "2", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.DIVIDE));
+ Double.valueOf("2.0"), calculate("4", "2", IValueMeta.TYPE_NUMBER, CalculationType.DIVIDE));
assertEquals(
Double.valueOf("0.5"),
- calculate(
- "10", "20", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.DIVIDE));
+ calculate("10", "20", IValueMeta.TYPE_NUMBER, CalculationType.DIVIDE));
assertEquals(
Double.valueOf("2.0"),
- calculate(
- "100", "50", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.DIVIDE));
+ calculate("100", "50", IValueMeta.TYPE_NUMBER, CalculationType.DIVIDE));
// Test Hop Integer (Java Long) types
assertEquals(
- Long.valueOf("2"),
- calculate(
- "2", "1", IValueMeta.TYPE_INTEGER, CalculatorMetaFunction.CalculationType.DIVIDE));
+ Long.valueOf("2"), calculate("2", "1", IValueMeta.TYPE_INTEGER, CalculationType.DIVIDE));
assertEquals(
- Long.valueOf("2"),
- calculate(
- "4", "2", IValueMeta.TYPE_INTEGER, CalculatorMetaFunction.CalculationType.DIVIDE));
+ Long.valueOf("2"), calculate("4", "2", IValueMeta.TYPE_INTEGER, CalculationType.DIVIDE));
assertEquals(
- Long.valueOf("0"),
- calculate(
- "10", "20", IValueMeta.TYPE_INTEGER, CalculatorMetaFunction.CalculationType.DIVIDE));
+ Long.valueOf("0"), calculate("10", "20", IValueMeta.TYPE_INTEGER, CalculationType.DIVIDE));
assertEquals(
- Long.valueOf("2"),
- calculate(
- "100", "50", IValueMeta.TYPE_INTEGER, CalculatorMetaFunction.CalculationType.DIVIDE));
+ Long.valueOf("2"), calculate("100", "50", IValueMeta.TYPE_INTEGER, CalculationType.DIVIDE));
// Test Hop big Number types
assertEquals(
BigDecimal.valueOf(Long.parseLong("2")),
- calculate(
- "2", "1", IValueMeta.TYPE_BIGNUMBER, CalculatorMetaFunction.CalculationType.DIVIDE));
+ calculate("2", "1", IValueMeta.TYPE_BIGNUMBER, CalculationType.DIVIDE));
assertEquals(
BigDecimal.valueOf(Long.parseLong("2")),
- calculate(
- "4", "2", IValueMeta.TYPE_BIGNUMBER, CalculatorMetaFunction.CalculationType.DIVIDE));
+ calculate("4", "2", IValueMeta.TYPE_BIGNUMBER, CalculationType.DIVIDE));
assertEquals(
BigDecimal.valueOf(Double.parseDouble("0.5")),
- calculate(
- "10", "20", IValueMeta.TYPE_BIGNUMBER, CalculatorMetaFunction.CalculationType.DIVIDE));
+ calculate("10", "20", IValueMeta.TYPE_BIGNUMBER, CalculationType.DIVIDE));
assertEquals(
BigDecimal.valueOf(Long.parseLong("2")),
- calculate(
- "100", "50", IValueMeta.TYPE_BIGNUMBER, CalculatorMetaFunction.CalculationType.DIVIDE));
+ calculate("100", "50", IValueMeta.TYPE_BIGNUMBER, CalculationType.DIVIDE));
}
@Test
@@ -767,71 +661,44 @@ class CalculatorValueDataUtilTest {
// Test Hop number types
assertEquals(
Double.valueOf("10.0"),
- calculate(
- "10", "100", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.PERCENT_1));
+ calculate("10", "100", IValueMeta.TYPE_NUMBER, CalculationType.PERCENT_1));
assertEquals(
Double.valueOf("100.0"),
- calculate(
- "2", "2", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.PERCENT_1));
+ calculate("2", "2", IValueMeta.TYPE_NUMBER, CalculationType.PERCENT_1));
assertEquals(
Double.valueOf("50.0"),
- calculate(
- "10", "20", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.PERCENT_1));
+ calculate("10", "20", IValueMeta.TYPE_NUMBER, CalculationType.PERCENT_1));
assertEquals(
Double.valueOf("200.0"),
- calculate(
- "100", "50", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.PERCENT_1));
+ calculate("100", "50", IValueMeta.TYPE_NUMBER, CalculationType.PERCENT_1));
// Test Hop Integer (Java Long) types
assertEquals(
Long.valueOf("10"),
- calculate(
- "10",
- "100",
- IValueMeta.TYPE_INTEGER,
- CalculatorMetaFunction.CalculationType.PERCENT_1));
+ calculate("10", "100", IValueMeta.TYPE_INTEGER, CalculationType.PERCENT_1));
assertEquals(
Long.valueOf("100"),
- calculate(
- "2", "2", IValueMeta.TYPE_INTEGER, CalculatorMetaFunction.CalculationType.PERCENT_1));
+ calculate("2", "2", IValueMeta.TYPE_INTEGER, CalculationType.PERCENT_1));
assertEquals(
Long.valueOf("50"),
- calculate(
- "10", "20", IValueMeta.TYPE_INTEGER, CalculatorMetaFunction.CalculationType.PERCENT_1));
+ calculate("10", "20", IValueMeta.TYPE_INTEGER, CalculationType.PERCENT_1));
assertEquals(
Long.valueOf("200"),
- calculate(
- "100",
- "50",
- IValueMeta.TYPE_INTEGER,
- CalculatorMetaFunction.CalculationType.PERCENT_1));
+ calculate("100", "50", IValueMeta.TYPE_INTEGER, CalculationType.PERCENT_1));
// Test Hop big Number types
assertEquals(
BigDecimal.valueOf(Long.parseLong("10")),
- calculate(
- "10",
- "100",
- IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.PERCENT_1));
+ calculate("10", "100", IValueMeta.TYPE_BIGNUMBER, CalculationType.PERCENT_1));
assertEquals(
BigDecimal.valueOf(Long.parseLong("100")),
- calculate(
- "2", "2", IValueMeta.TYPE_BIGNUMBER, CalculatorMetaFunction.CalculationType.PERCENT_1));
+ calculate("2", "2", IValueMeta.TYPE_BIGNUMBER, CalculationType.PERCENT_1));
assertEquals(
BigDecimal.valueOf(Long.parseLong("50")),
- calculate(
- "10",
- "20",
- IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.PERCENT_1));
+ calculate("10", "20", IValueMeta.TYPE_BIGNUMBER, CalculationType.PERCENT_1));
assertEquals(
BigDecimal.valueOf(Long.parseLong("200")),
- calculate(
- "100",
- "50",
- IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.PERCENT_1));
+ calculate("100", "50", IValueMeta.TYPE_BIGNUMBER, CalculationType.PERCENT_1));
}
@Test
@@ -840,65 +707,42 @@ class CalculatorValueDataUtilTest {
// Test Hop number types
assertEquals(
Double.valueOf("0.99"),
- calculate(
- "1", "1", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.PERCENT_2));
+ calculate("1", "1", IValueMeta.TYPE_NUMBER, CalculationType.PERCENT_2));
assertEquals(
Double.valueOf("1.96"),
- calculate(
- "2", "2", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.PERCENT_2));
+ calculate("2", "2", IValueMeta.TYPE_NUMBER, CalculationType.PERCENT_2));
assertEquals(
Double.valueOf("8.0"),
- calculate(
- "10", "20", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.PERCENT_2));
+ calculate("10", "20", IValueMeta.TYPE_NUMBER, CalculationType.PERCENT_2));
assertEquals(
Double.valueOf("50.0"),
- calculate(
- "100", "50", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.PERCENT_2));
+ calculate("100", "50", IValueMeta.TYPE_NUMBER, CalculationType.PERCENT_2));
// Test Hop Integer (Java Long) types
assertEquals(
- Long.valueOf("1"),
- calculate(
- "1", "1", IValueMeta.TYPE_INTEGER, CalculatorMetaFunction.CalculationType.PERCENT_2));
+ Long.valueOf("1"), calculate("1", "1", IValueMeta.TYPE_INTEGER, CalculationType.PERCENT_2));
assertEquals(
- Long.valueOf("2"),
- calculate(
- "2", "2", IValueMeta.TYPE_INTEGER, CalculatorMetaFunction.CalculationType.PERCENT_2));
+ Long.valueOf("2"), calculate("2", "2", IValueMeta.TYPE_INTEGER, CalculationType.PERCENT_2));
assertEquals(
Long.valueOf("8"),
- calculate(
- "10", "20", IValueMeta.TYPE_INTEGER, CalculatorMetaFunction.CalculationType.PERCENT_2));
+ calculate("10", "20", IValueMeta.TYPE_INTEGER, CalculationType.PERCENT_2));
assertEquals(
Long.valueOf("50"),
- calculate(
- "100",
- "50",
- IValueMeta.TYPE_INTEGER,
- CalculatorMetaFunction.CalculationType.PERCENT_2));
+ calculate("100", "50", IValueMeta.TYPE_INTEGER, CalculationType.PERCENT_2));
// Test Hop big Number types
assertEquals(
BigDecimal.valueOf(Double.parseDouble("0.99")),
- calculate(
- "1", "1", IValueMeta.TYPE_BIGNUMBER, CalculatorMetaFunction.CalculationType.PERCENT_2));
+ calculate("1", "1", IValueMeta.TYPE_BIGNUMBER, CalculationType.PERCENT_2));
assertEquals(
BigDecimal.valueOf(Double.parseDouble("1.96")),
- calculate(
- "2", "2", IValueMeta.TYPE_BIGNUMBER, CalculatorMetaFunction.CalculationType.PERCENT_2));
+ calculate("2", "2", IValueMeta.TYPE_BIGNUMBER, CalculationType.PERCENT_2));
assertEquals(
new BigDecimal("8.0"),
- calculate(
- "10",
- "20",
- IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.PERCENT_2));
+ calculate("10", "20", IValueMeta.TYPE_BIGNUMBER, CalculationType.PERCENT_2));
assertEquals(
new BigDecimal("50.0"),
- calculate(
- "100",
- "50",
- IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.PERCENT_2));
+ calculate("100", "50", IValueMeta.TYPE_BIGNUMBER, CalculationType.PERCENT_2));
}
@Test
@@ -907,41 +751,28 @@ class CalculatorValueDataUtilTest {
// Test Hop number types
assertEquals(
Double.valueOf("1.01"),
- calculate(
- "1", "1", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.PERCENT_3));
+ calculate("1", "1", IValueMeta.TYPE_NUMBER, CalculationType.PERCENT_3));
assertEquals(
Double.valueOf("2.04"),
- calculate(
- "2", "2", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.PERCENT_3));
+ calculate("2", "2", IValueMeta.TYPE_NUMBER, CalculationType.PERCENT_3));
assertEquals(
Double.valueOf("12.0"),
- calculate(
- "10", "20", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.PERCENT_3));
+ calculate("10", "20", IValueMeta.TYPE_NUMBER, CalculationType.PERCENT_3));
assertEquals(
Double.valueOf("150.0"),
- calculate(
- "100", "50", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.PERCENT_3));
+ calculate("100", "50", IValueMeta.TYPE_NUMBER, CalculationType.PERCENT_3));
// Test Hop Integer (Java Long) types
assertEquals(
- Long.valueOf("1"),
- calculate(
- "1", "1", IValueMeta.TYPE_INTEGER, CalculatorMetaFunction.CalculationType.PERCENT_3));
+ Long.valueOf("1"), calculate("1", "1", IValueMeta.TYPE_INTEGER, CalculationType.PERCENT_3));
assertEquals(
- Long.valueOf("2"),
- calculate(
- "2", "2", IValueMeta.TYPE_INTEGER, CalculatorMetaFunction.CalculationType.PERCENT_3));
+ Long.valueOf("2"), calculate("2", "2", IValueMeta.TYPE_INTEGER, CalculationType.PERCENT_3));
assertEquals(
Long.valueOf("12"),
- calculate(
- "10", "20", IValueMeta.TYPE_INTEGER, CalculatorMetaFunction.CalculationType.PERCENT_3));
+ calculate("10", "20", IValueMeta.TYPE_INTEGER, CalculationType.PERCENT_3));
assertEquals(
Long.valueOf("150"),
- calculate(
- "100",
- "50",
- IValueMeta.TYPE_INTEGER,
- CalculatorMetaFunction.CalculationType.PERCENT_3));
+ calculate("100", "50", IValueMeta.TYPE_INTEGER, CalculationType.PERCENT_3));
// Test Hop big Number types
assertEquals(
@@ -949,41 +780,25 @@ class CalculatorValueDataUtilTest {
new BigDecimal("1.01")
.compareTo(
(BigDecimal)
- calculate(
- "1",
- "1",
- IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.PERCENT_3)));
+ calculate("1", "1", IValueMeta.TYPE_BIGNUMBER, CalculationType.PERCENT_3)));
assertEquals(
0,
new BigDecimal("2.04")
.compareTo(
(BigDecimal)
- calculate(
- "2",
- "2",
- IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.PERCENT_3)));
+ calculate("2", "2", IValueMeta.TYPE_BIGNUMBER, CalculationType.PERCENT_3)));
assertEquals(
0,
new BigDecimal("12")
.compareTo(
(BigDecimal)
- calculate(
- "10",
- "20",
- IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.PERCENT_3)));
+ calculate("10", "20", IValueMeta.TYPE_BIGNUMBER, CalculationType.PERCENT_3)));
assertEquals(
0,
new BigDecimal("150")
.compareTo(
(BigDecimal)
- calculate(
- "100",
- "50",
- IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.PERCENT_3)));
+ calculate("100", "50", IValueMeta.TYPE_BIGNUMBER, CalculationType.PERCENT_3)));
}
@Test
@@ -992,70 +807,30 @@ class CalculatorValueDataUtilTest {
// Test Hop number types
assertEquals(
Double.valueOf("2.0"),
- calculate(
- "1",
- "1",
- "1",
- IValueMeta.TYPE_NUMBER,
- CalculatorMetaFunction.CalculationType.COMBINATION_1));
+ calculate("1", "1", "1", IValueMeta.TYPE_NUMBER, CalculationType.COMBINATION_1));
assertEquals(
Double.valueOf("22.0"),
- calculate(
- "2",
- "2",
- "10",
- IValueMeta.TYPE_NUMBER,
- CalculatorMetaFunction.CalculationType.COMBINATION_1));
+ calculate("2", "2", "10", IValueMeta.TYPE_NUMBER, CalculationType.COMBINATION_1));
assertEquals(
Double.valueOf("70.0"),
- calculate(
- "10",
- "20",
- "3",
- IValueMeta.TYPE_NUMBER,
- CalculatorMetaFunction.CalculationType.COMBINATION_1));
+ calculate("10", "20", "3", IValueMeta.TYPE_NUMBER, CalculationType.COMBINATION_1));
assertEquals(
Double.valueOf("350"),
- calculate(
- "100",
- "50",
- "5",
- IValueMeta.TYPE_NUMBER,
- CalculatorMetaFunction.CalculationType.COMBINATION_1));
+ calculate("100", "50", "5", IValueMeta.TYPE_NUMBER, CalculationType.COMBINATION_1));
// Test Hop Integer (Java Long) types
assertEquals(
Long.valueOf("2"),
- calculate(
- "1",
- "1",
- "1",
- IValueMeta.TYPE_INTEGER,
- CalculatorMetaFunction.CalculationType.COMBINATION_1));
+ calculate("1", "1", "1", IValueMeta.TYPE_INTEGER, CalculationType.COMBINATION_1));
assertEquals(
Long.valueOf("22"),
- calculate(
- "2",
- "2",
- "10",
- IValueMeta.TYPE_INTEGER,
- CalculatorMetaFunction.CalculationType.COMBINATION_1));
+ calculate("2", "2", "10", IValueMeta.TYPE_INTEGER, CalculationType.COMBINATION_1));
assertEquals(
Long.valueOf("70"),
- calculate(
- "10",
- "20",
- "3",
- IValueMeta.TYPE_INTEGER,
- CalculatorMetaFunction.CalculationType.COMBINATION_1));
+ calculate("10", "20", "3", IValueMeta.TYPE_INTEGER, CalculationType.COMBINATION_1));
assertEquals(
Long.valueOf("350"),
- calculate(
- "100",
- "50",
- "5",
- IValueMeta.TYPE_INTEGER,
- CalculatorMetaFunction.CalculationType.COMBINATION_1));
+ calculate("100", "50", "5", IValueMeta.TYPE_INTEGER, CalculationType.COMBINATION_1));
// Test Hop big Number types
assertEquals(
@@ -1064,22 +839,14 @@ class CalculatorValueDataUtilTest {
.compareTo(
(BigDecimal)
calculate(
- "1",
- "1",
- "1",
- IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.COMBINATION_1)));
+ "1", "1", "1", IValueMeta.TYPE_BIGNUMBER, CalculationType.COMBINATION_1)));
assertEquals(
0,
new BigDecimal("22.0")
.compareTo(
(BigDecimal)
calculate(
- "2",
- "2",
- "10",
- IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.COMBINATION_1)));
+ "2", "2", "10", IValueMeta.TYPE_BIGNUMBER, CalculationType.COMBINATION_1)));
assertEquals(
0,
new BigDecimal("70.0")
@@ -1090,7 +857,7 @@ class CalculatorValueDataUtilTest {
"20",
"3",
IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.COMBINATION_1)));
+ CalculationType.COMBINATION_1)));
assertEquals(
0,
new BigDecimal("350.0")
@@ -1101,7 +868,7 @@ class CalculatorValueDataUtilTest {
"50",
"5",
IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.COMBINATION_1)));
+ CalculationType.COMBINATION_1)));
}
@Test
@@ -1110,62 +877,30 @@ class CalculatorValueDataUtilTest {
// Test Hop number types
assertEquals(
Double.valueOf("1.4142135623730951"),
- calculate(
- "1",
- "1",
- IValueMeta.TYPE_NUMBER,
- CalculatorMetaFunction.CalculationType.COMBINATION_2));
+ calculate("1", "1", IValueMeta.TYPE_NUMBER, CalculationType.COMBINATION_2));
assertEquals(
Double.valueOf("2.8284271247461903"),
- calculate(
- "2",
- "2",
- IValueMeta.TYPE_NUMBER,
- CalculatorMetaFunction.CalculationType.COMBINATION_2));
+ calculate("2", "2", IValueMeta.TYPE_NUMBER, CalculationType.COMBINATION_2));
assertEquals(
Double.valueOf("22.360679774997898"),
- calculate(
- "10",
- "20",
- IValueMeta.TYPE_NUMBER,
- CalculatorMetaFunction.CalculationType.COMBINATION_2));
+ calculate("10", "20", IValueMeta.TYPE_NUMBER, CalculationType.COMBINATION_2));
assertEquals(
Double.valueOf("111.80339887498948"),
- calculate(
- "100",
- "50",
- IValueMeta.TYPE_NUMBER,
- CalculatorMetaFunction.CalculationType.COMBINATION_2));
+ calculate("100", "50", IValueMeta.TYPE_NUMBER, CalculationType.COMBINATION_2));
// Test Hop Integer (Java Long) types
assertEquals(
Long.valueOf("1"),
- calculate(
- "1",
- "1",
- IValueMeta.TYPE_INTEGER,
- CalculatorMetaFunction.CalculationType.COMBINATION_2));
+ calculate("1", "1", IValueMeta.TYPE_INTEGER, CalculationType.COMBINATION_2));
assertEquals(
Long.valueOf("2"),
- calculate(
- "2",
- "2",
- IValueMeta.TYPE_INTEGER,
- CalculatorMetaFunction.CalculationType.COMBINATION_2));
+ calculate("2", "2", IValueMeta.TYPE_INTEGER, CalculationType.COMBINATION_2));
assertEquals(
Long.valueOf("10"),
- calculate(
- "10",
- "20",
- IValueMeta.TYPE_INTEGER,
- CalculatorMetaFunction.CalculationType.COMBINATION_2));
+ calculate("10", "20", IValueMeta.TYPE_INTEGER, CalculationType.COMBINATION_2));
assertEquals(
Long.valueOf("100"),
- calculate(
- "100",
- "50",
- IValueMeta.TYPE_INTEGER,
- CalculatorMetaFunction.CalculationType.COMBINATION_2));
+ calculate("100", "50", IValueMeta.TYPE_INTEGER, CalculationType.COMBINATION_2));
// Test Hop big Number types
assertEquals(
@@ -1173,41 +908,27 @@ class CalculatorValueDataUtilTest {
new BigDecimal("1.4142135623730951")
.compareTo(
(BigDecimal)
- calculate(
- "1",
- "1",
- IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.COMBINATION_2)));
+ calculate("1", "1", IValueMeta.TYPE_BIGNUMBER, CalculationType.COMBINATION_2)));
assertEquals(
0,
new BigDecimal("2.8284271247461903")
.compareTo(
(BigDecimal)
- calculate(
- "2",
- "2",
- IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.COMBINATION_2)));
+ calculate("2", "2", IValueMeta.TYPE_BIGNUMBER, CalculationType.COMBINATION_2)));
assertEquals(
0,
new BigDecimal("22.360679774997898")
.compareTo(
(BigDecimal)
calculate(
- "10",
- "20",
- IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.COMBINATION_2)));
+ "10", "20", IValueMeta.TYPE_BIGNUMBER, CalculationType.COMBINATION_2)));
assertEquals(
0,
new BigDecimal("111.80339887498948")
.compareTo(
(BigDecimal)
calculate(
- "100",
- "50",
- IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.COMBINATION_2)));
+ "100", "50", IValueMeta.TYPE_BIGNUMBER, CalculationType.COMBINATION_2)));
}
@Test
@@ -1215,74 +936,57 @@ class CalculatorValueDataUtilTest {
// Test Hop number types
assertEquals(
- Double.valueOf("1.0"),
- calculate("1", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.ROUND_1));
+ Double.valueOf("1.0"), calculate("1", IValueMeta.TYPE_NUMBER, CalculationType.ROUND_1));
assertEquals(
Double.valueOf("103.0"),
- calculate(
- "103.01", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.ROUND_1));
+ calculate("103.01", IValueMeta.TYPE_NUMBER, CalculationType.ROUND_1));
assertEquals(
Double.valueOf("1235.0"),
- calculate(
- "1234.6", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.ROUND_1));
+ calculate("1234.6", IValueMeta.TYPE_NUMBER, CalculationType.ROUND_1));
// half
assertEquals(
Double.valueOf("1235.0"),
- calculate(
- "1234.5", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.ROUND_1));
+ calculate("1234.5", IValueMeta.TYPE_NUMBER, CalculationType.ROUND_1));
assertEquals(
Double.valueOf("1236.0"),
- calculate(
- "1235.5", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.ROUND_1));
+ calculate("1235.5", IValueMeta.TYPE_NUMBER, CalculationType.ROUND_1));
assertEquals(
Double.valueOf("-1234.0"),
- calculate(
- "-1234.5", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.ROUND_1));
+ calculate("-1234.5", IValueMeta.TYPE_NUMBER, CalculationType.ROUND_1));
assertEquals(
Double.valueOf("-1235.0"),
- calculate(
- "-1235.5", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.ROUND_1));
+ calculate("-1235.5", IValueMeta.TYPE_NUMBER, CalculationType.ROUND_1));
// Test Hop Integer (Java Long) types
assertEquals(
- Long.valueOf("1"),
- calculate("1", IValueMeta.TYPE_INTEGER, CalculatorMetaFunction.CalculationType.ROUND_1));
+ Long.valueOf("1"), calculate("1", IValueMeta.TYPE_INTEGER, CalculationType.ROUND_1));
assertEquals(
- Long.valueOf("2"),
- calculate("2", IValueMeta.TYPE_INTEGER, CalculatorMetaFunction.CalculationType.ROUND_1));
+ Long.valueOf("2"), calculate("2", IValueMeta.TYPE_INTEGER, CalculationType.ROUND_1));
assertEquals(
- Long.valueOf("-103"),
- calculate("-103", IValueMeta.TYPE_INTEGER, CalculatorMetaFunction.CalculationType.ROUND_1));
+ Long.valueOf("-103"), calculate("-103", IValueMeta.TYPE_INTEGER, CalculationType.ROUND_1));
// Test Hop big Number types
assertEquals(
- BigDecimal.ONE,
- calculate("1", IValueMeta.TYPE_BIGNUMBER, CalculatorMetaFunction.CalculationType.ROUND_1));
+ BigDecimal.ONE, calculate("1", IValueMeta.TYPE_BIGNUMBER, CalculationType.ROUND_1));
assertEquals(
BigDecimal.valueOf(Long.parseLong("103")),
- calculate(
- "103.01", IValueMeta.TYPE_BIGNUMBER, CalculatorMetaFunction.CalculationType.ROUND_1));
+ calculate("103.01", IValueMeta.TYPE_BIGNUMBER, CalculationType.ROUND_1));
assertEquals(
BigDecimal.valueOf(Long.parseLong("1235")),
- calculate(
- "1234.6", IValueMeta.TYPE_BIGNUMBER, CalculatorMetaFunction.CalculationType.ROUND_1));
+ calculate("1234.6", IValueMeta.TYPE_BIGNUMBER, CalculationType.ROUND_1));
// half
assertEquals(
BigDecimal.valueOf(Long.parseLong("1235")),
- calculate(
- "1234.5", IValueMeta.TYPE_BIGNUMBER, CalculatorMetaFunction.CalculationType.ROUND_1));
+ calculate("1234.5", IValueMeta.TYPE_BIGNUMBER, CalculationType.ROUND_1));
assertEquals(
BigDecimal.valueOf(Long.parseLong("1236")),
- calculate(
- "1235.5", IValueMeta.TYPE_BIGNUMBER, CalculatorMetaFunction.CalculationType.ROUND_1));
+ calculate("1235.5", IValueMeta.TYPE_BIGNUMBER, CalculationType.ROUND_1));
assertEquals(
BigDecimal.valueOf(Long.parseLong("-1234")),
- calculate(
- "-1234.5", IValueMeta.TYPE_BIGNUMBER, CalculatorMetaFunction.CalculationType.ROUND_1));
+ calculate("-1234.5", IValueMeta.TYPE_BIGNUMBER, CalculationType.ROUND_1));
assertEquals(
BigDecimal.valueOf(Long.parseLong("-1235")),
- calculate(
- "-1235.5", IValueMeta.TYPE_BIGNUMBER, CalculatorMetaFunction.CalculationType.ROUND_1));
+ calculate("-1235.5", IValueMeta.TYPE_BIGNUMBER, CalculationType.ROUND_1));
}
@Test
@@ -1291,164 +995,92 @@ class CalculatorValueDataUtilTest {
// Test Hop number types
assertEquals(
Double.valueOf("1.0"),
- calculate(
- "1", "1", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.ROUND_2));
+ calculate("1", "1", IValueMeta.TYPE_NUMBER, CalculationType.ROUND_2));
assertEquals(
Double.valueOf("2.1"),
- calculate(
- "2.06", "1", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.ROUND_2));
+ calculate("2.06", "1", IValueMeta.TYPE_NUMBER, CalculationType.ROUND_2));
assertEquals(
Double.valueOf("103.0"),
- calculate(
- "103.01", "1", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.ROUND_2));
+ calculate("103.01", "1", IValueMeta.TYPE_NUMBER, CalculationType.ROUND_2));
assertEquals(
Double.valueOf("12.35"),
- calculate(
- "12.346", "2", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.ROUND_2));
+ calculate("12.346", "2", IValueMeta.TYPE_NUMBER, CalculationType.ROUND_2));
// scale < 0
assertEquals(
Double.valueOf("10.0"),
- calculate(
- "12.0", "-1", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.ROUND_2));
+ calculate("12.0", "-1", IValueMeta.TYPE_NUMBER, CalculationType.ROUND_2));
// half
assertEquals(
Double.valueOf("12.35"),
- calculate(
- "12.345", "2", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.ROUND_2));
+ calculate("12.345", "2", IValueMeta.TYPE_NUMBER, CalculationType.ROUND_2));
assertEquals(
Double.valueOf("12.36"),
- calculate(
- "12.355", "2", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.ROUND_2));
+ calculate("12.355", "2", IValueMeta.TYPE_NUMBER, CalculationType.ROUND_2));
assertEquals(
Double.valueOf("-12.34"),
- calculate(
- "-12.345",
- "2",
- IValueMeta.TYPE_NUMBER,
- CalculatorMetaFunction.CalculationType.ROUND_2));
+ calculate("-12.345", "2", IValueMeta.TYPE_NUMBER, CalculationType.ROUND_2));
assertEquals(
Double.valueOf("-12.35"),
- calculate(
- "-12.355",
- "2",
- IValueMeta.TYPE_NUMBER,
- CalculatorMetaFunction.CalculationType.ROUND_2));
+ calculate("-12.355", "2", IValueMeta.TYPE_NUMBER, CalculationType.ROUND_2));
// Test Hop Integer (Java Long) types
assertEquals(
- Long.valueOf("1"),
- calculate(
- "1", "1", IValueMeta.TYPE_INTEGER, CalculatorMetaFunction.CalculationType.ROUND_2));
+ Long.valueOf("1"), calculate("1", "1", IValueMeta.TYPE_INTEGER, CalculationType.ROUND_2));
assertEquals(
- Long.valueOf("2"),
- calculate(
- "2", "2", IValueMeta.TYPE_INTEGER, CalculatorMetaFunction.CalculationType.ROUND_2));
+ Long.valueOf("2"), calculate("2", "2", IValueMeta.TYPE_INTEGER, CalculationType.ROUND_2));
assertEquals(
Long.valueOf("103"),
- calculate(
- "103", "3", IValueMeta.TYPE_INTEGER, CalculatorMetaFunction.CalculationType.ROUND_2));
+ calculate("103", "3", IValueMeta.TYPE_INTEGER, CalculationType.ROUND_2));
assertEquals(
- Long.valueOf("12"),
- calculate(
- "12", "4", IValueMeta.TYPE_INTEGER, CalculatorMetaFunction.CalculationType.ROUND_2));
+ Long.valueOf("12"), calculate("12", "4", IValueMeta.TYPE_INTEGER, CalculationType.ROUND_2));
// scale < 0
assertEquals(
Long.valueOf("100"),
- calculate(
- "120", "-2", IValueMeta.TYPE_INTEGER, CalculatorMetaFunction.CalculationType.ROUND_2));
+ calculate("120", "-2", IValueMeta.TYPE_INTEGER, CalculationType.ROUND_2));
// half
assertEquals(
Long.valueOf("12350"),
- calculate(
- "12345",
- "-1",
- IValueMeta.TYPE_INTEGER,
- CalculatorMetaFunction.CalculationType.ROUND_2));
+ calculate("12345", "-1", IValueMeta.TYPE_INTEGER, CalculationType.ROUND_2));
assertEquals(
Long.valueOf("12360"),
- calculate(
- "12355",
- "-1",
- IValueMeta.TYPE_INTEGER,
- CalculatorMetaFunction.CalculationType.ROUND_2));
+ calculate("12355", "-1", IValueMeta.TYPE_INTEGER, CalculationType.ROUND_2));
assertEquals(
Long.valueOf("-12340"),
- calculate(
- "-12345",
- "-1",
- IValueMeta.TYPE_INTEGER,
- CalculatorMetaFunction.CalculationType.ROUND_2));
+ calculate("-12345", "-1", IValueMeta.TYPE_INTEGER, CalculationType.ROUND_2));
assertEquals(
Long.valueOf("-12350"),
- calculate(
- "-12355",
- "-1",
- IValueMeta.TYPE_INTEGER,
- CalculatorMetaFunction.CalculationType.ROUND_2));
+ calculate("-12355", "-1", IValueMeta.TYPE_INTEGER, CalculationType.ROUND_2));
// Test Hop big Number types
assertEquals(
BigDecimal.valueOf(Double.parseDouble("1.0")),
- calculate(
- "1", "1", IValueMeta.TYPE_BIGNUMBER, CalculatorMetaFunction.CalculationType.ROUND_2));
+ calculate("1", "1", IValueMeta.TYPE_BIGNUMBER, CalculationType.ROUND_2));
assertEquals(
BigDecimal.valueOf(Double.parseDouble("2.1")),
- calculate(
- "2.06",
- "1",
- IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.ROUND_2));
+ calculate("2.06", "1", IValueMeta.TYPE_BIGNUMBER, CalculationType.ROUND_2));
assertEquals(
BigDecimal.valueOf(Double.parseDouble("103.0")),
- calculate(
- "103.01",
- "1",
- IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.ROUND_2));
+ calculate("103.01", "1", IValueMeta.TYPE_BIGNUMBER, CalculationType.ROUND_2));
assertEquals(
BigDecimal.valueOf(Double.parseDouble("12.35")),
- calculate(
- "12.346",
- "2",
- IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.ROUND_2));
+ calculate("12.346", "2", IValueMeta.TYPE_BIGNUMBER, CalculationType.ROUND_2));
// scale < 0
assertEquals(
BigDecimal.valueOf(Double.parseDouble("10.0")).setScale(-1),
- calculate(
- "12.0",
- "-1",
- IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.ROUND_2));
+ calculate("12.0", "-1", IValueMeta.TYPE_BIGNUMBER, CalculationType.ROUND_2));
// half
assertEquals(
BigDecimal.valueOf(Double.parseDouble("12.35")),
- calculate(
- "12.345",
- "2",
- IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.ROUND_2));
+ calculate("12.345", "2", IValueMeta.TYPE_BIGNUMBER, CalculationType.ROUND_2));
assertEquals(
BigDecimal.valueOf(Double.parseDouble("12.36")),
- calculate(
- "12.355",
- "2",
- IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.ROUND_2));
+ calculate("12.355", "2", IValueMeta.TYPE_BIGNUMBER, CalculationType.ROUND_2));
assertEquals(
BigDecimal.valueOf(Double.parseDouble("-12.34")),
- calculate(
- "-12.345",
- "2",
- IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.ROUND_2));
+ calculate("-12.345", "2", IValueMeta.TYPE_BIGNUMBER, CalculationType.ROUND_2));
assertEquals(
BigDecimal.valueOf(Double.parseDouble("-12.35")),
- calculate(
- "-12.355",
- "2",
- IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.ROUND_2));
+ calculate("-12.355", "2", IValueMeta.TYPE_BIGNUMBER, CalculationType.ROUND_2));
}
@Test
@@ -1456,38 +1088,26 @@ class CalculatorValueDataUtilTest {
// Test Hop number types
assertEquals(
- Double.valueOf("1.0"),
- calculate("1", "", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.NVL));
+ Double.valueOf("1.0"), calculate("1", "", IValueMeta.TYPE_NUMBER, CalculationType.NVL));
assertEquals(
- Double.valueOf("2.0"),
- calculate("", "2", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.NVL));
+ Double.valueOf("2.0"), calculate("", "2", IValueMeta.TYPE_NUMBER, CalculationType.NVL));
assertEquals(
- Double.valueOf("10.0"),
- calculate("10", "20", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.NVL));
+ Double.valueOf("10.0"), calculate("10", "20", IValueMeta.TYPE_NUMBER, CalculationType.NVL));
assertNull(calculate("", "", IValueMeta.TYPE_NUMBER, CalculationType.NVL));
// Test Hop string types
- assertEquals(
- "1",
- calculate("1", "", IValueMeta.TYPE_STRING, CalculatorMetaFunction.CalculationType.NVL));
- assertEquals(
- "2",
- calculate("", "2", IValueMeta.TYPE_STRING, CalculatorMetaFunction.CalculationType.NVL));
- assertEquals(
- "10",
- calculate("10", "20", IValueMeta.TYPE_STRING, CalculatorMetaFunction.CalculationType.NVL));
+ assertEquals("1", calculate("1", "", IValueMeta.TYPE_STRING, CalculationType.NVL));
+ assertEquals("2", calculate("", "2", IValueMeta.TYPE_STRING, CalculationType.NVL));
+ assertEquals("10", calculate("10", "20", IValueMeta.TYPE_STRING, CalculationType.NVL));
assertNull(calculate("", "", IValueMeta.TYPE_STRING, CalculationType.NVL));
// Test Hop Integer (Java Long) types
assertEquals(
- Long.valueOf("1"),
- calculate("1", "", IValueMeta.TYPE_INTEGER, CalculatorMetaFunction.CalculationType.NVL));
+ Long.valueOf("1"), calculate("1", "", IValueMeta.TYPE_INTEGER, CalculationType.NVL));
assertEquals(
- Long.valueOf("2"),
- calculate("", "2", IValueMeta.TYPE_INTEGER, CalculatorMetaFunction.CalculationType.NVL));
+ Long.valueOf("2"), calculate("", "2", IValueMeta.TYPE_INTEGER, CalculationType.NVL));
assertEquals(
- Long.valueOf("10"),
- calculate("10", "20", IValueMeta.TYPE_INTEGER, CalculatorMetaFunction.CalculationType.NVL));
+ Long.valueOf("10"), calculate("10", "20", IValueMeta.TYPE_INTEGER, CalculationType.NVL));
assertNull(calculate("", "", IValueMeta.TYPE_INTEGER, CalculationType.NVL));
// Test Hop big Number types
@@ -1495,46 +1115,24 @@ class CalculatorValueDataUtilTest {
0,
new BigDecimal("1")
.compareTo(
- (BigDecimal)
- calculate(
- "1",
- "",
- IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.NVL)));
+ (BigDecimal) calculate("1", "", IValueMeta.TYPE_BIGNUMBER, CalculationType.NVL)));
assertEquals(
0,
new BigDecimal("2")
.compareTo(
- (BigDecimal)
- calculate(
- "",
- "2",
- IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.NVL)));
+ (BigDecimal) calculate("", "2", IValueMeta.TYPE_BIGNUMBER, CalculationType.NVL)));
assertEquals(
0,
new BigDecimal("10")
.compareTo(
(BigDecimal)
- calculate(
- "10",
- "20",
- IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.NVL)));
+ calculate("10", "20", IValueMeta.TYPE_BIGNUMBER, CalculationType.NVL)));
assertNull(calculate("", "", IValueMeta.TYPE_BIGNUMBER, CalculationType.NVL));
// boolean
- assertEquals(
- true,
- calculate("true", "", IValueMeta.TYPE_BOOLEAN, CalculatorMetaFunction.CalculationType.NVL));
- assertEquals(
- false,
- calculate(
- "", "false", IValueMeta.TYPE_BOOLEAN, CalculatorMetaFunction.CalculationType.NVL));
- assertEquals(
- false,
- calculate(
- "false", "true", IValueMeta.TYPE_BOOLEAN, CalculatorMetaFunction.CalculationType.NVL));
+ assertEquals(true, calculate("true", "", IValueMeta.TYPE_BOOLEAN, CalculationType.NVL));
+ assertEquals(false, calculate("", "false", IValueMeta.TYPE_BOOLEAN, CalculationType.NVL));
+ assertEquals(false, calculate("false", "true", IValueMeta.TYPE_BOOLEAN, CalculationType.NVL));
assertNull(calculate("", "", IValueMeta.TYPE_BOOLEAN, CalculationType.NVL));
// Test Hop date
@@ -1543,21 +1141,14 @@ class CalculatorValueDataUtilTest {
try {
assertEquals(
simpleDateFormat.parse("2012-04-11"),
- calculate(
- "2012-04-11", "", IValueMeta.TYPE_DATE, CalculatorMetaFunction.CalculationType.NVL));
+ calculate("2012-04-11", "", IValueMeta.TYPE_DATE, CalculationType.NVL));
assertEquals(
simpleDateFormat.parse("2012-11-04"),
- calculate(
- "", "2012-11-04", IValueMeta.TYPE_DATE, CalculatorMetaFunction.CalculationType.NVL));
+ calculate("", "2012-11-04", IValueMeta.TYPE_DATE, CalculationType.NVL));
assertEquals(
simpleDateFormat.parse("1965-07-01"),
- calculate(
- "1965-07-01",
- "1967-04-11",
- IValueMeta.TYPE_DATE,
- CalculatorMetaFunction.CalculationType.NVL));
- assertNull(
- calculate("", "", IValueMeta.TYPE_DATE, CalculatorMetaFunction.CalculationType.NVL));
+ calculate("1965-07-01", "1967-04-11", IValueMeta.TYPE_DATE, CalculationType.NVL));
+ assertNull(calculate("", "", IValueMeta.TYPE_DATE, CalculationType.NVL));
} catch (ParseException pe) {
fail(pe.getMessage());
@@ -1568,28 +1159,18 @@ class CalculatorValueDataUtilTest {
try {
byte[] data = stringValueMeta.getBinary("101");
byte[] calculated =
- (byte[])
- calculate(
- "101", "", IValueMeta.TYPE_BINARY, CalculatorMetaFunction.CalculationType.NVL);
+ (byte[]) calculate("101", "", IValueMeta.TYPE_BINARY, CalculationType.NVL);
assertArrayEquals(data, calculated);
data = stringValueMeta.getBinary("011");
- calculated =
- (byte[])
- calculate(
- "", "011", IValueMeta.TYPE_BINARY, CalculatorMetaFunction.CalculationType.NVL);
+ calculated = (byte[]) calculate("", "011", IValueMeta.TYPE_BINARY, CalculationType.NVL);
assertArrayEquals(data, calculated);
data = stringValueMeta.getBinary("110");
- calculated =
- (byte[])
- calculate(
- "110", "011", IValueMeta.TYPE_BINARY, CalculatorMetaFunction.CalculationType.NVL);
+ calculated = (byte[]) calculate("110", "011", IValueMeta.TYPE_BINARY, CalculationType.NVL);
assertArrayEquals(data, calculated);
- calculated =
- (byte[])
- calculate("", "", IValueMeta.TYPE_BINARY, CalculatorMetaFunction.CalculationType.NVL);
+ calculated = (byte[]) calculate("", "", IValueMeta.TYPE_BINARY, CalculationType.NVL);
assertNull(calculated);
} catch (HopValueException kve) {
@@ -1599,37 +1180,20 @@ class CalculatorValueDataUtilTest {
@Test
void testRemainder() {
- assertNull(
- calculate(
- null, null, IValueMeta.TYPE_INTEGER, CalculatorMetaFunction.CalculationType.REMAINDER));
- assertNull(
- calculate(
- null, "3", IValueMeta.TYPE_INTEGER, CalculatorMetaFunction.CalculationType.REMAINDER));
- assertNull(
- calculate(
- "10", null, IValueMeta.TYPE_INTEGER, CalculatorMetaFunction.CalculationType.REMAINDER));
+ assertNull(calculate(null, null, IValueMeta.TYPE_INTEGER, CalculationType.REMAINDER));
+ assertNull(calculate(null, "3", IValueMeta.TYPE_INTEGER, CalculationType.REMAINDER));
+ assertNull(calculate("10", null, IValueMeta.TYPE_INTEGER, CalculationType.REMAINDER));
assertEquals(
Long.valueOf("1"),
- calculate(
- "10", "3", IValueMeta.TYPE_INTEGER, CalculatorMetaFunction.CalculationType.REMAINDER));
+ calculate("10", "3", IValueMeta.TYPE_INTEGER, CalculationType.REMAINDER));
assertEquals(
Long.valueOf("-1"),
- calculate(
- "-10", "3", IValueMeta.TYPE_INTEGER, CalculatorMetaFunction.CalculationType.REMAINDER));
+ calculate("-10", "3", IValueMeta.TYPE_INTEGER, CalculationType.REMAINDER));
Double comparisonDelta = Double.valueOf("0.0000000000001");
- assertNull(
- calculate(
- null, null, IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.REMAINDER));
- assertNull(
- calculate(
- null, "4.1", IValueMeta.TYPE_NUMBER, CalculatorMetaFunction.CalculationType.REMAINDER));
- assertNull(
- calculate(
- "17.8",
- null,
- IValueMeta.TYPE_NUMBER,
- CalculatorMetaFunction.CalculationType.REMAINDER));
+ assertNull(calculate(null, null, IValueMeta.TYPE_NUMBER, CalculationType.REMAINDER));
+ assertNull(calculate(null, "4.1", IValueMeta.TYPE_NUMBER, CalculationType.REMAINDER));
+ assertNull(calculate("17.8", null, IValueMeta.TYPE_NUMBER, CalculationType.REMAINDER));
assertEquals(
Double.parseDouble("1.4"),
(Double) calculate("17.8", "4.1", IValueMeta.TYPE_NUMBER, CalculationType.REMAINDER),
@@ -1644,46 +1208,19 @@ class CalculatorValueDataUtilTest {
(Double) calculate("-17.8", "-4.1", IValueMeta.TYPE_NUMBER, CalculationType.REMAINDER),
comparisonDelta);
- assertNull(
- calculate(
- null,
- null,
- IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.REMAINDER));
- assertNull(
- calculate(
- null,
- "16.12",
- IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.REMAINDER));
- assertNull(
- calculate(
- "-144.144",
- null,
- IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.REMAINDER));
+ assertNull(calculate(null, null, IValueMeta.TYPE_BIGNUMBER, CalculationType.REMAINDER));
+ assertNull(calculate(null, "16.12", IValueMeta.TYPE_BIGNUMBER, CalculationType.REMAINDER));
+ assertNull(calculate("-144.144", null, IValueMeta.TYPE_BIGNUMBER, CalculationType.REMAINDER));
assertEquals(
new BigDecimal("-15.184"),
- calculate(
- "-144.144",
- "16.12",
- IValueMeta.TYPE_BIGNUMBER,
- CalculatorMetaFunction.CalculationType.REMAINDER));
+ calculate("-144.144", "16.12", IValueMeta.TYPE_BIGNUMBER, CalculationType.REMAINDER));
assertEquals(
Double.valueOf("2.6000000000000005"),
- calculate(
- "12.5",
- "3.3",
- IValueMeta.TYPE_NUMBER,
- CalculatorMetaFunction.CalculationType.REMAINDER));
+ calculate("12.5", "3.3", IValueMeta.TYPE_NUMBER, CalculationType.REMAINDER));
assertEquals(
Double.valueOf("4.0"),
- calculate(
- "12.5",
- "4.25",
- IValueMeta.TYPE_NUMBER,
- CalculatorMetaFunction.CalculationType.REMAINDER));
+ calculate("12.5", "4.25", IValueMeta.TYPE_NUMBER, CalculationType.REMAINDER));
assertEquals(
Long.valueOf("1"),
calculate(
@@ -1693,7 +1230,7 @@ class CalculatorValueDataUtilTest {
IValueMeta.TYPE_INTEGER,
IValueMeta.TYPE_NUMBER,
IValueMeta.TYPE_NUMBER,
- CalculatorMetaFunction.CalculationType.REMAINDER));
+ CalculationType.REMAINDER));
}
@Test
@@ -1730,30 +1267,20 @@ class CalculatorValueDataUtilTest {
void testJaro() {
assertEquals(
Double.valueOf("0.0"),
- calculate(
- "abcd", "defg", IValueMeta.TYPE_STRING, CalculatorMetaFunction.CalculationType.JARO));
+ calculate("abcd", "defg", IValueMeta.TYPE_STRING, CalculationType.JARO));
assertEquals(
Double.valueOf("0.44166666666666665"),
- calculate(
- "elephant",
- "hippo",
- IValueMeta.TYPE_STRING,
- CalculatorMetaFunction.CalculationType.JARO));
+ calculate("elephant", "hippo", IValueMeta.TYPE_STRING, CalculationType.JARO));
assertEquals(
Double.valueOf("0.8666666666666667"),
- calculate(
- "hello", "hallo", IValueMeta.TYPE_STRING, CalculatorMetaFunction.CalculationType.JARO));
+ calculate("hello", "hallo", IValueMeta.TYPE_STRING, CalculationType.JARO));
}
@Test
void testJaroWinkler() {
assertEquals(
Double.valueOf("0.0"),
- calculate(
- "abcd",
- "defg",
- IValueMeta.TYPE_STRING,
- CalculatorMetaFunction.CalculationType.JARO_WINKLER));
+ calculate("abcd", "defg", IValueMeta.TYPE_STRING, CalculationType.JARO_WINKLER));
}
private Object calculate(
@@ -1847,44 +1374,43 @@ class CalculatorValueDataUtilTest {
Object dataB = createObject(stringDataB, valueMetaInterfaceTypeB, parameterValueMeta);
Object dataC = createObject(stringDataC, valueMetaInterfaceTypeC, parameterValueMeta);
- if (calculatorMetaFunction == CalculatorMetaFunction.CalculationType.ADD) {
+ if (calculatorMetaFunction == CalculationType.ADD) {
return ValueDataUtil.plus(valueMetaA, dataA, valueMetaB, dataB);
}
- if (calculatorMetaFunction == CalculatorMetaFunction.CalculationType.ADD3) {
+ if (calculatorMetaFunction == CalculationType.ADD3) {
return ValueDataUtil.plus3(valueMetaA, dataA, valueMetaB, dataB, valueMetaC, dataC);
}
- if (calculatorMetaFunction == CalculatorMetaFunction.CalculationType.SUBTRACT) {
+ if (calculatorMetaFunction == CalculationType.SUBTRACT) {
return ValueDataUtil.minus(valueMetaA, dataA, valueMetaB, dataB);
- } else if (calculatorMetaFunction == CalculatorMetaFunction.CalculationType.DIVIDE) {
+ } else if (calculatorMetaFunction == CalculationType.DIVIDE) {
return ValueDataUtil.divide(valueMetaA, dataA, valueMetaB, dataB);
- } else if (calculatorMetaFunction == CalculatorMetaFunction.CalculationType.PERCENT_1) {
+ } else if (calculatorMetaFunction == CalculationType.PERCENT_1) {
return ValueDataUtil.percent1(valueMetaA, dataA, valueMetaB, dataB);
- } else if (calculatorMetaFunction == CalculatorMetaFunction.CalculationType.PERCENT_2) {
+ } else if (calculatorMetaFunction == CalculationType.PERCENT_2) {
return ValueDataUtil.percent2(valueMetaA, dataA, valueMetaB, dataB);
- } else if (calculatorMetaFunction == CalculatorMetaFunction.CalculationType.PERCENT_3) {
+ } else if (calculatorMetaFunction == CalculationType.PERCENT_3) {
return ValueDataUtil.percent3(valueMetaA, dataA, valueMetaB, dataB);
- } else if (calculatorMetaFunction == CalculatorMetaFunction.CalculationType.COMBINATION_1) {
+ } else if (calculatorMetaFunction == CalculationType.COMBINATION_1) {
return ValueDataUtil.combination1(valueMetaA, dataA, valueMetaB, dataB, valueMetaC, dataC);
- } else if (calculatorMetaFunction == CalculatorMetaFunction.CalculationType.COMBINATION_2) {
+ } else if (calculatorMetaFunction == CalculationType.COMBINATION_2) {
return ValueDataUtil.combination2(valueMetaA, dataA, valueMetaB, dataB);
- } else if (calculatorMetaFunction == CalculatorMetaFunction.CalculationType.ROUND_1) {
+ } else if (calculatorMetaFunction == CalculationType.ROUND_1) {
return ValueDataUtil.round(valueMetaA, dataA);
- } else if (calculatorMetaFunction == CalculatorMetaFunction.CalculationType.ROUND_2) {
+ } else if (calculatorMetaFunction == CalculationType.ROUND_2) {
return ValueDataUtil.round(valueMetaA, dataA, valueMetaB, dataB);
- } else if (calculatorMetaFunction == CalculatorMetaFunction.CalculationType.NVL) {
+ } else if (calculatorMetaFunction == CalculationType.NVL) {
return ValueDataUtil.nvl(valueMetaA, dataA, valueMetaB, dataB);
- } else if (calculatorMetaFunction == CalculatorMetaFunction.CalculationType.DATE_DIFF) {
+ } else if (calculatorMetaFunction == CalculationType.DATE_DIFF) {
return ValueDataUtil.DateDiff(valueMetaA, dataA, valueMetaB, dataB, "");
- } else if (calculatorMetaFunction
- == CalculatorMetaFunction.CalculationType.DATE_WORKING_DIFF) {
+ } else if (calculatorMetaFunction == CalculationType.DATE_WORKING_DIFF) {
return ValueDataUtil.DateWorkingDiff(valueMetaA, dataA, valueMetaB, dataB);
- } else if (calculatorMetaFunction == CalculatorMetaFunction.CalculationType.REMAINDER) {
+ } else if (calculatorMetaFunction == CalculationType.REMAINDER) {
return ValueDataUtil.remainder(valueMetaA, dataA, valueMetaB, dataB);
- } else if (calculatorMetaFunction == CalculatorMetaFunction.CalculationType.JARO) {
+ } else if (calculatorMetaFunction == CalculationType.JARO) {
return ValueDataUtil.getJaro_Similitude(valueMetaA, dataA, valueMetaB, dataB);
- } else if (calculatorMetaFunction == CalculatorMetaFunction.CalculationType.JARO_WINKLER) {
+ } else if (calculatorMetaFunction == CalculationType.JARO_WINKLER) {
return ValueDataUtil.getJaroWinkler_Similitude(valueMetaA, dataA, valueMetaB, dataB);
- } else if (calculatorMetaFunction == CalculatorMetaFunction.CalculationType.MULTIPLY) {
+ } else if (calculatorMetaFunction == CalculationType.MULTIPLY) {
return ValueDataUtil.multiply(valueMetaA, dataA, valueMetaB, dataB);
} else {
fail("Invalid CalculatorMetaFunction specified.");