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

public Class Util

extends Object
Class Inheritance
Static Imports
com.sun.faces.RIConstants.CDI_BEAN_MANAGER, .RIConstants.FACELETS_ENCODING_KEY, .RIConstants.FACES_SERVLET_MAPPINGS, .RIConstants.FACES_SERVLET_REGISTRATION, .RIConstants.NO_VALUE, 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, jakarta.faces.application.ViewHandler.CHARACTER_ENCODING_KEY, java.lang.Character.isDigit, java.util.Collections.emptyList, java.util.logging.Level.FINE, .Level.FINEST, .Level.SEVERE

Util is a class ... Lifetime And Scope

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
public static interface

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_CACHE_KEY

RegEx patterns

public static final Map<String, Class<?>>
private static boolean
unitTestModeEnabled

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

Constructor Summary

AccessConstructor and Description
private
Util()

Method Summary

Modifier and TypeMethod and Description
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 DocumentBuilderFactory
public static SAXParserFactory
public static SchemaFactory
public static TransformerFactory
public static String
public static int

Returns:

first numeric segment from given client ID.
extractFirstNumericSegment
(String
the client ID
clientId
,
char
the separator character
separatorChar
)

Extract first numeric segment from given client ID.

  • 'table:1:button' should return 1
  • 'table:2' should return 2
  • '3:button' should return 3
  • '4' should return 4
public static String

Returns:

the filename extension or null. the method is null-safe
fileExtension
(String filename)

public static String
public static ELAwareBeanManager

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
)

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.

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 Doctype
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 HttpServletMapping

Returns:

the URL pattern of the jakarta.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 jakarta.faces.webapp.FacesServlet that is executing the current request.

private static Collection<String>
public static Optional<ServletRegistration>
public static HttpServletMapping
public static long
public static Object

Returns:

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

Factory method for creating the various Faces 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
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 encoding to be used for the response
getResponseEncoding
(FacesContext
the FacesContext for the current request
context
)

public static String

Returns:

the encoding to be used for the response
getResponseEncoding
(FacesContext
the FacesContext for the current request
context
,
Optional<String>
the default encoding, if any
defaultEncoding
)

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 the given string is null or is blank.
isBlank
(String
The string to be checked.
string
)

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

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
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

Returns:

null if the passed String is null or blank, s otherwise
nullIfBlank
(String s)

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

public static void
public static void
private static <F> void
setFeature(Util.ThrowingBiConsumer<F, Boolean> setter, F feature, Boolean flag)

private static <F> 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 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 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
,
int
split result threshold
splitLimit
)

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 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.

public static <T> Stream<T>
stream(Object object)

public static <E> Set<E>
unmodifiableSet(E... elements)

private static ELAwareBeanManager
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait