Class ViewTemplateNames

java.lang.Object
org.apache.juneau.rest.server.view.ViewTemplateNames

public final class ViewTemplateNames extends Object
Shared template-name checks applied by the view bridges before a name reaches a templating engine.

A template name is a path relative to the bridge's configured base path. Names that carry a URL scheme (or any :) or a backslash are never valid, and raw-served names must end in one of the extensions registered for the engine.

Since:
10.0.0
  • Method Details

    • isPlainName

      public static boolean isPlainName(String name)
      Returns true if the name is free of URL-scheme and path-separator tricks.
      Parameters:
      name - The template name. May be null.
      Returns:
      false if the name contains :, a backslash, or a control character.
    • hasAllowedExtension

      public static boolean hasAllowedExtension(String name, String... extensions)
      Returns true if the name ends with one of the allowed extensions.
      Parameters:
      name - The template name. Must not be null.
      extensions - The allowed extensions, including the leading dot (e.g. ".ftlh").
      Returns:
      true if the name has an allowed extension.
    • requirePlainName

      public static void requirePlainName(String name)
      Validates a template name for the typed-view path, throwing if it is not a plain name.
      Parameters:
      name - The template name.
      Throws:
      IllegalArgumentException - If the name is not plain.