public interface ItsNatVariableResolver
The variable syntax follows the JSP Expression Language notation:
${name}
.
Modifier and Type | Method and Description |
---|---|
ItsNatVariableResolver |
createItsNatVariableResolver()
Creates a variable resolver as a child of this resolver (bound to this resolver).
|
java.lang.Object |
getLocalVariable(java.lang.String name)
Returns the value associated to the specified name,
only the local registry of this resolver is searched.
|
java.lang.Object |
getVariable(java.lang.String name)
Returns the value associated to the specified name.
|
void |
introspect(java.lang.String refName,
java.lang.Object obj)
Introspect the specified object registering all JavaBeans properties
as local variables prefixed with the specified reference name.
|
boolean |
isDisconnected()
Informs whether this variable resolver is disconnected (does not have a parent).
|
java.lang.Object |
removeLocalVariable(java.lang.String name)
Unregisters the variable with the specified name from the local registry
of this resolver.
|
boolean |
resolve(org.w3c.dom.Node node)
Iterates recursively into the DOM subtree resolving (replacing) if possible any variable found with the
format ${name} into element attributes and text based nodes.
|
java.lang.String |
resolve(java.lang.String str)
Locates and replaces any variable declaration with format ${name} contained into the specified string with
the variable value converted to string (
Object.toString() ). |
java.lang.Object |
setLocalVariable(java.lang.String name,
java.lang.Object value)
Registers the specified variable name and value into the local registry
of this resolver.
|
boolean isDisconnected()
ItsNatVariableResolver createItsNatVariableResolver()
java.lang.Object getLocalVariable(java.lang.String name)
name
- the name to search for.setLocalVariable(String,Object)
,
removeLocalVariable(String)
java.lang.Object setLocalVariable(java.lang.String name, java.lang.Object value)
name
- the variable name.value
- the variable value.getLocalVariable(String)
java.lang.Object removeLocalVariable(java.lang.String name)
name
- the variable name.getLocalVariable(String)
void introspect(java.lang.String refName, java.lang.Object obj)
Current implementation uses jav.beans.Introspector.getBeanInfo(Class)
to get all JavaBeans properties. The reference name and property name are used
to build a qualified name using a dot as separator, this
qualified name is used to register as variable (e.g. "person.firstName"
where "person" is the reference name and "firstName" is a JavaBeans property).
refName
- reference name used to qualify JavaBeans properties. If null or empty no prefix is added to property names.obj
- reference to the object value to introspect and register its JavaBeans properties.java.lang.Object getVariable(java.lang.String name)
First of all the local registry is searched calling getLocalVariable(String)
.
If this method returns null and this resolver is "disconnected" (was created calling ItsNatDocument.createItsNatVariableResolver(boolean)
with
parameter disconnected
set to true) variable resolution ends returning null.
If "connected" (variable resolver was created with any other factory method)
the "owner" of this resolver is used:
If the variable resolver is a child of another variable resolver
(was created with createItsNatVariableResolver()
)
then the method getVariable(String)
of the parent is called to continue searching.
If the variable resolver was created with ItsNatServletContext.createItsNatVariableResolver()
then the method ServletContext.getAttribute(String)
is called to continue searching.
If the variable resolver was created with ItsNatSession.createItsNatVariableResolver()
then the method ItsNatSession.getAttribute(String)
is called to continue searching,
if returns null then delegates to the method ServletContext.getAttribute(String)
.
If the variable resolver was created with ItsNatDocument.createItsNatVariableResolver()
then the method ItsNatDocument.getAttribute(String)
is called to continue searching,
if returns null then delegates to the method ItsNatSession.getAttribute(String)
,
if returns null then delegates to the method ServletContext.getAttribute(String)
.
name
- the name to search for.java.lang.String resolve(java.lang.String str)
Object.toString()
).
To obtain the value the method getVariable(String)
is called,
if no variable is found the variable declaration is kept as is.
The same variable may be repeated.
str
- the source string to resolve declared variables.resolve(org.w3c.dom.Node)
boolean resolve(org.w3c.dom.Node node)
The method resolve(String)
is used to process element attributes
and content of text based nodes.
node
- the node to resolve.Copyright © 2007 Innowhere Software Services S.L. All Rights Reserved.