org.glassfish.admingui.common.util
Class GuiUtil

java.lang.Object
  extended by org.glassfish.admingui.common.util.GuiUtil

public class GuiUtil
extends java.lang.Object

Author:
anilam

Field Summary
static java.lang.String COMMON_RESOURCE_NAME
           
static java.lang.String I18N_RESOURCE_BUNDLE
           
static java.lang.String LOGGER_NAME
           
static java.lang.String RESOURCE_NAME
           
 
Constructor Summary
GuiUtil()
          Creates a new instance of GuiUtil
 
Method Summary
static java.lang.String arrayToString(java.lang.String[] str, java.lang.String delimiter)
          This method concatenates the delimiter char to the end of each string in the array, and returns a single string with the concatenated string.
static
<T> T[]
asArray(java.lang.Object o)
           
static java.lang.String checkEmpty(java.lang.String test)
           
static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> convertArrayToListOfMap(java.lang.Object[] values, java.lang.String key)
           
static java.util.List<java.lang.String> convertListOfStrings(java.util.List l)
           
static java.util.List<java.util.Map<java.lang.String,java.lang.String>> convertMapToListOfMap(java.util.Map<java.lang.String,java.lang.String> values)
           
static java.lang.String encode(java.lang.String value, java.lang.String delim, java.lang.String type)
           This method encodes the given String with the specified type.
static java.lang.String genId(java.lang.String uid)
           This method generates an ID that is safe for JSF for the given String.
static java.lang.Boolean getBooleanValue(java.util.Map pMap, java.lang.String name)
           
static java.util.ResourceBundle getBundle(java.lang.String resourceName)
           
static java.lang.Throwable[] getCauses(java.lang.Throwable start)
          Get the chain of exceptions via getCause().
static java.lang.String getCommonMessage(java.lang.String key)
           
static java.lang.String getCommonMessage(java.lang.String key, java.lang.Object[] args)
           
static org.jvnet.hk2.component.Habitat getHabitat()
           
static java.util.Locale getLocale()
           
static java.util.logging.Logger getLogger()
           
static java.lang.Object getMapValue(java.util.Map map, java.lang.String mapKeys)
           
static java.lang.String getMessage(java.util.ResourceBundle bundle, java.lang.String key)
           
static java.lang.String getMessage(java.lang.String key)
           
static java.lang.String getMessage(java.lang.String key, java.lang.Object[] args)
           
static java.lang.String getMessage(java.lang.String resourceName, java.lang.String key)
           
static java.lang.String getMessage(java.lang.String resourceName, java.lang.String key, java.lang.Object[] args)
           
static java.lang.Throwable getRootCause(java.lang.Throwable e)
          Get the original troublemaker.
static java.lang.Object getSessionValue(java.lang.String key)
           
static long getTimeStamp()
           
static void guiLog(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
           
static void handleError(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx, java.lang.String detail)
           
static void handleException(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx, java.lang.Throwable ex)
           
static void initSessionAttributes()
           
static boolean isEmpty(java.lang.String str)
           
static boolean isSelected(java.lang.String name, java.util.List<java.util.Map> selectedList)
           
static java.lang.String listToString(java.util.List<java.lang.String> list, java.lang.String delimiter)
           
static java.lang.String notNull(java.lang.String test)
           
static java.util.List parseStringList(java.lang.String line, java.lang.String sep)
          Parses a string containing substrings separated from each other by the specified set of separator characters and returns a list of strings.
static void prepareAlert(java.lang.String type, java.lang.String summary, java.lang.String detail)
           
static void prepareException(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx, java.lang.Throwable ex)
           
static void prepareSuccessful(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)
           
static java.lang.String removeToken(java.lang.String line, java.lang.String sep, java.lang.String remove)
           
static void setSessionValue(java.lang.String key, java.lang.Object value)
           
static void setTimeStamp()
           
static java.lang.String[] stringToArray(java.lang.String str, java.lang.String delimiter)
          This method converts a string into stringarray, uses the delimeter as the separator character.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

I18N_RESOURCE_BUNDLE

public static final java.lang.String I18N_RESOURCE_BUNDLE
See Also:
Constant Field Values

RESOURCE_NAME

public static final java.lang.String RESOURCE_NAME
See Also:
Constant Field Values

COMMON_RESOURCE_NAME

public static final java.lang.String COMMON_RESOURCE_NAME
See Also:
Constant Field Values

LOGGER_NAME

public static final java.lang.String LOGGER_NAME
See Also:
Constant Field Values
Constructor Detail

GuiUtil

public GuiUtil()
Creates a new instance of GuiUtil

Method Detail

getLogger

public static java.util.logging.Logger getLogger()

guiLog

public static void guiLog(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)

isEmpty

public static boolean isEmpty(java.lang.String str)

getCommonMessage

public static java.lang.String getCommonMessage(java.lang.String key,
                                                java.lang.Object[] args)

getMessage

public static java.lang.String getMessage(java.lang.String resourceName,
                                          java.lang.String key,
                                          java.lang.Object[] args)

getMessage

public static java.lang.String getMessage(java.lang.String key,
                                          java.lang.Object[] args)

initSessionAttributes

public static void initSessionAttributes()

setTimeStamp

public static void setTimeStamp()
                         throws java.lang.Exception
Throws:
java.lang.Exception

getTimeStamp

public static long getTimeStamp()
                         throws java.lang.Exception
Throws:
java.lang.Exception

setSessionValue

public static void setSessionValue(java.lang.String key,
                                   java.lang.Object value)

getSessionValue

public static java.lang.Object getSessionValue(java.lang.String key)

encode

public static java.lang.String encode(java.lang.String value,
                                      java.lang.String delim,
                                      java.lang.String type)

This method encodes the given String with the specified type.

If type is not specified then it defaults to UTF-8.

Parameters:
value - String to be encoded
delim - Reserved Characters don't want to be encoded
type - Encoding type. Default is UTF-8

genId

public static java.lang.String genId(java.lang.String uid)

This method generates an ID that is safe for JSF for the given String. It does not guarantee that the id is unique, it is the responsibility of the caller to pass in a String that will result in a UID. All non-ascii characters will be replaced with an '_'. This method will also ensure an alpha character (or '_') is the first character in the id.

Parameters:
uid - A non-null String.

getBundle

public static java.util.ResourceBundle getBundle(java.lang.String resourceName)

getMessage

public static java.lang.String getMessage(java.lang.String key)

getCommonMessage

public static java.lang.String getCommonMessage(java.lang.String key)

getMessage

public static java.lang.String getMessage(java.lang.String resourceName,
                                          java.lang.String key)

getMessage

public static java.lang.String getMessage(java.util.ResourceBundle bundle,
                                          java.lang.String key)

getLocale

public static java.util.Locale getLocale()

prepareSuccessful

public static void prepareSuccessful(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx)

prepareException

public static void prepareException(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx,
                                    java.lang.Throwable ex)

prepareAlert

public static void prepareAlert(java.lang.String type,
                                java.lang.String summary,
                                java.lang.String detail)

handleException

public static void handleException(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx,
                                   java.lang.Throwable ex)

handleError

public static void handleError(com.sun.jsftemplating.layout.descriptors.handler.HandlerContext handlerCtx,
                               java.lang.String detail)

notNull

public static java.lang.String notNull(java.lang.String test)

convertListOfStrings

public static java.util.List<java.lang.String> convertListOfStrings(java.util.List l)

parseStringList

public static java.util.List parseStringList(java.lang.String line,
                                             java.lang.String sep)
Parses a string containing substrings separated from each other by the specified set of separator characters and returns a list of strings. Splits the string line into individual string elements separated by the field separators specified in sep, and returns these individual strings as a list of strings. The individual string elements are trimmed of leading and trailing whitespace. Only non-empty strings are returned in the list.

Parameters:
line - The string to split
sep - The list of separators to use for determining where the string should be split. If null, then the standard separators (see StringTokenizer javadocs) are used.
Returns:
Returns the list containing the individual strings that the input string was split into.

removeToken

public static java.lang.String removeToken(java.lang.String line,
                                           java.lang.String sep,
                                           java.lang.String remove)

stringToArray

public static java.lang.String[] stringToArray(java.lang.String str,
                                               java.lang.String delimiter)
This method converts a string into stringarray, uses the delimeter as the separator character. If the delimiter is null, uses space as default.


arrayToString

public static java.lang.String arrayToString(java.lang.String[] str,
                                             java.lang.String delimiter)
This method concatenates the delimiter char to the end of each string in the array, and returns a single string with the concatenated string.


listToString

public static java.lang.String listToString(java.util.List<java.lang.String> list,
                                            java.lang.String delimiter)

asArray

public static <T> T[] asArray(java.lang.Object o)

isSelected

public static boolean isSelected(java.lang.String name,
                                 java.util.List<java.util.Map> selectedList)

checkEmpty

public static java.lang.String checkEmpty(java.lang.String test)

getBooleanValue

public static java.lang.Boolean getBooleanValue(java.util.Map pMap,
                                                java.lang.String name)

getHabitat

public static org.jvnet.hk2.component.Habitat getHabitat()

convertArrayToListOfMap

public static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> convertArrayToListOfMap(java.lang.Object[] values,
                                                                                                       java.lang.String key)

convertMapToListOfMap

public static java.util.List<java.util.Map<java.lang.String,java.lang.String>> convertMapToListOfMap(java.util.Map<java.lang.String,java.lang.String> values)

getMapValue

public static java.lang.Object getMapValue(java.util.Map map,
                                           java.lang.String mapKeys)

getCauses

public static java.lang.Throwable[] getCauses(java.lang.Throwable start)
Get the chain of exceptions via getCause(). The first element is the Exception passed.

Parameters:
start - the Exception to traverse
Returns:
a Throwable[] or an Exception[] as appropriate

getRootCause

public static java.lang.Throwable getRootCause(java.lang.Throwable e)
Get the original troublemaker.

Parameters:
e - the Exception to dig into
Returns:
the original Throwable that started the problem


Copyright © 2012 GlassFish Community. All Rights Reserved.