Text normalization (using design console)
849307Mar 22 2011 — edited May 3 2011Hi,
I'm trying to normalize a string for a prepopulate adapter for an email address. As you might know, an email address may not contain diacritics (in fact only a-z, A-Z, 0-9, -, _, and . are allowed). However, in Europe it is quite common for diacritics to occur in names. So I want to remove these diacritics without removing the base letters. For example 'Öztürk' should become 'Ozturk'.
Now there is a simple solution: create your own JavaTask that does this, using Normalizer.normalize(word, Form.NFD).replaceAll("\\p{InCombiningDiacriticalMarks}+", "");
In effect splitting the diacritics from the base character and then removing them.
However, for reasons I shall not go into now, I want to do this using the design console... And it is here where the tricky part starts.
The design console only lets you couple variables and tasks based on the input fields of tasks. And it does this a bit too strict. The normalize function in the java.text.normalizer class expects two arguments: a charsequence and a java.text.normalizer$Form. Whiles normally one simply gives a string to this function, using the design console one first needs to convert this somehow to a charsequence. Using the java.lang.String.subsequence(beginindex i, endindex j) function. Sigh. But oke, this works.
However the second argument is my problem, I can not seem to set the correct value or create the right object of this type. Using the design console.
So the question is: how do I create or pass a public static variable of a certain type? In this case a Enum named Form defined in the java.text.Normalizer Class that has static values NFC, NFD, NFKC and NFKD.
- Literal is not possible as it has no type of Normalizer$Form. So no string or integer referencing.
- Creating a Enum is not possible as this is a abstract type class.
Any insights would be greatly appreciated.
Jan Willem
Edited by: user13736222 on 22-mrt-2011 13:21: subject clearification
Edited by: Jan Willem Beusink on 23-mrt-2011 16:30 fixed typo in example command