Top Description Inners Fields Constructors Methods
com.sun.faces.util

public Class Util

extends Object
Class Inheritance
Static Imports
com.sun.faces.util.MessageUtils.ILLEGAL_ATTEMPT_SETTING_APPLICATION_ARTIFACT_ID, .MessageUtils.NAMED_OBJECT_NOT_FOUND_ERROR_MESSAGE_ID, .MessageUtils.NULL_PARAMETERS_ERROR_MESSAGE_ID, .MessageUtils.NULL_VIEW_ID_ERROR_MESSAGE_ID, .MessageUtils.getExceptionMessageString, .RequestStateManager.INVOCATION_PATH, java.util.Collections.emptyList, java.util.logging.Level.FINE, .Level.SEVERE

Util is a class ...

Lifetime And Scope

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
private static final String
private static final String
private static final String
private static final String
private static final Logger
private static final String
PATTERN_CACKE_KEY

RegEx patterns

private static boolean
unitTestModeEnabled

Flag that, when true, enables special behavior in the RI to enable unit testing.

Constructor Summary

AccessConstructor and Description
private
Util()

Method Summary

Modifier and TypeMethod and Description
public static String
public static void
canSetAppArtifact(ApplicationAssociate applicationAssociate, String artifactName)

public static void
checkIdUniqueness(FacesContext context, UIComponent component, Set<String> componentIds)

Utility method to validate ID uniqueness for the tree represented by component.

public static boolean
public static <
The generic object type.
T
>
T

Returns:

The first non-null object of the argument list, or null if there is no such element.
coalesce
(T...
The argument list of objects to be tested for non-null.
objects
)

Returns the first non-null object of the argument list, or null if there is no such element.

public static boolean
public static boolean
public static DocumentBuilderFactory
public static SAXParserFactory
public static SchemaFactory
public static TransformerFactory
public static String
public static BeanManager

Returns:

the CDI bean manager.
getCdiBeanManager
(FacesContext
the Faces context to consult
facesContext
)

Get the CDI bean manager.

public static String
public static String

Returns:

