Class StringFunctions

java.lang.Object
cloud.opencode.base.expression.function.StringFunctions

public final class StringFunctions extends Object
String Functions 字符串函数

Provides built-in string manipulation functions for expressions.

为表达式提供内置的字符串操作函数。

Features | 主要功能:

  • Case conversion: upper, lower, capitalize - 大小写转换
  • Trimming: trim, ltrim, rtrim - 修剪
  • Search: contains, startswith, endswith, indexof - 搜索
  • Manipulation: replace, split, join, concat, pad, repeat, reverse - 操作
  • Validation: isempty, isblank, matches (regex) - 验证
  • Formatting: format, substring - 格式化

Usage Examples | 使用示例:

Object result = OpenExpression.eval("upper('hello')");  // "HELLO"
Object trimmed = OpenExpression.eval("trim('  hi  ')");  // "hi"
Object has = OpenExpression.eval("contains('hello', 'ell')");  // true

Security | 安全性:

  • Thread-safe: Yes, stateless utility class - 线程安全: 是,无状态工具类
  • Null-safe: Yes, null arguments return sensible defaults - 空值安全: 是,null参数返回合理默认值
  • ReDoS protection: regex operations have timeout and length limits - ReDoS防护: 正则操作有超时和长度限制
Since:
JDK 25, opencode-base-expression V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Method Details

    • getFunctions

      public static Map<String,Function> getFunctions()
      Get all string functions 获取所有字符串函数
      Returns:
      the function map | 函数映射