Skip to content

Martini String Functions

The String class in Martini encompasses a comprehensive suite of functions for string manipulation, based on the robust Apache Commons StringUtils class. This functionality is integrated into Martini services and is also available for use in Groovy scripts.

Utilization

To utilize string functions in Martini, developers can either directly insert the desired function into their service code or leverage content assist for easier implementation. When using content assist, initiated by pressing the period (.) key, type the keyword "string." It's important to select functions that are specifically prefixed with "string" to ensure correct usage.

Groovy Examples

The String functions can be effectively utilized in a Groovy context. Below are some examples demonstrating their usage:

1
2
3
4
5
6
// Example of camel case string splitting
assert 'ExampleStringInCamelCase'.splitCamelCase().equals('Example String In Camel Case')

// Demonstration of string encryption and decryption
def exampleString = 'Confidential Data'
assert exampleString.encrypt().decrypt().equals(exampleString)