public final class CmsJspElFunctions extends java.lang.Object
CmsJspContentAccessBean
Modifier and Type | Method and Description |
---|---|
static void |
addToList(java.util.List<java.lang.Object> list,
java.lang.Object value)
Extends the given list by adding the provided object.
|
static CmsObject |
convertCmsObject(java.lang.Object input)
Returns an OpenCms user context created from an Object.
|
static java.util.Date |
convertDate(java.lang.Object input)
Returns a Date created from an Object.
|
static java.util.List<java.lang.Object> |
convertList(java.util.List<java.lang.Object> input,
java.lang.String attributeName)
Returns a list of attribute values specified by the attribute name of the items of the given list.
|
static java.util.Locale |
convertLocale(java.lang.Object input)
Returns a Locale created from an Object.
|
static javax.servlet.ServletRequest |
convertRequest(java.lang.Object input)
Tries to convert the given input object into a request.
|
static CmsResource |
convertResource(CmsObject cms,
java.lang.Object input)
Returns a resource created from an Object.
|
static CmsUUID |
convertUUID(java.lang.Object input)
Returns a CmsUUID created from an Object.
|
static java.util.List<java.lang.Object> |
createList()
Returns a newly created, empty List object.
|
static CmsObject |
getCmsObject(java.lang.Object input)
Returns the current OpenCms user context from the given page context.
|
static java.lang.Integer |
getListSize(java.util.Collection<java.lang.Object> input)
Returns the size of the given list.
|
static java.lang.String |
getModuleParam(java.lang.String name,
java.lang.String key)
Returns a parameter value from the module parameters.
|
static java.lang.String |
getNavigationUri(java.lang.Object input)
Deprecated.
On a JSP use
${cms.requestContext.uri} instead. |
static java.lang.String |
getRequestLink(java.lang.String url)
Returns the link without parameters from a String that is formatted for a GET request.
|
static java.lang.String |
getRequestParam(java.lang.String url,
java.lang.String paramName)
Returns the value of a parameter from a String that is formatted for a GET request.
|
static CmsJspVfsAccessBean |
getVfsAccessBean(java.lang.Object input)
Returns a JSP / EL VFS access bean.
|
static boolean |
isSubSitemap(CmsResource resource)
Returns whether the given resource is a sub sitemap folder.
|
static java.lang.String |
jsonGetString(java.lang.Object maybeJsonString,
java.lang.Object key)
Parses the JSON String and returns the requested value.
|
static java.util.Map<java.lang.String,java.lang.String> |
jsonToMap(java.lang.String jsonString)
Converts a string (which is assumed to contain a JSON object whose values are strings only) to a map, for use in JSPs.
|
static java.lang.String |
lookup(java.lang.String key,
java.lang.String map)
Looks up the given key from the map that is passed as a String, and returns either the
element found or the empty String.
|
static java.lang.String |
lookup(java.lang.String key,
java.lang.String map,
java.lang.String defaultValue)
Looks up the given key from the map that is passed as a String, and returns either the
element found or the default value.
|
static java.lang.String |
repairHtml(java.lang.String input)
Repairs the given HTML input by adding potentially missing closing tags.
|
static java.lang.String |
stripHtml(java.lang.Object input)
Strips all HTML markup from the given input.
|
static java.lang.String |
trimToSize(java.lang.String input,
int length)
Returns a substring of the source, which is at most length characters long.
|
static boolean |
validateRegex(java.lang.String value,
java.lang.String regex)
Validates a value against a regular expression.
|
public static void addToList(java.util.List<java.lang.Object> list, java.lang.Object value)
list
- the list to extendvalue
- the value to add to the listpublic static CmsObject convertCmsObject(java.lang.Object input)
CmsObject
, it is casted and returned unchanged.
ServletRequest
, the OpenCms user context is read from the request context.
PageContext
, the OpenCms user context is read from the request of the page context.
input
- the input to create an OpenCms user context frompublic static java.util.Date convertDate(java.lang.Object input)
Date
already, if so it is casted and returned unchanged.
Long
, and if so the Date is created from the Long value.
input
- the Object to create a Date frompublic static java.util.List<java.lang.Object> convertList(java.util.List<java.lang.Object> input, java.lang.String attributeName)
input
- the list of objects to obtain the attribute values fromattributeName
- the name of the attribute to obtainpublic static java.util.Locale convertLocale(java.lang.Object input)
Locale
already, if so it is casted and returned.
input
- the Object to create a Locale frompublic static javax.servlet.ServletRequest convertRequest(java.lang.Object input)
This is only possible if the input object is already a request or if it is a page context.
If everything else, this method returns null
.
input
- the input object to convert to a requestnull
public static CmsResource convertResource(CmsObject cms, java.lang.Object input) throws CmsException
CmsResource
, it is casted to the resource and returned unchanged.
CmsUUID
, the given OpenCms context is used to read a resource with
this UUID from the VFS.
cms
- the current OpenCms user contextinput
- the input to create a resource fromCmsException
- in case of errors accessing the OpenCms VFS for reading the resourcepublic static CmsUUID convertUUID(java.lang.Object input)
input
- the Object to create a CmsUUID frompublic static java.util.List<java.lang.Object> createList()
There is no way to create an empty list using standard JSTL methods, hence this function.
public static CmsObject getCmsObject(java.lang.Object input)
input
- the input to create a CmsObject frompublic static java.lang.Integer getListSize(java.util.Collection<java.lang.Object> input)
input
- the list of objects to obtain the size frompublic static java.lang.String getModuleParam(java.lang.String name, java.lang.String key)
name
- the name of the modulekey
- the parameter to return the value fornull
if the parameter is not set@Deprecated public static java.lang.String getNavigationUri(java.lang.Object input)
${cms.requestContext.uri}
instead.
For OpenCms 10.5, this is the same as using ${cms.requestContext.uri}
on a JSP.
input
- the request convertible object to get the navigation URI frompublic static java.lang.String getRequestLink(java.lang.String url)
url
- the URL to remove the parameters frompublic static java.lang.String getRequestParam(java.lang.String url, java.lang.String paramName)
url
- the URL to get the parameter value fromparamName
- the request parameter namepublic static CmsJspVfsAccessBean getVfsAccessBean(java.lang.Object input)
input
- the Object to create a CmsObject frompublic static boolean isSubSitemap(CmsResource resource)
resource
- the resource to checktrue
if the given resource is a sub sitemap folderpublic static java.lang.String jsonGetString(java.lang.Object maybeJsonString, java.lang.Object key)
maybeJsonString
- the JSON stringkey
- the keypublic static java.util.Map<java.lang.String,java.lang.String> jsonToMap(java.lang.String jsonString)
If the input can't be interpreted as JSON, an empty map is returned.
jsonString
- the JSON stringpublic static java.lang.String lookup(java.lang.String key, java.lang.String map)
The map String must have the form "key1:value1|key2:value2"
etc.
key
- the key to look upmap
- the map represented as a Stringpublic static java.lang.String lookup(java.lang.String key, java.lang.String map, java.lang.String defaultValue)
The map String must have the form "key1:value1|key2:value2"
etc.
key
- the key to look upmap
- the map represented as a StringdefaultValue
- the default valuepublic static java.lang.String repairHtml(java.lang.String input)
input
- the HTML inputpublic static java.lang.String stripHtml(java.lang.Object input)
CmsJspContentAccessValueWrapper
, an optimized
method is used for the HTML stripping.
input
- the input to Strip from HTMLpublic static java.lang.String trimToSize(java.lang.String input, int length)
If a char is cut, " ..."
is appended to the result.
input
- the string to trimlength
- the maximum length of the string to be returnedCmsStringUtil.trimToSize(String, int, String)
public static boolean validateRegex(java.lang.String value, java.lang.String regex)
value
- the valueregex
- the regextrue
if the value satisfies the validation