org.riotfamily.website.view
Class CommonMacroHelper
java.lang.Object
org.riotfamily.website.view.CommonMacroHelper
public class CommonMacroHelper
- extends Object
- Since:
- 6.5
- Author:
- Felix Gnass [fgnass at neteye dot de]
Method Summary |
String |
addCurrentTimestamp(String s)
|
String |
addParameter(String url,
String name,
String value)
|
String |
addRequestParameters(String url)
|
String |
addTimestamp(String s)
|
String |
baseName(String path)
|
String |
capture(String url)
|
String |
formatByteSize(long bytes)
|
String |
formatMillis(long millis)
|
String |
formatNumber(Number number,
String pattern,
String localeString)
|
String |
getAbsoluteUrl(String url)
|
Date |
getCurrentTime()
|
String |
getDateDelimiter()
|
String |
getDateFormat()
|
CommonMacroHelper.ExposeAsVariablesDirective |
getExposeAsVariablesDirective()
|
String |
getFileExtension(String filename,
Collection<String> validExtensions,
String defaultExtension)
|
String |
getHostName(String url)
|
Locale |
getLocale()
|
String |
getMessage(MessageSourceResolvable resolvable)
|
String |
getMessage(String code,
Collection<?> args)
|
String |
getMessageWithDefault(String code,
String defaultMessage,
Collection<?> args,
Locale locale)
|
String |
getOriginatingRequestUri()
|
String |
getPathWithinApplication()
|
Random |
getRandom()
|
String |
getSharedProperty(String key)
|
String |
getUrlForHandler(String handlerName,
Object attributes,
String prefix)
|
String |
hyphenate(String markup)
|
String |
hyphenatePlainText(String text)
|
String |
include(String url)
|
Object |
invokeStaticMethod(String method,
Collection<?> args)
|
boolean |
isCompressResources()
|
boolean |
isExternalUrl(String url)
|
|
partition(Collection<T> c,
String titleProperty)
Partitions the given collection by inspecting the specified property
of the contained items. |
String |
resolveAndEncodeLinks(String html)
|
String |
resolveAndEncodeUrl(String url)
|
String |
resolveUrl(String url)
|
int |
round(float number)
|
String |
setParameter(String url,
String name,
String value)
|
String |
setSharedProperty(String key,
String value)
|
List<?> |
shuffle(Collection<?> collection)
Shuffles the given collection |
|
split(List<T> items,
int groups)
Splits a list into a specified number of groups. |
String |
stripTagsAndWhitespaces(String s)
|
void |
tag(String className)
|
String |
toDelimitedString(Collection<?> c,
String delim)
|
String |
toTitleCase(String s)
|
String |
xmlEscapeDanglingAmps(String s)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CommonMacroHelper
public CommonMacroHelper(ApplicationContext ctx,
HttpServletRequest request,
HttpServletResponse response,
ResourceStamper stamper,
HandlerUrlResolver handlerUrlResolver,
RiotHyphenator hyphenator,
boolean compressResources)
getRandom
public Random getRandom()
isCompressResources
public boolean isCompressResources()
getCurrentTime
public Date getCurrentTime()
getLocale
public Locale getLocale()
getDateFormat
public String getDateFormat()
getDateDelimiter
public String getDateDelimiter()
getMessage
public String getMessage(String code,
Collection<?> args)
getMessageWithDefault
public String getMessageWithDefault(String code,
String defaultMessage,
Collection<?> args,
Locale locale)
getMessage
public String getMessage(MessageSourceResolvable resolvable)
getSharedProperty
public String getSharedProperty(String key)
setSharedProperty
public String setSharedProperty(String key,
String value)
resolveUrl
public String resolveUrl(String url)
resolveAndEncodeUrl
public String resolveAndEncodeUrl(String url)
resolveAndEncodeLinks
public String resolveAndEncodeLinks(String html)
getAbsoluteUrl
public String getAbsoluteUrl(String url)
getUrlForHandler
public String getUrlForHandler(String handlerName,
Object attributes,
String prefix)
getOriginatingRequestUri
public String getOriginatingRequestUri()
getPathWithinApplication
public String getPathWithinApplication()
setParameter
public String setParameter(String url,
String name,
String value)
addParameter
public String addParameter(String url,
String name,
String value)
addRequestParameters
public String addRequestParameters(String url)
isExternalUrl
public boolean isExternalUrl(String url)
getHostName
public String getHostName(String url)
include
public String include(String url)
throws ServletException,
IOException
- Throws:
ServletException
IOException
capture
public String capture(String url)
throws ServletException,
IOException
- Throws:
ServletException
IOException
addTimestamp
public String addTimestamp(String s)
addCurrentTimestamp
public String addCurrentTimestamp(String s)
partition
public <T> List<ObjectGroup<?,T>> partition(Collection<T> c,
String titleProperty)
- Partitions the given collection by inspecting the specified property
of the contained items.
- Parameters:
c
- The collection to partitiontitleProperty
- The property to use for grouping
- Returns:
- A list of
ObjectGroups
invokeStaticMethod
public Object invokeStaticMethod(String method,
Collection<?> args)
throws ClassNotFoundException,
NoSuchMethodException,
InvocationTargetException,
IllegalAccessException
- Throws:
ClassNotFoundException
NoSuchMethodException
InvocationTargetException
IllegalAccessException
toDelimitedString
public String toDelimitedString(Collection<?> c,
String delim)
shuffle
public List<?> shuffle(Collection<?> collection)
- Shuffles the given collection
- Parameters:
collection
- The collection to shuffle
- Returns:
- The shuffled collection
getFileExtension
public String getFileExtension(String filename,
Collection<String> validExtensions,
String defaultExtension)
baseName
public String baseName(String path)
formatByteSize
public String formatByteSize(long bytes)
formatMillis
public String formatMillis(long millis)
formatNumber
public String formatNumber(Number number,
String pattern,
String localeString)
round
public int round(float number)
hyphenatePlainText
public String hyphenatePlainText(String text)
hyphenate
public String hyphenate(String markup)
toTitleCase
public String toTitleCase(String s)
stripTagsAndWhitespaces
public String stripTagsAndWhitespaces(String s)
xmlEscapeDanglingAmps
public String xmlEscapeDanglingAmps(String s)
split
public <T> List<List<T>> split(List<T> items,
int groups)
- Splits a list into a specified number of groups. The items are
distributed evenly. Example:
1 | 4 | 7
2 | 5 | 8
3 | 6
- Parameters:
items
- The items to splitgroups
- The number of groups (NOT number of group-items)
- Returns:
- The splitted list
tag
public void tag(String className)
throws ClassNotFoundException
- Throws:
ClassNotFoundException
getExposeAsVariablesDirective
public CommonMacroHelper.ExposeAsVariablesDirective getExposeAsVariablesDirective()