All Downloads are FREE. Search and download functionalities are using the official Maven repository.

it.amattioli.workstate.info.TreeBuilder Maven / Gradle / Ivy

There is a newer version: 1.0.7
Show newest version
package it.amattioli.workstate.info;
import java.util.*;

public abstract class TreeBuilder {
  private Stack nodeStack = new Stack();
  private TreeInfo current; 
  
  protected abstract TreeInfo buildNode(String tag, Object info);
  
  public void newNode(String tag, Object info) {
    TreeInfo newNode = buildNode(tag, info);
    if (current != null) {
      current.addSubNode(tag,newNode);
      nodeStack.push(current);
    }
    current = newNode;    
  }
  
  public void closeNode() {
    if (!nodeStack.empty()) {
      current = nodeStack.pop();
    }
  }
  
  public TreeInfo getResult() {
    return current;
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy