populating a tree with the file revisions
<p>`The requirement is that a tree has to be populated with revisions of a file. </p>

<p>I have  a command  that fetches all the revisions of a particular file from MKS(Versioning system). </p>

<p>using the following command in java </p>

<pre><code>Process p = Runtime.getRuntime().exec("cmd /C "+cmd);
</code></pre>

<p>i get all the versions of file.c. now i want to populate the data onto a Tree structure. how do i do that?</p>

<pre><code>try { 
 List&lt;String&gt; lVersions = new ArrayList&lt;String&gt;();
 Process p = Runtime.getRuntime().exec("cmd /C "+cmd); 
 BufferedReader in = new BufferedReader( new InputStreamReader(p.getInputStream()));
 String line = null; 
 while ((line = in.readLine()) != null)
 { 
   lVersions .add(line); 
 }
 }catch (IOException e) 
 { e.printStackTrace(); 
 }
</code></pre>

<p>lVersions contain the following output. It shows the all the revisions of a particular file. I need to populate this information on to a Tree structure. </p>

<pre><code>1.1
1.1.1.1
1.1.1.2
1.1.1.3
1.1.1.4
1.2
1.3  
</code></pre>

<p>I have created a Tree Class </p>

<p>public class Tree {</p>

<pre><code>private List&lt;Tree&gt; children = new ArrayList&lt;Tree&gt;();
private String label;
private Tree parent;
private String root;

public Tree() {
    super();
    children = new ArrayList&lt;Tree&gt;();
    }

    public Tree(String label) {
    this();
    setData(label);
    }

    public void setRoot(String root){
    this.root= root;
}
public String getRoot(){
    return root;
}
public void addChild(Tree child) {

    child.setParent(this);
    children.add(child);
}

public void removeChild(Tree node) {
    children.remove(node);
    node.setParent(null);
}

public void setParent(Tree parent) {
    this.parent = parent;
}

public Object[] getChildren() {
    return children.toArray();
}

public Object getParent() {
    return parent;
}

public String getLabel() {
    return this.label;
}
public void setData(String label) {
    this.label = label;
    }
</code></pre>

<p>}</p>

<p>I have to generate the following tree structure and also remember the parent of each node. I am not asking for the code but some pointers as to how to start and to proceed would be very helpful !!!!     </p>

<pre><code>    1.1
 1.2    1.1.1.1
 1.3    1.1.1.2
 1.4    1.1.1.3
        1.1.1.4
</code></pre>
