package net.xprova.propertylanguage;

import java.util.ArrayList;
import java.util.List;

public class TreeNode {

	public String name;
	public int delay;
	public List<TreeNode> children;

	public TreeNode(String name, TreeNode child, int delay) {

		this.name = name;

		this.delay = delay;

		this.children = new ArrayList<TreeNode>();

		children.add(child);
	}

	public TreeNode(String name, List<TreeNode> children) {

		this(name, children, 0);
	}

	public TreeNode(String name, int delay) {

		this(name, new ArrayList<TreeNode>(), delay);
	}

	public TreeNode(String name, List<TreeNode> children, int delay) {

		this.name = name;

		this.children = children == null ? new ArrayList<TreeNode>() : children;

		this.delay = delay;
	}

	public TreeNode(TreeNode other) {

		this.name = other.name;

		this.delay = other.delay;

		this.children = new ArrayList<TreeNode>();

		for (TreeNode c : other.children)
			this.children.add(new TreeNode(c));

	}

	public void print() {

		print("", true);
	}

	public boolean isTerminal() {

		return children.isEmpty();

	}

	private void print(String prefix, boolean isTail) {

		String n = delay != 0 ? String.format("%s (delay %d)", name, delay) : name;

		System.out.println(prefix + (isTail ? "└── " : "├── ") + n);

		if (children != null) {

			for (int i = 0; i < children.size() - 1; i++)
				children.get(i).print(prefix + (isTail ? "    " : "│   "), false);

			if (children.size() > 0)
				children.get(children.size() - 1).print(prefix + (isTail ? "    " : "│   "), true);

		}
	}
}
@@ -1245,20 +1245,50 @@
  ? %22
-%E2%94%94%E2%94%80%E2%94%80 %22 : %22%E2%94%9C%E2%94%80%E2%94%80
+%5Cu2514%5Cu2500%5Cu2500 %22 : %22%5Cu251C%5Cu2500%5Cu2500
  %22) 
@@ -1421,25 +1421,30 @@
 ? %22    %22 : %22
-%E2%94%82
+%5Cu00E2
    %22), false
@@ -1552,9 +1552,14 @@
  : %22
-%E2%94%82
+%5Cu00E2
    %22

Fix issue with unicode chars in tree display