|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.rave.web.ui.util.VariableResolver
public class VariableResolver
VariableResolver is used to parse expressions of the format.
<type> refers to a registerd VariableResolver.DataSource
,
custom VariableResolver.DataSource
s can be registered via:
setDataSource(String key,
VariableResolver.DataSource dataSource)
.
However, there are many built-in VariableResolver.DataSource
types that are pre-registered.
Below are the pre-registered types:
ATTRIBUTE
-- VariableResolver.AttributeDataSource
BOOLEAN
-- VariableResolver.BooleanDataSource
BROWSER
-- VariableResolver.BrowserDataSource
CONSTANT
-- VariableResolver.ConstantDataSource
ESCAPE
-- VariableResolver.EscapeDataSource
HAS_FACET
-- VariableResolver.HasFacetDataSource
HAS_PROPERTY
-- VariableResolver.HasPropertyDataSource
INT
-- VariableResolver.IntDataSource
METHOD_BINDING
-- VariableResolver.MethodBindingDataSource
PROPERTY
-- VariableResolver.PropertyDataSource
REQUEST_PARAMETER
--
VariableResolver.RequestParameterDataSource
RESOURCE
-- VariableResolver.ResourceBundleDataSource
SESSION
-- VariableResolver.SessionDataSource
STYLE
-- VariableResolver.StyleDataSource
THEME_JS
-- VariableResolver.ThemeJavaScriptDataSource
THIS
-- VariableResolver.ThisDataSource
Nested Class Summary | |
---|---|
static class |
VariableResolver.AttributeDataSource
This VariableResolver.DataSource provides access to
HttpRequest attributes. |
static class |
VariableResolver.BooleanDataSource
This VariableResolver.DataSource converts the given
key to a Boolean . |
static class |
VariableResolver.BrowserDataSource
This VariableResolver.DataSource uses the given
key to check various properties of the browser that
submitted the request. |
static class |
VariableResolver.ConstantDataSource
This VariableResolver.DataSource allows access to constants
in java classes. |
static interface |
VariableResolver.DataSource
This interface defines a String substitution data source. |
static class |
VariableResolver.EscapeDataSource
This VariableResolver.DataSource simply returns the key
that it is given. |
static class |
VariableResolver.HasFacetDataSource
This VariableResolver.DataSource tests if the given facet
exists on the UIComponent. |
static class |
VariableResolver.HasPropertyDataSource
This VariableResolver.DataSource tests if the given
property exists on the UIComponent. |
static class |
VariableResolver.IntDataSource
This VariableResolver.DataSource converts the given
key to an Integer . |
static class |
VariableResolver.MethodBindingDataSource
This VariableResolver.DataSource creates a MethodBinding
from the supplied key. |
static class |
VariableResolver.PropertyDataSource
This VariableResolver.DataSource provides access to
UIComponent Properties. |
static class |
VariableResolver.RequestParameterDataSource
This VariableResolver.DataSource provides access to
HttpRequest Parameters. |
static class |
VariableResolver.ResourceBundleDataSource
This VariableResolver.DataSource allows access to resource
bundle keys. |
static class |
VariableResolver.SessionDataSource
This VariableResolver.DataSource provides access to
HttpSession attributes. |
static class |
VariableResolver.StyleDataSource
This VariableResolver.DataSource retrieves style classes
from the current Theme . |
static class |
VariableResolver.ThemeDataSource
This VariableResolver.DataSource retrieves Theme messages
from the Theme . |
static class |
VariableResolver.ThemeJavaScriptDataSource
This VariableResolver.DataSource retrieves the path to a
JavaScript file from the Theme . |
static class |
VariableResolver.ThisDataSource
This class provides an implementation for the syntax $this{xyz} where xyz can be any of the following. |
Field Summary | |
---|---|
static java.lang.String |
ATTRIBUTE
Defines "attribute" in $attribute{...}. |
static java.lang.String |
BOOLEAN
Defines "boolean" in $boolean{...}. |
static java.lang.String |
BROWSER
Defines "browser" in $browser{...}. |
static java.lang.String |
CONSTANT
Defines "constant" in $constant{...}. |
static java.lang.String |
ESCAPE
Defines "escape" in $escape{...}. |
static java.lang.String |
HAS_FACET
Defines "hasFacet" in $hasFacet{...}. |
static java.lang.String |
HAS_PROPERTY
Defines "hasProperty" in $hasProperty{...}. |
static java.lang.String |
INT
Defines "int" in $int{...}. |
static java.lang.String |
METHOD_BINDING
Defines "methodBinding" in $methodBinding{...}. |
static java.lang.String |
PROPERTY
Defines "property" in $property{...}. |
static java.lang.String |
REQUEST_PARAMETER
Defines "requestParameter" in $requestParameter{...}. |
static java.lang.String |
RESOURCE
Defines "resource" in $resource{...}. |
static java.lang.String |
SESSION
Defines "session" in $session{...}. |
static java.lang.String |
STYLE
Defines "style" in $style{...}. |
static java.lang.String |
SUB_END
The ')' character marks the end of the data content for a String substitution. |
static java.lang.String |
SUB_START
The '$' character marks the beginning of a substituion in a String. |
static java.lang.String |
SUB_TYPE_DELIM
The '(' character marks the beginning of the data content of a String substitution. |
static java.lang.String |
THEME
Defines "theme" in $theme{...}. |
static java.lang.String |
THEME_JS
Defines "themeScript" in $themeScript{...}. |
static java.lang.String |
THIS
Defines "this" in $this{...}. |
Constructor Summary | |
---|---|
VariableResolver()
|
Method Summary | |
---|---|
static VariableResolver.DataSource |
getDataSource(java.lang.String key)
This method looks up the requested VariableResolver.DataSource by the given key. |
static void |
main(java.lang.String[] args)
The main function for this class provides some simple test cases. |
static java.lang.Object |
resolveVariables(javax.faces.context.FacesContext ctx,
LayoutElement desc,
javax.faces.component.UIComponent component,
java.lang.Object value)
This method replaces the ${..} variables with their attribute values. |
static java.lang.Object |
resolveVariables(javax.faces.context.FacesContext ctx,
LayoutElement desc,
javax.faces.component.UIComponent component,
java.lang.String string,
java.lang.String startToken,
java.lang.String typeDelim,
java.lang.String endToken)
This method will substitute variables into the given String, or return the variable if the substitution is the whole String. |
static java.lang.Object |
resolveVariables(LayoutElement desc,
javax.faces.component.UIComponent component,
java.lang.Object value)
This method replaces the ${..} variables with their values. |
static void |
setDataSource(java.lang.String key,
VariableResolver.DataSource dataSource)
This method sets the given VariableResolver.DataSource to
be used for $[type]{...} when key matches type. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String ATTRIBUTE
Defines "attribute" in $attribute{...}. This allows you to retrieve an HttpRequest attribute.
public static final java.lang.String PROPERTY
Defines "property" in $property{...}. This allows you to retrieve a property from the UIComponent.
public static final java.lang.String HAS_PROPERTY
Defines "hasProperty" in $hasProperty{...}. This allows you to see if a property from the UIComponent exists.
public static final java.lang.String HAS_FACET
Defines "hasFacet" in $hasFacet{...}. This allows you to see if a facet from the UIComponent exists.
public static final java.lang.String SESSION
Defines "session" in $session{...}. This allows you to retrieve an HttpSession attribute.
public static final java.lang.String STYLE
Defines "style" in $style{...}. This allows you to retrieve
a style classes from the current Theme
.
public static final java.lang.String THEME
Defines "theme" in $theme{...}. This allows you to
retrieve a Theme message from the current
Theme
.
public static final java.lang.String THEME_JS
Defines "themeScript" in $themeScript{...}. This allows you to
retrieve a JavaScript classes from the current
Theme
.
public static final java.lang.String REQUEST_PARAMETER
Defines "requestParameter" in $requestParameter{...}. This allows you to retrieve a HttpRequest parameter (QUERY_STRING parameter).
public static final java.lang.String THIS
Defines "this" in $this{...}. This allows you to retrieve a number of different objects related to the relative placement of this expression.
VariableResolver.ThisDataSource
,
Constant Field Valuespublic static final java.lang.String ESCAPE
Defines "escape" in $escape{...}. This allows some reserved characters to be escaped in "if" attributes. Such as '=' or '|'.
public static final java.lang.String BOOLEAN
Defines "boolean" in $boolean{...}. This converts the given String to a Boolean.
public static final java.lang.String BROWSER
Defines "browser" in $browser{...}. This checks properties of the browser that sent the request.
public static final java.lang.String INT
Defines "int" in $int{...}. This converts the given String to an Integer.
public static final java.lang.String METHOD_BINDING
Defines "methodBinding" in $methodBinding{...}. This allows MethodBindings in to be created.
public static final java.lang.String CONSTANT
Defines "constant" in $constant{...}. This allows constants in java classes to be accessed.
public static final java.lang.String RESOURCE
Defines "resource" in $resource{...}. This allows resource to be accessed.
public static final java.lang.String SUB_START
public static final java.lang.String SUB_TYPE_DELIM
public static final java.lang.String SUB_END
Constructor Detail |
---|
public VariableResolver()
Method Detail |
---|
public static java.lang.Object resolveVariables(javax.faces.context.FacesContext ctx, LayoutElement desc, javax.faces.component.UIComponent component, java.lang.String string, java.lang.String startToken, java.lang.String typeDelim, java.lang.String endToken)
This method will substitute variables into the given String, or
return the variable if the substitution is the whole String. This
method looks for the LAST occurance of startToken in the given
String. It then searches from that location (if found) to the
first occurance of typeDelim. The value inbetween is used as the
type of substitution to perform (i.e. request attribute, session,
etc.). It next looks for the next occurance of endToken. The
value inbetween is used as the key passed to the
VariableResolver.DataSource
specified by the type. The
String value from the VariableResolver.DataSource
replaces
the portion of the String from the startToken to the endToken. If
this is the entire String, the Object is returned instead of the
String value. This process is repeated until no more
substitutions are * needed.
This algorithm will accomodate nested variables (e.g. "${A{$x}}"). It also allows the replacement value itself to contain variables. Care should be taken to ensure that the replacement String included does not directly or indirectly refer to itself -- this will cause an infinite loop.
There is one special case where the string to be evaluated begins with the startToken and ends with the endToken. In this case, string substitution is NOT performed. Instead the value of the request attribute is returned.
ctx
- The FacesContextdesc
- The closest LayoutElement to this stringcomponent
- The assoicated UIComponentstring
- The string to be evaluated.startToken
- Marks the beginning "$"typeDelim
- Marks separation of type/variable "{"endToken
- Marks the end of the variable "}"
public static java.lang.Object resolveVariables(LayoutElement desc, javax.faces.component.UIComponent component, java.lang.Object value)
desc
- The LayoutElement
descriptorcomponent
- The UIComponent
value
- The value to resolve
public static java.lang.Object resolveVariables(javax.faces.context.FacesContext ctx, LayoutElement desc, javax.faces.component.UIComponent component, java.lang.Object value)
ctx
- The FacesContext
desc
- The LayoutElement
descriptorcomponent
- The UIComponent
value
- The value to resolve
public static VariableResolver.DataSource getDataSource(java.lang.String key)
This method looks up the requested
VariableResolver.DataSource
by the given key.
key
- The key identifying the desired
VariableResolver.DataSource
VariableResolver.DataSource
public static void setDataSource(java.lang.String key, VariableResolver.DataSource dataSource)
This method sets the given VariableResolver.DataSource
to
be used for $[type]{...} when key matches type.
key
- The key identifying the
VariableResolver.DataSource
dataSource
- The VariableResolver.DataSource
public static void main(java.lang.String[] args)
args
- The commandline arguments.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |