Class PathConverter
java.lang.Object
net.sf.basedb.util.extensions.xml.PathConverter
- All Implemented Interfaces:
ValueConverter
public class PathConverter extends Object implements ValueConverter
A value converter that can be used on all setter methods
that has been annotated with the
PathSetter
and
PathType
annotations. The values are converted using the
following rules:
- If the value starts with '/', the root path is added to the start
of the value, for example,
/images/copy.png --> /base2/images/copy.png
. - If the value starts with '~', the path to the home directory for
the current extension is added, for example,
~/images/myimage.png --> /base2/extensions/my-extensions.jar/images/myimage.png
- If the path type is
PathType.CONTEXT_RELATIVE
the context-path is removed from the final path. Eg./base2/images/copy.png --> /images/copy.png
Note 1! It is only the start of the value that is checked. If a '~' is present in the middle of a value, it is not replaced.
Note 2! Using the VariableSetter
annotation and values like
$ROOT$/images/copy.png
would have the same result. The only
reason to use this annotation is that it allows for a shorter notation.
- Version:
- 2.7
- Author:
- nicklas
- Last modified
- $Date:2008-03-20 12:15:25 +0100 (Thu, 20 Mar 2008) $
-
Field Summary
-
Constructor Summary
Constructors Constructor Description PathConverter()
Create a new empty path converter.PathConverter(String root, String home)
Create a new initialised path converter. -
Method Summary
Modifier and Type Method Description String
convert(String in, Method method)
Convert a value.String
getHome()
Get the value of the home path.String
getRoot()
Get the value of the root path.void
setHome(String home)
Set the value of the home path.void
setRoot(String root)
Set the value of the root path.
-
Field Details
-
root
-
home
-
-
Constructor Details
-
PathConverter
public PathConverter()Create a new empty path converter. UsesetRoot(String)
andsetHome(String)
to initialise it. -
PathConverter
Create a new initialised path converter.- Parameters:
root
- The path to the root directory (/)home
- The path to the home directory (~)
-
-
Method Details
-
convert
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
-
setRoot
Set the value of the root path. -
getRoot
Get the value of the root path. -
setHome
Set the value of the home path. -
getHome
Get the value of the home path.
-