public class PathConverter extends java.lang.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 java.lang.String |
home |
private java.lang.String |
root |
Constructor and Description |
---|
PathConverter()
Create a new empty path converter.
|
PathConverter(java.lang.String root,
java.lang.String home)
Create a new initialised path converter.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
convert(java.lang.String in,
java.lang.reflect.Method method)
Convert a value.
|
java.lang.String |
getHome()
Get the value of the home path.
|
java.lang.String |
getRoot()
Get the value of the root path.
|
void |
setHome(java.lang.String home)
Set the value of the home path.
|
void |
setRoot(java.lang.String root)
Set the value of the root path.
|
public PathConverter()
setRoot(String)
and setHome(String)
to initialise it.public PathConverter(java.lang.String root, java.lang.String home)
root
- The path to the root directory (/)home
- The path to the home directory (~)public java.lang.String convert(java.lang.String in, java.lang.reflect.Method method)
ValueConverter
convert
in interface ValueConverter
in
- The value to convertmethod
- The factory setter methodpublic void setRoot(java.lang.String root)
public java.lang.String getRoot()
public void setHome(java.lang.String home)
public java.lang.String getHome()