public class PathConverter extends Object implements ValueConverter
PathSetter
and
PathType
annotations. The values are converted using the
following rules:
/images/copy.png --> /base2/images/copy.png
.
~/images/myimage.png --> /base2/extensions/my-extensions.jar/images/myimage.png
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.
Modifier and Type | Field and Description |
---|---|
private String |
home |
private String |
root |
Constructor and Description |
---|
PathConverter()
Create a new empty path converter.
|
PathConverter(String root,
String home)
Create a new initialised path converter.
|
Modifier and Type | Method and 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.
|
public PathConverter()
setRoot(String)
and setHome(String)
to initialise it.public String convert(String in, Method method)
ValueConverter
convert
in interface ValueConverter
in
- The value to convertmethod
- The factory setter methodpublic void setRoot(String root)
public String getRoot()
public void setHome(String home)
public String getHome()