How to parse a String into Java Tree?
<p>I have a method that generates pop-up menu with many submenus. Basically these menus given dynamically so I have to have algorithm to handle creating submenus using below string.
In order to do it I will need to transform this string into Java Tree by splitting using the delimiter. I am stuck on how to handle splitted string data and translate to the Java Tree Model according to Parent and children nodes.</p>

<p>An Example of Dynamic String Values that I need to parse:</p>

<p><strong>String str = " Menu1; Menu2; [Menu2A; Menu2B; [Menu2B-A; Menu2B-B];]; Menu3; ";</strong></p>

<p><strong>After Handling operation The output should be:</strong></p>

<pre><code>                                 Pop-up Menu
                                 /    |     \
                           Menu1    Menu2   Menu3
                                 /     | 

                              Menu2A     Menu2B
                                          |       \
                                          |        \
                                       Menu2B-A  Menu2B-B
</code></pre>
