com.sun.faces.util
Class Util

java.lang.Object
  extended by com.sun.faces.util.Util

public class Util
extends java.lang.Object

Util is a class ...

Lifetime And Scope

Version:
$Id: Util.java,v 1.208.2.1 2007/04/26 16:53:52 rlubke Exp $

Nested Class Summary
static interface Util.TreeTraversalCallback
           
 
Field Summary
static java.lang.String APPLICATION_LOGGER
           
static java.lang.String CONFIG_LOGGER
           
static java.lang.String CONTEXT_LOGGER
           
static java.lang.String FACES_LOG_STRINGS
           
static java.lang.String FACES_LOGGER
           
static java.lang.String LIFECYCLE_LOGGER
           
static java.lang.String RENDERKIT_LOGGER
           
static java.lang.String TAGLIB_LOGGER
           
static java.lang.String TIMING_LOGGER
           
 
Method Summary
static boolean componentIsDisabled(javax.faces.component.UIComponent component)
           
static boolean componentIsDisabledOrReadonly(javax.faces.component.UIComponent component)
           
static java.lang.Object createInstance(java.lang.String className)
           
static java.lang.Object createInstance(java.lang.String className, java.lang.Class rootType, java.lang.Object root)
           
static java.lang.String getContentTypeFromResponse(java.lang.Object response)
          PRECONDITION: argument response is non-null and has a method called getContentType that takes no arguments and returns a String, with no side-effects.
static javax.faces.convert.Converter getConverterForClass(java.lang.Class converterClass, javax.faces.context.FacesContext context)
           
static javax.faces.convert.Converter getConverterForIdentifer(java.lang.String converterId, javax.faces.context.FacesContext context)
           
static java.lang.ClassLoader getCurrentLoader(java.lang.Object fallbackClass)
           
static java.lang.String getFacesMapping(javax.faces.context.FacesContext context)
          Returns the URL pattern of the FacesServlet that is executing the current request.
static java.beans.FeatureDescriptor getFeatureDescriptor(java.lang.String name, java.lang.String displayName, java.lang.String desc, boolean expert, boolean hidden, boolean preferred, java.lang.Object type, java.lang.Boolean designTime)
           
static java.lang.Object getListenerInstance(javax.el.ValueExpression type, javax.el.ValueExpression binding)
          Factory method for creating the varius JSF listener instances that may be referenced by type or binding.
static java.util.Locale getLocaleFromContextOrSystem(javax.faces.context.FacesContext context)
          If the FacesContext has a UIViewRoot, and this UIViewRoot has a Locale, return it.
static java.util.Locale getLocaleFromString(java.lang.String localeStr)
           
static java.util.logging.Logger getLogger(java.lang.String loggerName)
           
static java.lang.String getStackTraceString(java.lang.Throwable e)
          Leverage the Throwable.getStackTrace() method to produce a String version of the stack trace, with a "\n" before each line.
static javax.faces.application.StateManager getStateManager(javax.faces.context.FacesContext context)
           
static javax.faces.application.ViewHandler getViewHandler(javax.faces.context.FacesContext context)
           
static int indexOfSet(java.lang.String str, char[] set, int fromIndex)
           
static boolean isCoreTLVActive()
           
static boolean isHtmlTLVActive()
           
static boolean isPrefixMapped(java.lang.String mapping)
          Returns true if the provided url-mapping is a prefix path mapping (starts with /).
static boolean isUnitTestModeEnabled()
           
static java.lang.Class loadClass(java.lang.String name, java.lang.Object fallbackClass)
           
static void parameterNonEmpty(java.lang.String param)
           
static void parameterNonNull(java.lang.Object param)
           
static boolean prefixViewTraversal(javax.faces.context.FacesContext context, javax.faces.component.UIComponent root, Util.TreeTraversalCallback action)
           
static void setCoreTLVActive(boolean active)
           
static void setHtmlTLVActive(boolean active)
           
static void setUnitTestModeEnabled(boolean enabled)
           
static java.lang.String[] split(java.lang.String toSplit, java.lang.String regex)
          A slightly more efficient version of String.split() which caches the Patterns in an LRUMap instead of creating a new Pattern on each invocation.
static void verifyFactoriesAndInitDefaultRenderKit(javax.servlet.ServletContext context)
          Verify the existence of all the factories needed by faces.
static void verifyRequiredClasses(javax.faces.context.FacesContext facesContext)
          Verifies that the required classes are available on either the ContextClassLoader, or the local ClassLoader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FACES_LOGGER

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

FACES_LOG_STRINGS

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

RENDERKIT_LOGGER

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

TAGLIB_LOGGER

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

APPLICATION_LOGGER

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

CONTEXT_LOGGER

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

CONFIG_LOGGER

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

LIFECYCLE_LOGGER

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

TIMING_LOGGER

public static final java.lang.String TIMING_LOGGER
See Also:
Constant Field Values
Method Detail

getListenerInstance

public static java.lang.Object getListenerInstance(javax.el.ValueExpression type,
                                                   javax.el.ValueExpression binding)

Factory method for creating the varius JSF listener instances that may be referenced by type or binding.

If binding is not null and the evaluation result is not null return that instance. Otherwise try to instantiate an instances based on type.

Parameters:
type - the Listener type
binding - a ValueExpression which resolves to a Listener instance
Returns:
a Listener instance based off the provided type and

setUnitTestModeEnabled

public static void setUnitTestModeEnabled(boolean enabled)

isUnitTestModeEnabled

public static boolean isUnitTestModeEnabled()

setCoreTLVActive

public static void setCoreTLVActive(boolean active)

isCoreTLVActive

public static boolean isCoreTLVActive()

setHtmlTLVActive

public static void setHtmlTLVActive(boolean active)

isHtmlTLVActive

public static boolean isHtmlTLVActive()

loadClass

public static java.lang.Class loadClass(java.lang.String name,
                                        java.lang.Object fallbackClass)
                                 throws java.lang.ClassNotFoundException
Throws:
java.lang.ClassNotFoundException

getCurrentLoader

public static java.lang.ClassLoader getCurrentLoader(java.lang.Object fallbackClass)

getLogger

public static java.util.logging.Logger getLogger(java.lang.String loggerName)

verifyFactoriesAndInitDefaultRenderKit

public static void verifyFactoriesAndInitDefaultRenderKit(javax.servlet.ServletContext context)
                                                   throws javax.faces.FacesException
Verify the existence of all the factories needed by faces. Create and install the default RenderKit into the ServletContext.

Throws:
javax.faces.FacesException
See Also:
FactoryFinder

verifyRequiredClasses

public static void verifyRequiredClasses(javax.faces.context.FacesContext facesContext)
                                  throws javax.faces.FacesException

Verifies that the required classes are available on either the ContextClassLoader, or the local ClassLoader. Currently only checks for the class "javax.servlet.jsp.jstl.fmt.LocalizationContext", which is used for Localization.

The result of the check is saved in the ServletContext attribute RIConstants.HAS_REQUIRED_CLASSES_ATTR.

Algorithm:

Check the ServletContext for the attribute, if found, and the value is false, that means we've checked before, and we don't have the classes, just throw FacesException. If the value is true, we've checked before and we have the classes, just return.

Throws:
javax.faces.FacesException

getLocaleFromContextOrSystem

public static java.util.Locale getLocaleFromContextOrSystem(javax.faces.context.FacesContext context)

If the FacesContext has a UIViewRoot, and this UIViewRoot has a Locale, return it. Otherwise return Locale.getDefault().


getConverterForClass

public static javax.faces.convert.Converter getConverterForClass(java.lang.Class converterClass,
                                                                 javax.faces.context.FacesContext context)

getConverterForIdentifer

public static javax.faces.convert.Converter getConverterForIdentifer(java.lang.String converterId,
                                                                     javax.faces.context.FacesContext context)

getStateManager

