public Object[] getChildren(Object parent, int from, int to) throws UnknownTypeException {
ArrayList<Object> kids = new ArrayList<Object>();
if(parent instanceof String) {
String s = (String) parent;
if(s.compareTo(QUORUM_ROOT)==0) {
RuntimeObject ro = data.getThisObject();
if(ro != null) {
ThisObject th = new ThisObject();
th.myThis = ro;
kids.add(th);
}
Iterator<DataObject> obs = data.getVariablesInActionScope();
while(obs.hasNext()) {
kids.add(obs.next());
}
}
}
else if(parent instanceof DataObject) {
DataObject d = (DataObject) parent;
String name = d.getName();
ExpressionValue value = d.getCurrentValue();
if(value == null){
value = data.getLocalScope().getVariable(name);
}
if(value != null && value.getType() != null && !value.getType().isPrimitiveType()) {
if(!value.isNull()) { //it's a legal object
//request the object of that hash number from the
//data environment
int hash = value.getObjectHash();
RuntimeObject object = data.getObject(hash);
if(object != null && object.hasParents()) {
InheritanceNode node = new InheritanceNode();
node.child = object;
kids.add(node);
}
if(object != null) {
Iterator<DataObject> obs = object.getLocalVariables();
while(obs.hasNext()) {
kids.add(obs.next());
}
addArrayChildren(kids, object);
}
}
}
}
else if (parent instanceof InheritanceNode){ //an object with parents
InheritanceNode node = (InheritanceNode) parent;
RuntimeObject child = node.child;
Iterator<RuntimeObject> ros = child.getParents();
while(ros.hasNext()) {
kids.add(ros.next());
}
}
else if (parent instanceof RuntimeObject){ //a parent of an object
RuntimeObject node = (RuntimeObject) parent;
if(node.hasLocalVariables()) {//if it has variables, display them
Iterator<DataObject> vars = node.getLocalVariables();
while(vars.hasNext()) {
ChildNode cn = new ChildNode();
cn.scope = node;
cn.data = vars.next();
kids.add(cn);
}
}
}
else if (parent instanceof ThisObject){ //a parent of an object
ThisObject th = (ThisObject)parent;
RuntimeObject node = th.myThis;
if(node.hasLocalVariables()) {//if it has variables, display them
Iterator<DataObject> vars = node.getLocalVariables();
while(vars.hasNext()) {
ChildNode cn = new ChildNode();
cn.scope = node;
cn.data = vars.next();
kids.add(cn);
}
}
}
else if (parent instanceof ChildNode){ //a parent of an object
ChildNode n = (ChildNode) parent;
DataObject d = n.data;
String name = d.getName();
ExpressionValue value = n.scope.getVariable(name);
if(value != null && value.getType() != null && !value.getType().isPrimitiveType()) {
if(!value.isNull()) { //it's a legal object
//request the object of that hash number from the
//data environment
int hash = value.getObjectHash();
RuntimeObject object = data.getObject(hash);
if(object.hasParents()) {
InheritanceNode node = new InheritanceNode();
node.child = object;
kids.add(node);
}
Iterator<DataObject> obs = object.getLocalVariables();
while(obs.hasNext()) {
kids.add(obs.next());
}
}
}
}
else if(parent instanceof ArrayChild) {
ArrayChild child = (ArrayChild) parent;
RuntimeObject node = child.object;
if(node.hasLocalVariables()) {//if it has variables, display them
Iterator<DataObject> vars = node.getLocalVariables();
while(vars.hasNext()) {
ChildNode cn = new ChildNode();
cn.scope = node;
cn.data = vars.next();
kids.add(cn);