Class StringFunctions.Format

java.lang.Object
org.apache.juneau.commons.svl.TypedFunction
org.apache.juneau.commons.svl.functions.StringFunctions.Format
All Implemented Interfaces:
VarFunction
Enclosing class:
StringFunctions

public static class StringFunctions.Format extends TypedFunction
#{format(pattern, args...)} — Java formatter-style formatting. Pattern uses Java Formatter syntax (e.g. %s, %d, %.2f). Variadic args; coerced per Java Formatter rules at invocation.
Example:

#{format("%s-%03d", ${prefix}, ${counter})}

All args are passed as raw String values; format specifiers like %d will convert numeric strings via Integer.parseInt(java.lang.String, int) / Long.parseLong(java.lang.String, int) as needed. %s accepts any string verbatim.

  • Constructor Details

  • Method Details

    • name

      public String name()
      Description copied from interface: VarFunction
      The function's invocation name as it appears between #{} and the opening parenthesis in the template. Must consist of ASCII letters, digits, and underscores; must begin with a letter.
      Returns:
      The invocation name. Never null or empty.
    • invoke

      public String invoke(String pattern, String[] args)