Class URITool


  • @DefaultKey("uriTool")
    public class URITool
    extends Object
    An Apache Velocity tool that provides utility methods to work with URIs/URLs and links.
    Since:
    1.0
    Author:
    Andrius Velykis
    • Constructor Detail

      • URITool

        public URITool()
    • Method Detail

      • relativizeLink

        public static String relativizeLink​(String baseDirUri,
                                            String link)
        Resolves the link as relative to the base dir URI.

        Relativizes only absolute links, if the link has the same scheme, host and port as the base, it is made into a relative link as viewed from the base.

        This is the same method that's used to relativize project links in Maven site.

        Parameters:
        baseDirUri - URI that will serve as the base to calculate the relative one
        link - The link to relativize (make it relative to the base URI if possible)
        Returns:
        the relative link, if calculated, or the original link if not.
        Since:
        1.0
      • toURI

        public static URI toURI​(String uri)