Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.ecm.platform.ui.web.tag.fn
Class Functions

java.lang.Object
  extended by org.nuxeo.ecm.platform.ui.web.tag.fn.Functions

public final class Functions
extends Object

Util functions.

Author:
Anahide Tchertchian, Thierry Martins

Nested Class Summary
static class Functions.BytePrefix
           
 
Field Summary
static String BIG_FILE_SIZE_LIMIT_PROPERTY
           
static long DEFAULT_BIG_FILE_SIZE_LIMIT
           
static String I18N_DURATION_PREFIX
           
 
Method Summary
static String basicDateAndTimeFormater()
           
static String basicDateFormater()
           
static String concat(String s1, String s2)
           
static String dateAndTimeFormater(String formatLength)
           
static String dateFormater(String formatLength)
           
static String formatDate(Date date, String format)
           
static String formatDateUsingBasicFormatter(Date date)
           
static long getBigFileSizeLimit()
           
static long getFileSize(String value)
           
static long getValueFromMultiplier(String m)
          Transform the parameter in entry according to these unit systems: SI prefixes: k/M/G for kilo, mega, giga IEC prefixes: Ki/Mi/Gi for kibi, mebi, gibi
static String groupDisplayName(String name, String label)
          Choose between label or name the best string to display a group
static String groupFullName(String groupId)
          Returns the full name of a group from his id
static boolean hasMessages(String clientId)
           
static String htmlEscape(String data)
           
static String indentString(Integer level, String text)
           
static Integer integerDivision(Integer x, Integer y)
           
static String javaScriptEscape(String data)
          Escapes a given string to be used in a JavaScript function (escaping single quote characters for instance).
static String join(String[] list, String separator)
           
static String joinArrayWithFinalDelimiter(Object[] collection, String separator, String finalSeparator)
           
static String joinCollection(Collection<Object> collection, String separator)
           
static String joinCollectionWithFinalDelimiter(Collection<Object> collection, String separator, String finalSeparator)
          Can be used in order to produce something like that "Julien, Alain , Thierry et Marc-Aurele" where ' , ' and ' et ' is the final one.
static String principalFullName(NuxeoPrincipal principal)
           
static String printFileSize(String size)
           
static String printFormatedFileSize(String sizeS, String format, Boolean isShort)
           
static String printFormattedDuration(Object durationObj)
           
static String printFormattedDuration(Object durationObj, Map<String,String> i18nLabels)
          Format the duration of a media in a string of two consecutive units to best express the duration of a media, e.g.: 1 hr 42 min 2 min 25 sec 10 sec 0 sec
static Object test(Boolean test, Object onSuccess, Object onFailure)
           
static String translate(String messageId, Object... params)
           
static String userDisplayName(String id, String first, String last)
           
static String userDisplayNameAndEmail(String id, String first, String last, String email)
          Return, from the id, the id its-self if neither last name nor name are found or the full name plus the email if this one exists
static String userFullName(String username)
          Returns the full name of a user, or its username if user if not found.
static boolean userIsMemberOf(String groupName)
           
static String userUrl(String patternName, String username, String viewId, boolean newConversation)
           
static String userUrl(String patternName, String username, String viewId, boolean newConversation, HttpServletRequest req)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

I18N_DURATION_PREFIX

public static final String I18N_DURATION_PREFIX
See Also:
Constant Field Values

BIG_FILE_SIZE_LIMIT_PROPERTY

public static final String BIG_FILE_SIZE_LIMIT_PROPERTY
See Also:
Constant Field Values

DEFAULT_BIG_FILE_SIZE_LIMIT

public static final long DEFAULT_BIG_FILE_SIZE_LIMIT
See Also:
Constant Field Values
Method Detail

test

public static Object test(Boolean test,
                          Object onSuccess,
                          Object onFailure)

join

public static String join(String[] list,
                          String separator)

joinCollection

public static String joinCollection(Collection<Object> collection,
                                    String separator)

htmlEscape

