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 Details

  • Constructor Details

    • PathConverter

      public PathConverter()
      Create a new empty path converter. Use setRoot(String) and setHome(String) to initialise it.
    • PathConverter

      public PathConverter(String root, String home)
      Create a new initialised path converter.
      Parameters:
      root - The path to the root directory (/)
      home - The path to the home directory (~)
  • Method Details

    • convert

      public String convert(String in, Method method)
      Description copied from interface: ValueConverter
      Convert a value.
      Specified by:
      convert in interface ValueConverter
      Parameters:
      in - The value to convert
      method - The factory setter method
      Returns:
      The converted or original value
    • setRoot

      public void setRoot(String root)
      Set the value of the root path.
    • getRoot

      public String getRoot()
      Get the value of the root path.
    • setHome

      public void setHome(String home)
      Set the value of the home path.
    • getHome

      public String getHome()
      Get the value of the home path.