Class VariableConverter
- java.lang.Object
-
- net.sf.basedb.util.extensions.xml.VariableConverter
-
- All Implemented Interfaces:
ValueConverter
public class VariableConverter extends Object implements ValueConverter
A value converter that can be used on all setter methods that has been annotated with theVariableSetter
annotation. The input string will be scanned for parts that match$VARIABLE$
and have that part replaced by the actual value of a defined variable. Undefined variables are not replaced. SeesetVariable(String, String)
for more details.Web client note! The web client application defines the variables
ROOT
andHOME
which are the paths to the web application root directory (/base2
) and the home directory (/base2/extensions/xxxx
) of the current extension. This means that the XML configuration file may contain values like$ROOT$/images/copy.png
. The$ROOT$
portion will automatically be replaced with the correct path if the factory method is annotated with theVariableSetter
annotation.- Version:
- 2.7
- Author:
- nicklas
- Last modified
- $Date:2008-03-20 12:15:25 +0100 (Thu, 20 Mar 2008) $
-
-
Constructor Summary
Constructors Constructor Description VariableConverter()
Create a new variable converter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
convert(String in, Method method)
Convert a value.String
getVariable(String name)
Get the value of a variable.void
setVariable(String name, String value)
Set the value of a variable.
-
-
-
Constructor Detail
-
VariableConverter
public VariableConverter()
Create a new variable converter. UsesetVariable(String, String)
to define variables andXmlLoader.addValueConverter(ValueConverter)
to register this converter with an XML loader.
-
-
Method Detail
-
convert
public String convert(String in, Method method)
Description copied from interface:ValueConverter
Convert a value.- Specified by:
convert
in interfaceValueConverter
- Parameters:
in
- The value to convertmethod
- The factory setter method- Returns:
- The converted or original value
-
setVariable
public void setVariable(String name, String value)
Set the value of a variable. If a setter method of a factory class (ActionFactory
orRendererFactory
) is annotated with theVariableSetter
annotation the XML loader will scan the value from the XML file for replacement tags,$VARIABLE$
, and replace the tag with the value of the variable. If the variable doesn't exists, the tag is left untouched.- Parameters:
name
- The name of the variablevalue
- The value of the variable, or null to remove the variable
-
-