the content type of the response
getContentTypeFromResponse
(Object
the current response
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.

private static ClassLoader
public static ClassLoader
getContextClassLoader2()

Identify and return the class loader that is associated with the calling web application.

public static Converter<T>
getConverterForClass(Class<T> converterClass, FacesContext context)

public static Converter<T>
public static ClassLoader
getCurrentLoader(Object fallbackClass)

public static String
private static ServletRegistration
public static String

Returns:

the version found, or "" if none found.
getFacesConfigXmlVersion
(FacesContext
the Faces context.
facesContext
)

Get the faces-config.xml version (if any).

public static String

Returns:

the URL pattern of the javax.faces.webapp.FacesServlet or null if no mapping can be determined
getFacesMapping
(FacesContext
the FacesContext of the current request
context
)

Returns the URL pattern of the javax.faces.webapp.FacesServlet that is executing the current request.

private static Collection<String>
public static FeatureDescriptor
getFeatureDescriptor(String name, String displayName, String desc, boolean expert, boolean hidden, boolean preferred, Object type, Boolean designTime)

public static String
public static long
public static Object

Returns:

a Listener instance based off the provided type and
getListenerInstance
(ValueExpression
the Listener type
type
,
ValueExpression
a ValueExpression which resolves to a Listener instance
binding
)

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

public static Locale

Returns:

the Locale from the UIViewRoot, the the value of Locale.getDefault()
getLocaleFromContextOrSystem
(FacesContext
the FacesContext for the current request
context
)

public static Locale
private static String

Returns:

the appropriate mapping based on the current request
getMappingForRequest
(ExternalContext
the external context of the request
externalContext
,
String
the servlet path of the request
servletPath
,
String
the path info of the request
pathInfo
)

Return the appropriate javax.faces.webapp.FacesServlet mapping based on the servlet path of the current request.

public static String

Returns:

The naming container prefix, or an empty string if the view root is not an instance of naming container.
getNamingContainerPrefix
(FacesContext
Involved faces context.
context
)

If view root is instance of naming container, return its container client id, suffixed with separator character.

private static Map<String, Pattern>
private static Map<String, Pattern>
public static String

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.
getStackTraceString
(Throwable
the Throwable to obtain the stacktrace from
e
)

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

public static StateManager
public static Class<T>
public static ValueExpression
public static ViewHandler
public static String
public static String

Returns:

the version found, or "" if none found.
getWebXmlVersion
(FacesContext
the Faces context.
facesContext
)

Get the web.xml version (if any).

public static String
public static int

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
indexOfSet
(String
local string
str
,
char[]
the substring
set
,
int
starting index
fromIndex
)

public static boolean

Returns:

True if all values are empty, false otherwise
isAllEmpty
(Object...
the values to be checked on emptiness
values
)

Returns true if all values are empty, false if at least one value is not empty.

public static boolean
isAllNull(Object... values)

public static boolean

Returns:

true if any value is empty and false if no values are empty
isAnyEmpty
(Object...
the values to be checked on emptiness
values
)

Returns true if at least one value is empty.

public static boolean
isAnyNull(Object... values)

public static boolean

Returns:

true if available, false otherwise.
isCdiAvailable
(FacesContext
the Faces context to consult.
facesContext
)

Is CDI available.

public static boolean

Returns:

true if available, false otherwise.
isCdiAvailable
(ServletContext
the servlet context.
servletContext
)

Is CDI available (ServletContext variant)

public static boolean

Returns:

true if CDI 1.1 or later, false otherwise.
isCdiOneOneOrLater
(FacesContext
the Faces context.
facesContext
)

Is CDI 1.1 or later

public static boolean

Returns:

True if the given string is null or is empty.
isEmpty
(String
The string to be checked on emptiness.
string
)

Returns true if the given string is null or is empty.

public static boolean

Returns:

true if the given array is null or is empty.
isEmpty
(Object[]
The array to be checked on emptiness.
array
)

Returns true if the given array is null or is empty.

public static boolean

Returns:

true if the given collection is null or is empty.
isEmpty
(Collection<?>
The collection to be checked on emptiness.
collection
)

Returns true if the given collection is null or is empty.

public static boolean

Returns:

true if the given value is null or is empty.
isEmpty
(Object
The value to be checked on emptiness.
value
)

Returns true if the given value is null or is empty.

public static boolean

Returns:

true if the mapping starts with /
isExactMapped
(String
a url-pattern
mapping
)

Returns true if the provided url-mapping is an exact mapping (starts with Util#EXACT_MARKER).

public static <
The generic object type.
T
>
boolean

Returns:

true if the given object equals one of the given objects.
isOneOf
(T
The object to be checked if it equals one of the given objects.
object
,
T...
The argument list of objects to be tested for equality.
objects
)

Returns true if the given object equals one of the given objects.

public static boolean
isPortletRequest(FacesContext
the FacesContext associated with the request.
context
)

Convenience method for determining if the request associated with the specified FacesContext is a PortletRequest submitted by the JSR-301 bridge.

public static boolean

Returns:

true if the mapping starts with /
isPrefixMapped
(String
a url-pattern
mapping
)

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

public static boolean

Returns:

true if the FacesServlet is exact mapped to the given resource, false otherwise
isResourceExactMappedToFacesServlet
(ExternalContext
the external context for this request
externalContext
,
String
the resource to test
resource
)

Checks if the FacesServlet is exact mapped to the given resource.

public static boolean
public static boolean
public static boolean

Returns:

true if the FacesServlet is exact mapped to the given viewId, false otherwise
isViewIdExactMappedToFacesServlet
(String
the view id to test
viewId
)

Checks if the FacesServlet is exact mapped to the given resource.

public static boolean

Returns:

true if the FacesContext attributes map contains a reference to the UIViewRoot's view ID
isViewPopulated
(FacesContext
the FacesContext for the current request
ctx
,
UIViewRoot
the UIViewRoot to check
viewToRender
)

public static Class<T>
loadClass(String name, Object fallbackClass)

public static Class<?>
loadClass2(String name, Object fallbackClass)

public static <T> T
newInstance(Class<?> clazz)

public static void
notNegative(String varname, long number)

public static void
notNull(String varname, Object var)

public static void
notNullAttribute(String attributeName, Object attribute)

public static void
notNullNamedObject(Object object, String objectId, String logMsg)

public static void
public static String
public static String
public static String
public static String
public static <T> List<T>
reverse(List<T> list)

public static void
public static void
public static void
setUnitTestModeEnabled(boolean enabled)

public static void
setViewPopulated(FacesContext
the FacesContext for the current request
ctx
,
UIViewRoot
the UIViewRoot to mark as populated
viewToRender
)

Flag the specified UIViewRoot as populated.

public static synchronized String[]

Returns:

the result of Pattern.spit(String, int)
split
(Map<String, Object>
the Application Map
appMap
,
String
the string to split
toSplit
,
String
the regex used for splitting
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.

public static synchronized String[]
split(ServletContext sc, String toSplit, String regex)

public static boolean

Returns:

true if the given string starts with one of the given prefixes.
startsWithOneOf
(String
The object to be checked if it starts with one of the given prefixes.
string
,
String...
The argument list of prefixes to be checked
prefixes
)

Returns true if the given string starts with one of the given prefixes.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait