Class StringFunctions.PathToken

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

public static class StringFunctions.PathToken extends TypedFunction
#{pathToken(s)} — normalize a user-supplied path token for safe interpolation into a path= template.

Strips leading and trailing /, plus a trailing /* (or * that sits immediately after a /). Multi-segment paths are preserved.

Edge cases:
  • "" → ""
  • "/" → ""
  • "/*" → ""
  • "jsp" → "jsp"
  • "/jsp" → "jsp"
  • "/jsp/" → "jsp"
  • "/jsp/*" → "jsp"
  • "jsp/*" → "jsp"
  • "/api/v1/*" → "api/v1"

Used in SVL-configurable mixin paths so users can supply "jsp", "/jsp", "/jsp/", "/jsp/*", or "jsp/*" and the template /#{pathToken(${juneau.jsp.path:jsp})}/* always resolves to a clean /jsp/*.

  • 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 s)