Hi all,

I have the following problem:

There is an Product classe which contains localized title with the getter:

public Localized<String> getTitle() {
           return _title;
       }

Localizes is a classe with private final Map<Locale, T> _bindings; and has the public getter: public T get(Locale locale) {}

Now I want to check in the LHS of my rule if the title contains some substring. I can do that with matches(regular expression), but how can I best iterate in the localizede strings of the title? I am now doing it with the following eval() way, but there must be a better solution:

There are 2 languages in Localizes, so I can check that with the public int size. There is also a methode get(Locale) to get the String of the given local, but how can I use that here?

$prd : Product()
$title : Localized(size == 2) from $prd.getTitle()
eval( matchesLocalTestString($title, "(?i).*SUBSTRING.*") )

function boolean matchesLocalTestString(Localized locString, String matchString) {
   String tmpStr = (String) locString.get(LocaleUtils.DUTCH);
   return tmpStr.matches(matchString) ;
}

The code above works, but I can't get the result of the eval and I don't think this is the fastest way. So can anyone please help me with this?

Thanks,

Waruzjan Shahbazian
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to