This is an automated email from the ASF dual-hosted git repository.
hansva pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hop.git
The following commit(s) were added to refs/heads/master by this push:
new 0da0b1da44 (DOC) userdefinedjavaexpression fixes
new 8514fe51ee Merge pull request #1579 from VladimirAlexiev/patch-12
0da0b1da44 is described below
commit 0da0b1da44762075f914e5516f16f727f13c2a01
Author: Vladimir Alexiev <[email protected]>
AuthorDate: Wed Jul 6 12:50:47 2022 +0300
(DOC) userdefinedjavaexpression fixes
---
.../transforms/userdefinedjavaexpression.adoc | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git
a/docs/hop-user-manual/modules/ROOT/pages/pipeline/transforms/userdefinedjavaexpression.adoc
b/docs/hop-user-manual/modules/ROOT/pages/pipeline/transforms/userdefinedjavaexpression.adoc
index f8d29acb52..3c7b168142 100644
---
a/docs/hop-user-manual/modules/ROOT/pages/pipeline/transforms/userdefinedjavaexpression.adoc
+++
b/docs/hop-user-manual/modules/ROOT/pages/pipeline/transforms/userdefinedjavaexpression.adoc
@@ -118,7 +118,8 @@ even with OR and AND and other operators and functions
**Using Constants**
-If you use a constant, you may need to define the right type in some
expressions otherwise it could throw:
+If you use a constant, you may need to define the right type in some
expressions otherwise it could throw an error.
+Eg if you use "0" that is "int" but Apache Hop "Integer" is "java.lang.Long",
so you'll get an exception:
Incompatible expression types "int" and "java.lang.Long"
@@ -129,17 +130,17 @@ To solve this, use:
test == null ? new Long(0) : test
----
-In this case, it checks if test is null and replaces with zero.
-If it is not null, it will return test.
+The above expression checks if "test" is null and replaces it with a zero Long.
+Otherwise, it return "test" unchanged.
**Cut a string from end and test for null and minimal length**
-Imagine you have input strings with
+Imagine you have input strings "location" like
Orlando FL
New York NY
-and you want to separate the state and city, you could use the following
expressions:
+and you want to separate the state and city. You could use the following
expressions:
For state (get the last 2 characters):
@@ -155,12 +156,12 @@ For city (get the beginning without the last 2 characters
and trim):
location != null && location.length()>2 ? location.substring(0,
location.length()-2).trim() : location
----
-**Functionality of a LIKE operator (contains string) and replacing values**
+**Functionality of a LIKE operator (contains string)**
The following example returns 1 when abc is within the source string,
otherwise 2. It returns also 2 when the source string is null.
-The return values could be of value type Integer.
+If you prefer the return values to be of value type Integer, use "new Long(1)"
and "new Long(2)".
[source,java]
----
-samplestr !=null && samplestr.indexOf("abc")>-1 ? 1 : 2
-----
\ No newline at end of file
+samplestr != null && samplestr.indexOf("abc")>-1 ? 1 : 2
+----