public static String htmlEscape(String data)

javaScriptEscape

public static String javaScriptEscape(String data)
Escapes a given string to be used in a JavaScript function (escaping single quote characters for instance).

Since:
5.4.2

joinCollectionWithFinalDelimiter

public static String joinCollectionWithFinalDelimiter(Collection<Object> collection,
                                                      String separator,
                                                      String finalSeparator)
Can be used in order to produce something like that "Julien, Alain , Thierry et Marc-Aurele" where ' , ' and ' et ' is the final one.


joinArrayWithFinalDelimiter

public static String joinArrayWithFinalDelimiter(Object[] collection,
                                                 String separator,
                                                 String finalSeparator)

formatDateUsingBasicFormatter

public static String formatDateUsingBasicFormatter(Date date)

formatDate

public static String formatDate(Date date,
                                String format)

concat

public static String concat(String s1,
                            String s2)

indentString

public static String indentString(Integer level,
                                  String text)

userIsMemberOf

public static boolean userIsMemberOf(String groupName)

userFullName

public static String userFullName(String username)
Returns the full name of a user, or its username if user if not found.

Since 5.4.3, returns null if given username is null (instead of returning the current user full name).


groupFullName

public static String groupFullName(String groupId)
Returns the full name of a group from his id

Parameters:
groupId - the group id
Returns:
the group full name
Since:
5.4.3
See Also:
groupDisplayName(String, String)

principalFullName

public static String principalFullName(NuxeoPrincipal principal)

userDisplayName

public static String userDisplayName(String id,
                                     String first,
                                     String last)

userDisplayNameAndEmail

public static String userDisplayNameAndEmail(String id,
                                             String first,
                                             String last,
                                             String email)
Return, from the id, the id its-self if neither last name nor name are found or the full name plus the email if this one exists

Parameters:
id - id of the user
first - first name of the user
last - last name of the user
email - email of the user
Returns:
id or full name with email if exists
Since:
5.4.3

groupDisplayName

public static String groupDisplayName(String name,
                                      String label)
Choose between label or name the best string to display a group

Parameters:
name - the group name
label - the group name
Returns:
label if not empty or null, otherwise group name
Since:
5.4.3

dateFormater

public static String dateFormater(String formatLength)

basicDateFormater

public static String basicDateFormater()

dateAndTimeFormater

public static String dateAndTimeFormater(String formatLength)

basicDateAndTimeFormater

public static String basicDateAndTimeFormater()

printFileSize

public static String printFileSize(String size)

printFormatedFileSize

public static String printFormatedFileSize(String sizeS,
                                           String format,
                                           Boolean isShort)

integerDivision

public static Integer integerDivision(Integer x,
                                      Integer y)

printFormattedDuration

public static String printFormattedDuration(Object durationObj,
                                            Map<String,String> i18nLabels)
Format the duration of a media in a string of two consecutive units to best express the duration of a media, e.g.:

Parameters:
durationObj - a Float, Double, Integer, Long or String instance representing a duration in seconds
i18nLabels - a map to translate the days, hours, minutes and seconds labels
Returns:
the formatted string

printFormattedDuration

public static String printFormattedDuration(Object durationObj)

translate

public static final String translate(String messageId,
                                     Object... params)

getBigFileSizeLimit

public static long getBigFileSizeLimit()
Returns:
the big file size limit defined with the property org.nuxeo.big.file.size.limit

getFileSize

public static long getFileSize(String value)

getValueFromMultiplier

public static long getValueFromMultiplier(String m)
Transform the parameter in entry according to these unit systems:

Parameters:
m - : binary prefix multiplier
Returns:
the value of the multiplier as a long

hasMessages

public static boolean hasMessages(String clientId)

userUrl

public static String userUrl(String patternName,
                             String username,
                             String viewId,
                             boolean newConversation)

userUrl

public static String userUrl(String patternName,
                             String username,
                             String viewId,
                             boolean newConversation,
                             HttpServletRequest req)

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.