VariablesWatcher vars = TODSessionFactory.getDefault().getVarialesWatcher();
ArrayList<Object> kids = new ArrayList<Object>();
if(parent instanceof String) {
String s = (String) parent;
if(s.compareTo(this.TOD_ROOT)==0) {
MirroredObjectInstance moi = vars.getThis();
if(moi != null) {
TODDataStorage.ThisObject th = new TODDataStorage.ThisObject();
th.myThis = moi;
kids.add(th);
}
// Add variables in scope.
Iterator<Variable> locals = vars.getVariablesInScope();
while (locals.hasNext()) {
Variable var = locals.next();
ChildNode n = new ChildNode();
n.data = var;
n.parent = moi;
kids.add(n);
}
}
} else if (parent instanceof ThisObject) {
ThisObject t = (ThisObject)parent;
MirroredObjectInstance me = t.myThis;
Iterator<FieldVariable> fields = me.getFields();
while (fields.hasNext()) {
ChildNode n = new ChildNode();
n.data = fields.next();
n.parent = me;
kids.add(n);
}
} else if (parent instanceof ChildNode) {
ChildNode t = (ChildNode)parent;
if (t.data.getValue() instanceof MirroredObjectInstance) {
MirroredObjectInstance o = (MirroredObjectInstance)t.data.getValue();
if (o instanceof MirroredQuorumArray) {
MirroredQuorumArray array = (MirroredQuorumArray)o;
MirroredValue[] values = array.getArray();
for (int x = 0; x < values.length; x++) {
ArrayElementNode n = new ArrayElementNode();
n.index = x;
n.parent = array;
n.data = values[x];
kids.add(n);
}
} else {
Iterator<FieldVariable> fields = o.getFields();
while (fields.hasNext()) {
ChildNode n = new ChildNode();
n.data = fields.next();
n.parent = o;
kids.add(n);
}
}
}
} else if (parent instanceof ArrayElementNode) {
ArrayElementNode t = (ArrayElementNode)parent;
if (t.data instanceof MirroredObjectInstance) {
MirroredObjectInstance o = (MirroredObjectInstance)t.data;
if (o instanceof MirroredQuorumArray) {
MirroredQuorumArray array = (MirroredQuorumArray)o;
MirroredValue[] values = array.getArray();
for (int x = 0; x < values.length; x++) {
ArrayElementNode n = new ArrayElementNode();
n.index = x;
n.parent = array;
n.data = values[x];
kids.add(n);
}
} else {
Iterator<FieldVariable> fields = o.getFields();
while (fields.hasNext()) {
ChildNode n = new ChildNode();
n.data = fields.next();
n.parent = o;
kids.add(n);