java - How do you recursively replace occurences of a string in an array -


Then consider a class A with two string variables "name" and "value"

Class B is a variable that is set

  set < A & gt; AllVariables   

is a set that looks like this

  A.name = "$ var1" value = "x + 10" gt; 2 "A .name =" $ var2 "Evolution =" 11 + y% 10 == 0 "A name =" $ var3 "= values ​​$" var1 "and" $ Var2 "  

What I need to do is evaluate these expressions. I am using jexl for this to be me through the set and repeat these variable names with their respective Need to change with the values.

In this case, the object named $ var3 is named "x + 10" 2 & amp; 11; + Y% 10 == 0 "

How do I do this?

2 make the Hashmap, translated and toTranslate .

You parse your set.

For example, if you see any value, if the value is any number in the $ element ( $ sign in), then you can enter in your translated HashMap keys $ Element .

If it's there, then you can search in your translated hash You can replace the $ element from the AY value.

You do this for each separate $ element you found in your object .

If all $ element has been translated, then add your object A to translated hashmap (key = name, value = value). ).

Otherwise, you add it to your toTranslate hashp.

Once all your sets have been parsed, you get 2 hamsps Are there.

You create a loop for a while: while toTranslate hashp is not empty, then you get each value, and $ element translate your People in Hashp have close

Be careful, you can end up with an infinite loop. One good thing will be to make sure that every time you loop on toTranslate hash, its number of elements decreases. If you are not in the infinite loop.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -