Book a Demo

Author Topic: String processing in template framework  (Read 3164 times)

Jakub

  • EA Novice
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
String processing in template framework
« on: November 21, 2013, 12:21:51 am »
Is it possible to somehow match and parse the string within transformation template (CDT) ?

I have a string: Dictionary<String, Shift> and I would need:
1) detect tha string starts with Dictionary keyword
2)extract  second parameter -> Shift

I tried following but I am not sure what's wrong:
%If FIND(opReturnType,"Dictionary")>=0 %
$note=%opReturnType%
$ty=%TRIM(REPLACE(opReturnType,"Dictionary",""))%
$pos=%FIND($ty,",")%
$ty=%RIGHT($ty,LENGTH($ty)-$pos)%
$type=%TRIM(REPLACE($ty,">",""))%
%else%
$type= %opReturnType%
%endIf%
« Last Edit: November 21, 2013, 01:02:19 am by jaksky »

Jakub

  • EA Novice
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
Re: String processing in template framework
« Reply #1 on: November 21, 2013, 04:17:03 am »
$dic=%FIND(opReturnType,"Dictionary")%

%If $dic!="-1"%
$note="TODO://Replace: with java.util.Map "
$note+=%opReturnType%
$t=%opReturnType%
$pos=%FIND($t,",")%
$dict=%LEFT($t,$pos)%
$ty=%REPLACE($t,$dict,"")%
$typ=%TRIM_LEFT($ty,",")%
$typp=%TRIM_RIGHT($typ,">")%
$type=%TRIM($typp)%
$lowerBound="0"
$upperBound="*"
%endIf%