it.amattioli.workstate.info.TreeBuilder Maven / Gradle / Ivy
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