I'm trying to create a command which would create a hyperlink based on a fully qualified java class name (e.g. "my.test.package_1.MyTest_Class")
What I'd like to achieve is to create based on e.g. my.test.package_1.MyTest_Class a \href which would point to a url based on this fully qualified class name and as the link name I'd like to have the class name only.
e.g.
from \mysrc{my.test.package_1.MyTest_Class} I want to have:
Code: Select all
\href
{https://www.xxx.yyy.com/src/my/test/package/MyTestClass.java}%
{\lstinline{MyTest_Class}}%
}%
Code: Select all
\newcounter {len}
%GETS THE CLASSNAME - i.e. the text after the last dot
\newcommand{\getclassname}[1]{%
\StrCount{#1}{.}[\dotcount]%
\StrPosition[\dotcount]{#1}{.}[\lastdotpos]%
\StrLen{#1}[\arglen]%
\setcounter{len}{0}%
\addtocounter{len}{\arglen}%
\addtocounter{len}{-\lastdotpos}%
\StrRight{#1}{\value{len}}%
}%
%CREATES THE LINK
\newcommand{\mysrc}[1]{%
\StrSubstitute{#1}{.}{/}[\SLASHNAME]%
\getclassname{#1}[\CLASSNAME]%
\href%
{https://aaa/src/\SLASHNAME.java}%
{\CLASSNAME}%
}%
Do you have any ideas, how I could achieve this task and maybe improve a bit my command (I'm quite new at writing latex commands)?
Thanks,
Kornel