Class TagUtils

java.lang.Object
org.springframework.web.util.TagUtils

public abstract class TagUtils extends Object
Utility class for tag library related code, exposing functionality such as translating Strings to web scopes.

Author:
Alef Arendsen, Rob Harrop, Juergen Hoeller, Rick Evans
  • Field Details

  • Constructor Details

    • TagUtils

      public TagUtils()
  • Method Details

    • getScope

      public static int getScope(String scope)
      Determines the scope for a given input String.

      If the String does not match 'request', 'session', 'page' or 'application', the method will return PageContext.PAGE_SCOPE.

      Parameters:
      scope - the String to inspect
      Returns:
      the scope found, or PageContext.PAGE_SCOPE if no scope matched
      Throws:
      IllegalArgumentException - if the supplied scope is null
    • hasAncestorOfType

      public static boolean hasAncestorOfType(Tag tag, Class<?> ancestorTagClass)
      Determine whether the supplied Tag has any ancestor tag of the supplied type.
      Parameters:
      tag - the tag whose ancestors are to be checked
      ancestorTagClass - the ancestor Class being searched for
      Returns:
      true if the supplied Tag has any ancestor tag of the supplied type
      Throws:
      IllegalArgumentException - if either of the supplied arguments is null; or if the supplied ancestorTagClass is not type-assignable to the Tag class
    • assertHasAncestorOfType

      public static void assertHasAncestorOfType(Tag tag, Class<?> ancestorTagClass, String tagName, String ancestorTagName)
      Determine whether the supplied Tag has any ancestor tag of the supplied type, throwing an IllegalStateException if not.
      Parameters:
      tag - the tag whose ancestors are to be checked
      ancestorTagClass - the ancestor Class being searched for
      tagName - the name of the tag; for example 'option'
      ancestorTagName - the name of the ancestor tag; for example 'select'
      Throws:
      IllegalStateException - if the supplied tag does not have a tag of the supplied parentTagClass as an ancestor
      IllegalArgumentException - if any of the supplied arguments is null, or in the case of the String-typed arguments, is composed wholly of whitespace; or if the supplied ancestorTagClass is not type-assignable to the Tag class
      See Also: