Hi,
I am in the midst of writing a validator. Basically, there are different tokens, each with multiple values. (For eg: HJ^23^SDF) with "^" being a delimiter separating the values inside a token.
I need to ensure that each of these values falls within an accepted set of values, i.e For Token HJ, the first value can be <23,45,24,76> etc.
I have about 20 tokens and between 3-8 values per token.
What would be the best way to do this.
Only thing I can think of is build multiple sets with the accepted values and check corresponding values with the appropriate set.
i.e
String[]
pattern = {23,25,24,76}; Set set=new TreeSet();
for(i=0;i<pattern.length;i++)
set.add(pattern[i]);
And then
set.contains(value)
Is there a better/cleaner way to do this?
Thank You
Karthik