public static javax.faces.application.StateManager getStateManager(javax.faces.context.FacesContext context)
                                                            throws javax.faces.FacesException
Throws:
javax.faces.FacesException

getViewHandler

public static javax.faces.application.ViewHandler getViewHandler(javax.faces.context.FacesContext context)
                                                          throws javax.faces.FacesException
Throws:
javax.faces.FacesException

componentIsDisabled

public static boolean componentIsDisabled(javax.faces.component.UIComponent component)

componentIsDisabledOrReadonly

public static boolean componentIsDisabledOrReadonly(javax.faces.component.UIComponent component)

createInstance

public static java.lang.Object createInstance(java.lang.String className)

createInstance

public static java.lang.Object createInstance(java.lang.String className,
                                              java.lang.Class rootType,
                                              java.lang.Object root)

getLocaleFromString

public static java.util.Locale getLocaleFromString(java.lang.String localeStr)
                                            throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

indexOfSet

public static int indexOfSet(java.lang.String str,
                             char[] set,
                             int fromIndex)
Returns:
starting at fromIndex, the index of the first occurrence of any substring from set in toSearch, or -1 if no such match is found

parameterNonNull

public static void parameterNonNull(java.lang.Object param)
                             throws javax.faces.FacesException
Throws:
javax.faces.FacesException

parameterNonEmpty

public static void parameterNonEmpty(java.lang.String param)
                              throws javax.faces.FacesException
Throws:
javax.faces.FacesException

getStackTraceString

public static java.lang.String getStackTraceString(java.lang.Throwable e)

Leverage the Throwable.getStackTrace() method to produce a String version of the stack trace, with a "\n" before each line.

Returns:
the String representation ofthe stack trace obtained by calling getStackTrace() on the passed in exception. If null is passed in, we return the empty String.

getContentTypeFromResponse

public static java.lang.String getContentTypeFromResponse(java.lang.Object response)

PRECONDITION: argument response is non-null and has a method called getContentType that takes no arguments and returns a String, with no side-effects.

This method allows us to get the contentType in both the servlet and portlet cases, without introducing a compile-time dependency on the portlet api.


prefixViewTraversal

public static boolean prefixViewTraversal(javax.faces.context.FacesContext context,
                                          javax.faces.component.UIComponent root,
                                          Util.TreeTraversalCallback action)
                                   throws javax.faces.FacesException
Throws:
javax.faces.FacesException

getFeatureDescriptor

public static java.beans.FeatureDescriptor getFeatureDescriptor(java.lang.String name,
                                                                java.lang.String displayName,
                                                                java.lang.String desc,
                                                                boolean expert,
                                                                boolean hidden,
                                                                boolean preferred,
                                                                java.lang.Object type,
                                                                java.lang.Boolean designTime)

split

public static java.lang.String[] split(java.lang.String toSplit,
                                       java.lang.String regex)

A slightly more efficient version of String.split() which caches the Patterns in an LRUMap instead of creating a new Pattern on each invocation.

Parameters:
toSplit - the string to split
regex - the regex used for splitting
Returns:
the result of Pattern.spit(String, int)

getFacesMapping

public static java.lang.String getFacesMapping(javax.faces.context.FacesContext context)

Returns the URL pattern of the FacesServlet that is executing the current request. If there are multiple URL patterns, the value returned by HttpServletRequest.getServletPath() and HttpServletRequest.getPathInfo() is used to determine which mapping to return.

If no mapping can be determined, it most likely means that this particular request wasn't dispatched through the FacesServlet.

Parameters:
context - the FacesContext of the current request
Returns:
the URL pattern of the FacesServlet or null if no mapping can be determined
Throws:
java.lang.NullPointerException - if context is null

isPrefixMapped

public static boolean isPrefixMapped(java.lang.String mapping)

Returns true if the provided url-mapping is a prefix path mapping (starts with /).

Parameters:
mapping - a url-pattern
Returns:
true if the mapping starts with /


Copyright ? 2002-2006 Sun Microsystems, Inc. All Rights Reserved.