First problem is that you set the
root
to
null
and try to use that;
root = root.GetChild(0);
You need to make sure you don't keep processing after
root
is
null
. One way might be by fixing the
for-loop;
for (int i = 0; i<definition.length() && root != null; i++)
But even then, as you let
root
change inside
CreateFromDefinition
it will still be
null
when the method completes, and since
GetListDefinition
calls
root.toString()
it will fail.
You'll want to make sure the
root
member always points to the root, a lazy way of achieving this would be to set
root
to the initial node created;
int startofname = 0;
ADS2TreeNode current = new ADS2TreeNode (definition) ;
root = current ;
ADS2TreeNode r = current;
then, at the end of that method, set
root=r;
.
Hope this helps,
Fredrik