org.apache.myfaces.trinidad.util
Class ComponentUtils

java.lang.Object
  extended by org.apache.myfaces.trinidad.util.ComponentUtils

public final class ComponentUtils
extends Object

Utility functions used by the Apache Trinidad components.

Version:
$Name: $ ($Revision: adfrt/faces/adf-faces-api/src/main/java/oracle/adf/view/faces/util/ComponentUtils.java#0 $) $Date: 10-nov-2005.19:08:37 $

Method Summary
static javax.faces.component.UIComponent findRelativeComponent(javax.faces.component.UIComponent from, String scopedId)
          Find a component relative to another.
static String getLogicalScopedIdForComponent(javax.faces.component.UIComponent targetComponent, javax.faces.component.UIComponent baseComponent)
          Gets the logical scoped identifier for the target component.
static javax.faces.component.UIComponent getNonFlatteningAncestor(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Returns the nearest ancestor component, skipping over any flattening components.
static String getScopedIdForComponent(javax.faces.component.UIComponent targetComponent, javax.faces.component.UIComponent baseComponent)
          Gets the scoped identifier for the target component.
static boolean isSkipIterationVisit(javax.faces.component.visit.VisitContext visitContext)
           
static boolean resolveBoolean(Object value)
          Utility method for component code that transforms Object->boolean.
static boolean resolveBoolean(Object value, boolean defaultValue)
          Utility method for component code that transforms Object->boolean.
static char resolveCharacter(Character value)
          Utility method for component code that transforms Character->character.
static char resolveCharacter(Character value, char defaultValue)
          Utility method for component code that transforms Character->character.
static Date resolveDate(Object value)
          Utility method for code that transforms Object->Date
static Date resolveDate(Object value, Date defaultValue)
          Utility method for code that transforms Object->Date
static double resolveDouble(Object value)
          Utility method for component code that transforms an Object (which must be a java.lang.Number) into a double.
static double resolveDouble(Object value, double defaultValue)
          Utility method for component code that transforms an Object (which must be a java.lang.Number) into a double.
static int resolveInteger(Object value)
          Utility method for component code that transforms an Object (which must be a java.lang.Number) into an int.
static int resolveInteger(Object value, int defaultValue)
          Utility method for component code that transforms an Object (which must be a java.lang.Number) into an int.
static Locale resolveLocale(Object value)
           
static Locale resolveLocale(Object value, Locale defaultValue)
           
static long resolveLong(Object value)
          Utility method for component code that transforms an Object (which must be a java.lang.Number) into a long.
static long resolveLong(Object value, long defaultValue)
          Utility method for component code that transforms an Object (which must be a java.lang.Number) into a long.
static Number resolveNumber(Object value)
          Utility method for component code that transforms Object->Number.
static Number resolveNumber(Object value, Number defaultValue)
          Utility method for component code that transforms Object->Number.
static Object resolveObject(Object value, Object defaultValue)
          Utility method for component code that resolves an Object, returning a default value if the value is null.
static String resolveString(Object value)
          Utility method for component code that transforms Object->String.
static String resolveString(Object value, boolean treatEmptyStringAsNull)
          Utility method for component code that transforms Object->String.
static String resolveString(Object value, String defaultValue)
          Utility method for component code that transforms Object->String.
static String[] resolveStringArray(Object value)
          Utility method for code that transforms Object->String[]
static String[] resolveStringArray(Object value, String[] defaultValue)
          Utility method for code that transforms Object->String[]
static TimeZone resolveTimeZone(Object value)
           
static TimeZone resolveTimeZone(Object value, TimeZone defaultValue)
           
static Throwable unwrap(Throwable t)
          Gets the root cause of an exception.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

resolveObject

public static Object resolveObject(Object value,
                                   Object defaultValue)
Utility method for component code that resolves an Object, returning a default value if the value is null.


resolveBoolean

public static boolean resolveBoolean(Object value,
                                     boolean defaultValue)
Utility method for component code that transforms Object->boolean.


resolveBoolean

public static boolean resolveBoolean(Object value)
Utility method for component code that transforms Object->boolean.


resolveInteger

public static int resolveInteger(Object value)
Utility method for component code that transforms an Object (which must be a java.lang.Number) into an int.


resolveInteger

public static int resolveInteger(Object value,
                                 int defaultValue)
Utility method for component code that transforms an Object (which must be a java.lang.Number) into an int.


resolveLong

public static long resolveLong(Object value)
Utility method for component code that transforms an Object (which must be a java.lang.Number) into a long.


resolveLong

public static long resolveLong(Object value,
                               long defaultValue)
Utility method for component code that transforms an Object (which must be a java.lang.Number) into a long.


resolveDouble

public static double resolveDouble(Object value)
Utility method for component code that transforms an Object (which must be a java.lang.Number) into a double.


resolveDouble

public static double resolveDouble(Object value,
                                   double defaultValue)
Utility method for component code that transforms an Object (which must be a java.lang.Number) into a double.


resolveCharacter

public static char resolveCharacter(Character value)
Utility method for component code that transforms Character->character.


resolveCharacter

public static char resolveCharacter(Character value,
                                    char defaultValue)
Utility method for component code that transforms Character->character.


resolveNumber

public static Number resolveNumber(Object value)
Utility method for component code that transforms Object->Number.


resolveNumber

public static Number resolveNumber(Object value,
                                   Number defaultValue)
Utility method for component code that transforms Object->Number.


resolveString

public static String resolveString(Object value)
Utility method for component code that transforms Object->String.


resolveString

public static String resolveString(Object value,
                                   boolean treatEmptyStringAsNull)
Utility method for component code that transforms Object->String. If treatEmptyStringAsNull is true, null is returned for empty string.


resolveString

public static String resolveString(Object value,
                                   String defaultValue)
Utility method for component code that transforms Object->String.


resolveStringArray

public static String[] resolveStringArray(Object value)
Utility method for code that transforms Object->String[]


resolveStringArray

public static String[] resolveStringArray(Object value,
                                          String[] defaultValue)
Utility method for code that transforms Object->String[]


resolveDate

public static Date resolveDate(Object value)
Utility method for code that transforms Object->Date


resolveDate

public static Date resolveDate(Object value,
                               Date defaultValue)
Utility method for code that transforms Object->Date


resolveTimeZone

public static TimeZone resolveTimeZone(Object value)

resolveTimeZone

public static TimeZone resolveTimeZone(Object value,
                                       TimeZone defaultValue)

resolveLocale

public static Locale resolveLocale(Object value)

resolveLocale

public static Locale resolveLocale(Object value,
                                   Locale defaultValue)

isSkipIterationVisit

public static boolean isSkipIterationVisit(javax.faces.component.visit.VisitContext visitContext)
Parameters:
visitContext -
Returns:
true if this is a non-iterating visit.

unwrap

public static Throwable unwrap(Throwable t)
Gets the root cause of an exception. Keeps unwrapping the given throwable until the root cause is found.


findRelativeComponent

public static javax.faces.component.UIComponent findRelativeComponent(javax.faces.component.UIComponent from,
                                                                      String scopedId)
Find a component relative to another.

The relative ID must account for NamingContainers. If the component is already inside of a naming container, you can use a single colon to start the search from the root, or multiple colons to move up through the NamingContainers - "::" will pop out of the current naming container, ":::" will pop out of two naming containers, etc.

Parameters:
from - the component to search relative to
scopedId - the relative id path from the 'from' component to the component to find
Returns:
the component if found, null otherwise
See Also:
RenderUtils.getRelativeId(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.String), UIComponent.findComponent(java.lang.String)

getScopedIdForComponent

public static String getScopedIdForComponent(javax.faces.component.UIComponent targetComponent,
                                             javax.faces.component.UIComponent baseComponent)
Gets the scoped identifier for the target component. The scoping will be within a subtree rooted by the supplied base component. If the supplied base component were to be the view root, the returned id will be the absolute id and hence prefixed with NamingContainer.SEPARATOR_CHARACTER. This algorithm reverse matches that of UIComponent.findComponent(). In other words, the scoped id returned by this method can be safely used in calls to findComponent() on the baseComponent, if it were to be enclosing the targetComponent. This method assumes that the supplied baseComponent definitely encloses the targetComponent, return value is not reliable if this is not the case. Examples of id returned: ':foo:bar:baz'/'foo:baz'/'foo'

Parameters:
targetComponent - The component for which the scoped id needs to be determined.
baseComponent - The component relative to which the scoped id for the targetComponent needs to be determined.
Returns:
The scoped id for target component. Returns null if the supplied targetComponent was null or did not have an id.

getLogicalScopedIdForComponent

public static String getLogicalScopedIdForComponent(javax.faces.component.UIComponent targetComponent,
                                                    javax.faces.component.UIComponent baseComponent)
Gets the logical scoped identifier for the target component. The scoping will be within a subtree rooted by the supplied base component. The subtree will be computed in the context of the document or documents where the components were defined. If the supplied base component were to be the view root, the returned id will be the absolute id and hence prefixed with NamingContainer.SEPARATOR_CHARACTER. This algorithm reverse matches that of UIComponent.findComponent(). In other words, the scoped id returned by this method can be safely used in calls to findComponent() on the baseComponent, if it were to be enclosing the targetComponent. This method assumes that the supplied baseComponent definitely encloses the targetComponent, return value is not reliable if this is not the case. Examples of id returned: ':foo:bar:baz'/'foo:baz'/'foo'

Parameters:
targetComponent - The component for which the scoped id needs to be determined.
baseComponent - The component relative to which the scoped id for the targetComponent needs to be determined.
Returns:
The scoped id for target component. Returns null if the supplied targetComponent was null or did not have an id.

getNonFlatteningAncestor

public static javax.faces.component.UIComponent getNonFlatteningAncestor(javax.faces.context.FacesContext context,
                                                                         javax.faces.component.UIComponent component)
Returns the nearest ancestor component, skipping over any flattening components.

Parameters:
context - the FacesContext
component - the UIComponent
Returns:
the first ancestor component that is not a FlattenedComponent that is actively flattening its children or null if no such ancestor component is found.
See Also:
FlattenedComponent


Copyright © 2001-2012 The Apache Software Foundation. All Rights Reserved.