public abstract class TagUtils extends Object
Strings
to web scopes.
page
will be transformed to
PageContext.PAGE_SCOPE
request
will be transformed to
PageContext.REQUEST_SCOPE
session
will be transformed to
PageContext.SESSION_SCOPE
application
will be transformed to
PageContext.APPLICATION_SCOPE
Modifier and Type | Field and Description |
---|---|
static String |
SCOPE_APPLICATION
Constant identifying the application scope.
|
static String |
SCOPE_PAGE
Constant identifying the page scope.
|
static String |
SCOPE_REQUEST
Constant identifying the request scope.
|
static String |
SCOPE_SESSION
Constant identifying the session scope.
|
Constructor and Description |
---|
TagUtils() |
Modifier and Type | Method and Description |
---|---|
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. |
static int |
getScope(String scope)
Determines the scope for a given input
String . |
static boolean |
hasAncestorOfType(Tag tag,
Class<?> ancestorTagClass)
Determine whether the supplied
Tag has any ancestor tag
of the supplied type. |
public static final String SCOPE_PAGE
public static final String SCOPE_REQUEST
public static final String SCOPE_SESSION
public static final String SCOPE_APPLICATION
public static int getScope(String scope)
String
.
If the String
does not match 'request', 'session',
'page' or 'application', the method will return PageContext.PAGE_SCOPE
.
scope
- the String
to inspectPageContext.PAGE_SCOPE
if no scope matchedIllegalArgumentException
- if the supplied scope
is null
public static boolean hasAncestorOfType(Tag tag, Class<?> ancestorTagClass)
Tag
has any ancestor tag
of the supplied type.tag
- the tag whose ancestors are to be checkedancestorTagClass
- the ancestor Class
being searched fortrue
if the supplied Tag
has any ancestor tag
of the supplied typeIllegalArgumentException
- if either of the supplied arguments is null
;
or if the supplied ancestorTagClass
is not type-assignable to
the Tag
classpublic static void assertHasAncestorOfType(Tag tag, Class<?> ancestorTagClass, String tagName, String ancestorTagName)
Tag
has any ancestor tag
of the supplied type, throwing an IllegalStateException
if not.tag
- the tag whose ancestors are to be checkedancestorTagClass
- the ancestor Class
being searched fortagName
- the name of the tag
; for example 'option
'ancestorTagName
- the name of the ancestor tag
; for example 'select
'IllegalStateException
- if the supplied tag
does not
have a tag of the supplied parentTagClass
as an ancestorIllegalArgumentException
- 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
classhasAncestorOfType(javax.servlet.jsp.tagext.Tag, Class)