|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.weborganic.furi.VariableBinder
public class VariableBinder
A convenience class is to bind variables to resolvers in a set of URI patterns.
Variables can be bound to a resolver by type or by name.
To assign a VariableResolver
to variables of a specific type, use bindType(String, VariableResolver)
.
The following example will bind all variables typed int
to return the corresponding integer value.
VariableBinder binder = new VariableBinder(); b.bindType("int", new VariableResolver(){ public boolean exists(String v) {return v.matches("\\d+");} public Integer resolve(String v) {return exists(v)? Integer.valueOf(v) : null;}; });To assign a
VariableResolver
to variables of a specific name, use bindName(String, VariableResolver)
.
The following example will bind all variables typed int
to return the corresponding integer value.
VariableBinder binder = new VariableBinder(); b.bindName("name", new VariableResolver(){ public boolean exists(String v) {return true;} public Integer resolve(String v) {return exists(v)? Integer.valueOf(v) : null;}; });
Constructor Summary | |
---|---|
VariableBinder()
|
Method Summary | |
---|---|
void |
bind(String name,
VariableResolver resolver)
Deprecated. use #bindName() or #bindType() instead |
void |
bindName(String name,
VariableResolver resolver)
Binds the variables with the specified name to the specified resolver. |
void |
bindType(String type,
VariableResolver resolver)
Binds the variables with the specified name to the specified resolver. |
VariableResolver |
getResolver(String name)
Returns the resolver used for the variable of the specified name. |
VariableResolver |
getResolver(String name,
VariableType type)
Returns the resolver used for the variable of the specified name or type. |
VariableResolver |
getResolver(VariableType type)
Returns the resolver used for the variable of the specified type. |
boolean |
isNameBound(String name)
Indicates whether the given variable name is bound to a VariableResolver. |
boolean |
isTypeBound(String type)
Indicates whether the given variable type is bound to a VariableResolver. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public VariableBinder()
Method Detail |
---|
public void bind(String name, VariableResolver resolver)
name
- The name of the variable.resolver
- The resolver to use with these variables.public void bindName(String name, VariableResolver resolver)
name
- The name of the variable.resolver
- The resolver to use with these variables.public void bindType(String type, VariableResolver resolver)
type
- The variable type.resolver
- The resolver to use with these variables.public VariableResolver getResolver(String name, VariableType type)
By default, looks for the resolver assigned to the specified variable name; if no resolver is bound to the variable name, it will return the resolver bound to the given variable type.
This method does not return null
. If the specified variable name or type is not
bound to any resolver the default resolver if returned instead.
name
- The name of the variable.type
- The type of the variable.
public VariableResolver getResolver(String name)
This method does not return null
. If the specified variable name is no bound
to any resolver the default resolver if returned instead.
name
- The name of the variables.
public VariableResolver getResolver(VariableType type)
This method does not return null
. If the specified variable name is no bound
to any resolver the default resolver if returned instead.
type
- The type of the variable.
public boolean isNameBound(String name)
name
- The variable name.
true
if a given variable resolver is bound to the specific name;
false
otherwise (including if the name is null
.public boolean isTypeBound(String type)
type
- The variable type.
true
if a given variable resolver is bound to the specific type;
false
otherwise (including if the type is null
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |