2

I've primarily relied on custom modules and functions I've created for specific needs. However, I've also been utilizing a number of inbuilt functions provided by Mule in DataWeave, such as the upper function, which returns the provided string in uppercase characters, with the syntax upper(text: String): String.

how does Mule implement this? Or where could I find the source code of this function?

3
  • The question is not clear. What are you trying to ask? Why do you need the source for the built in functions? Curiosity or you are trying to resolve an issue? Commented Mar 1, 2024 at 15:47
  • Aled its just curiosity to understand and get deep knowledge. how exactly behind the scene its happening Commented Mar 1, 2024 at 16:09
  • 1
    DataWeave is not open source at this time so its code is not publicly available. Commented Mar 1, 2024 at 16:48

1 Answer 1

3

For see implementations of the DataWeave functions in Anypoint studio, use [CTRL] button and LMB click at the function name.

picture of Set Payload where to CTRL and LMB

For example, upper:

/**
* Returns the provided string in uppercase characters.
*
* === Parameters
*
* [%header, cols="1,3"]
* |===
* | Name   | Description
* | `text` | The string to convert to uppercase.
* |===
*
* === Example
*
* This example converts lowercase characters to uppercase.
*
* ==== Source
*
* [source,DataWeave,linenums]
* ----
* %dw 2.0
* output application/json
* ---
* { "name" : upper("mulesoft") }
* ----
*
* ==== Output
*
* [source,JSON,linenums]
* ----
* { "name": "MULESOFT" }
* ----
**/
fun upper(text: String): String = native("system::StringUpperFunctionValue")

You can see native("system::StringUpperFunctionValue"). The function native means that the implementation is in jar or class files. Specifically, system::StringUpperFunctionValue StringUpperFunctionValue.class is located in the maven package groupId org.mule.weave artifactId runtime.

Sign up to request clarification or add additional context in comments.

4 Comments

Those classes are probably developed in Scala like the rest of DataWeave.
how to identify which class file it is for required function as there are multiple files and nothing named with function or StringUpperFunctionValue.please let me know or add a screen shot of that
@Михаил Сидоренко i found it inside the repo with path C:\Users\anurag\.m2\repository\org\mule\weave\core-modules\2.4.0-20220824.jar and when i unzipped this jar i found a class file file that i decomplied (runtime-2.4.0-20220824\org\mule\weave\v2\runtime\core\functions\stringops\StringUpperFunctionValue.class) which is developed in scala. to understand this more i have to explore. any way got the idea
@AnuragSharma Unfortunately, I don’t know the full terms of the DataWeave license, so just in case I refrained from describing how MuleSoft class files are structured and I’m afraid to call for any action. I found the files StringUpperFunctionValue.class and StringUpperFunctionValue$.class by scanning the entire .m2 folder.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.