|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ValueProvider
interface represents a concept an attribute value getter,
which can be chained in order to implement a particular fall-back strategy.
An implementation of the ValueProvider
is specific to a particular value source,
e.g. a flat-file, an XML file, relational database, HttpServletRequest
, HttpSession
,
CC/PP profile and other. When instantiating a ValueProvider
,
the user must specify a unique name of an attribute and optionally can also provide a default --
another instance of the ValueProvider
interface which is used as
a fall-back in the case the attribute value is not set in the former ValueProvider
instance.
This defaulting principle can be applied recursively thus forming a chain of ValueProvider
instances
to implement a particular fall-back strategy: for example, to retrieve a value from command line parameters,
if not set, than from a configuration file and eventually to fall-back to a built-in constant.
It is important to note that attribute name can differ for each ValueProvider
in the chain as
the same semantical entity can have different names in different contexts.
Method Summary | |
java.lang.String |
getAttributeName()
Returns attribute name. |
ValueProvider |
getDefault()
Returns the next ValueProvider in the chain. |
java.lang.Object |
getLocalValue()
Returns attribute value. |
java.lang.Object |
getValue()
Returns attribute value. |
boolean |
hasLocalValue()
Checks whether the attribute is currently set. |
boolean |
hasValue()
Checks whether the attribute is currently set. |
PreferenceChain |
toPreferenceChain()
Takes the current snapshot of the ValueProvider chain returning a list of values
in the ValueProvider chain. |
Method Detail |
public java.lang.String getAttributeName()
ValueProvider
is bound to.public java.lang.Object getValue()
ValueProvider
instances.)
public boolean hasValue()
ValueProvider
instances.)
true
if the value is set for any ValueProvider
in the chain,
false
otherwisepublic java.lang.Object getLocalValue()
public boolean hasLocalValue()
true
if the value is set for this ValueProvider
instance,
false
otherwisepublic ValueProvider getDefault()
ValueProvider
in the chain.
ValueProvider
in the chain or null
when invoked for the tail of the chain.public PreferenceChain toPreferenceChain()
ValueProvider
chain returning a list of values
in the ValueProvider
chain. A value is appended to the chain for those
value providers, where hasLocaleValue()
returns true
.
Remarks: Any item in the result PreferenceChain
can be the desired property value
as well as a PreferenceChain
or a PreferenceBag
of property values
as returned by an individual ValueProvider
in the chain.
The purpose of this method is mainly for diagnostics (tuning and debugging).
PreferenceChain
object - a list of values - can be an empty list.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |