Package org.springframework.web.util
Class TagUtils
java.lang.Object
org.springframework.web.util.TagUtils
Utility class for tag library related code, exposing functionality
such as translating
Strings to web scopes.
pagewill be transformed toPageContext.PAGE_SCOPErequestwill be transformed toPageContext.REQUEST_SCOPEsessionwill be transformed toPageContext.SESSION_SCOPEapplicationwill be transformed toPageContext.APPLICATION_SCOPE
- Author:
- Alef Arendsen, Rob Harrop, Juergen Hoeller, Rick Evans
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidassertHasAncestorOfType(Tag tag, Class<?> ancestorTagClass, String tagName, String ancestorTagName) Determine whether the suppliedTaghas any ancestor tag of the supplied type, throwing anIllegalStateExceptionif not.static intDetermines the scope for a given inputString.static booleanhasAncestorOfType(Tag tag, Class<?> ancestorTagClass) Determine whether the suppliedTaghas any ancestor tag of the supplied type.
-
Field Details
-
SCOPE_PAGE
Constant identifying the page scope.- See Also:
-
SCOPE_REQUEST
Constant identifying the request scope.- See Also:
-
SCOPE_SESSION
Constant identifying the session scope.- See Also:
-
SCOPE_APPLICATION
Constant identifying the application scope.- See Also:
-
-
Constructor Details
-
TagUtils
public TagUtils()
-
-
Method Details
-
getScope
Determines the scope for a given inputString.If the
Stringdoes not match 'request', 'session', 'page' or 'application', the method will returnPageContext.PAGE_SCOPE.- Parameters:
scope- theStringto inspect- Returns:
- the scope found, or
PageContext.PAGE_SCOPEif no scope matched - Throws:
IllegalArgumentException- if the suppliedscopeisnull
-
hasAncestorOfType
Determine whether the suppliedTaghas any ancestor tag of the supplied type.- Parameters:
tag- the tag whose ancestors are to be checkedancestorTagClass- the ancestorClassbeing searched for- Returns:
trueif the suppliedTaghas any ancestor tag of the supplied type- Throws:
IllegalArgumentException- if either of the supplied arguments isnull; or if the suppliedancestorTagClassis not type-assignable to theTagclass
-
assertHasAncestorOfType
public static void assertHasAncestorOfType(Tag tag, Class<?> ancestorTagClass, String tagName, String ancestorTagName) Determine whether the suppliedTaghas any ancestor tag of the supplied type, throwing anIllegalStateExceptionif not.- Parameters:
tag- the tag whose ancestors are to be checkedancestorTagClass- the ancestorClassbeing searched fortagName- the name of thetag; for example 'option'ancestorTagName- the name of the ancestortag; for example 'select'- Throws:
IllegalStateException- if the suppliedtagdoes not have a tag of the suppliedparentTagClassas an ancestorIllegalArgumentException- if any of the supplied arguments isnull, or in the case of theString-typed arguments, is composed wholly of whitespace; or if the suppliedancestorTagClassis not type-assignable to theTagclass- See Also:
-